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

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

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

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

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

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

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

sc_asn1_read_tag:
   64|   224k|{
   65|   224k|	const u8 *p = *buf;
   66|   224k|	size_t left = buflen, len;
   67|   224k|	unsigned int cla, tag, i;
   68|       |
   69|   224k|	*buf = NULL;
   70|       |
   71|   224k|	if (left == 0 || !p || buflen == 0)
  ------------------
  |  Branch (71:6): [True: 1.56k, False: 222k]
  |  Branch (71:19): [True: 0, False: 222k]
  |  Branch (71:25): [True: 0, False: 222k]
  ------------------
   72|  1.56k|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|  1.56k|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
   73|   222k|	if (*p == 0xff || *p == 0) {
  ------------------
  |  Branch (73:6): [True: 2.53k, False: 220k]
  |  Branch (73:20): [True: 6.95k, False: 213k]
  ------------------
   74|       |		/* end of data reached */
   75|  9.48k|		*taglen = 0;
   76|  9.48k|		*tag_out = SC_ASN1_TAG_EOC;
  ------------------
  |  |  194|  9.48k|#define SC_ASN1_TAG_EOC			0
  ------------------
   77|  9.48k|		return SC_SUCCESS;
  ------------------
  |  |   28|  9.48k|#define SC_SUCCESS				0
  ------------------
   78|  9.48k|	}
   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|   213k|	cla = (*p & SC_ASN1_TAG_CLASS) | (*p & SC_ASN1_TAG_CONSTRUCTED);
  ------------------
  |  |  184|   213k|#define SC_ASN1_TAG_CLASS		0xC0
  ------------------
              	cla = (*p & SC_ASN1_TAG_CLASS) | (*p & SC_ASN1_TAG_CONSTRUCTED);
  ------------------
  |  |  190|   213k|#define SC_ASN1_TAG_CONSTRUCTED		0x20
  ------------------
   85|   213k|	tag = *p & SC_ASN1_TAG_PRIMITIVE;
  ------------------
  |  |  191|   213k|#define SC_ASN1_TAG_PRIMITIVE		0x1F
  ------------------
   86|   213k|	p++;
   87|   213k|	left--;
   88|   213k|	if (tag == SC_ASN1_TAG_PRIMITIVE) {
  ------------------
  |  |  191|   213k|#define SC_ASN1_TAG_PRIMITIVE		0x1F
  ------------------
  |  Branch (88:6): [True: 6.30k, False: 206k]
  ------------------
   89|       |		/* high tag number */
   90|  6.30k|		size_t n = SC_ASN1_TAGNUM_SIZE - 1;
  ------------------
  |  |  145|  6.30k|#define SC_ASN1_TAGNUM_SIZE		3
  ------------------
   91|       |		/* search the last tag octet */
   92|  8.89k|		do {
   93|  8.89k|			if (left == 0 || n == 0)
  ------------------
  |  Branch (93:8): [True: 744, False: 8.14k]
  |  Branch (93:21): [True: 213, False: 7.93k]
  ------------------
   94|       |				/* either an invalid tag or it doesn't fit in
   95|       |				 * unsigned int */
   96|    957|				return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|    957|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
   97|  7.93k|			tag <<= 8;
   98|  7.93k|			tag |= *p;
   99|  7.93k|			p++;
  100|  7.93k|			left--;
  101|  7.93k|			n--;
  102|  7.93k|		} while (tag & 0x80);
  ------------------
  |  Branch (102:12): [True: 2.58k, False: 5.34k]
  ------------------
  103|  6.30k|	}
  104|       |
  105|       |	/* parse length byte(s) */
  106|   212k|	if (left == 0)
  ------------------
  |  Branch (106:6): [True: 1.14k, False: 211k]
  ------------------
  107|  1.14k|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|  1.14k|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  108|   211k|	len = *p;
  109|   211k|	p++;
  110|   211k|	left--;
  111|   211k|	if (len & 0x80) {
  ------------------
  |  Branch (111:6): [True: 23.8k, False: 187k]
  ------------------
  112|  23.8k|		len &= 0x7f;
  113|  23.8k|		unsigned int a = 0;
  114|  23.8k|		if (len > sizeof a || len > left)
  ------------------
  |  Branch (114:7): [True: 7.54k, False: 16.3k]
  |  Branch (114:25): [True: 324, False: 15.9k]
  ------------------
  115|  7.86k|			return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|  7.86k|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  116|  19.0k|		for (i = 0; i < len; i++) {
  ------------------
  |  Branch (116:15): [True: 3.05k, False: 15.9k]
  ------------------
  117|  3.05k|			a <<= 8;
  118|  3.05k|			a |= *p;
  119|  3.05k|			p++;
  120|  3.05k|			left--;
  121|  3.05k|		}
  122|  15.9k|		len = a;
  123|  15.9k|	}
  124|       |
  125|   203k|	*cla_out = cla;
  126|   203k|	*tag_out = tag;
  127|   203k|	*taglen = len;
  128|   203k|	*buf = p;
  129|       |
  130|   203k|	if (len > left)
  ------------------
  |  Branch (130:6): [True: 11.9k, False: 191k]
  ------------------
  131|  11.9k|		return SC_ERROR_ASN1_END_OF_CONTENTS;
  ------------------
  |  |   84|  11.9k|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  132|       |
  133|   191k|	return SC_SUCCESS;
  ------------------
  |  |   28|   191k|#define SC_SUCCESS				0
  ------------------
  134|   203k|}
sc_format_asn1_entry:
  138|   130k|{
  139|   130k|	entry->parm = parm;
  140|   130k|	entry->arg  = arg;
  141|   130k|	if (set_present)
  ------------------
  |  Branch (141:6): [True: 43.9k, False: 86.9k]
  ------------------
  142|  43.9k|		entry->flags |= SC_ASN1_PRESENT;
  ------------------
  |  |  147|  43.9k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  143|   130k|}
sc_copy_asn1_entry:
  147|  51.0k|{
  148|   199k|	while (src->name != NULL) {
  ------------------
  |  Branch (148:9): [True: 148k, False: 51.0k]
  ------------------
  149|   148k|		*dest = *src;
  150|   148k|		dest++;
  151|   148k|		src++;
  152|   148k|	}
  153|       |	dest->name = NULL;
  154|  51.0k|}
sc_asn1_find_tag:
  482|  46.2k|{
  483|  46.2k|	size_t left = buflen, taglen;
  484|  46.2k|	const u8 *p = buf;
  485|       |
  486|  46.2k|	*taglen_in = 0;
  487|   110k|	while (left >= 2) {
  ------------------
  |  Branch (487:9): [True: 93.7k, False: 17.0k]
  ------------------
  488|  93.7k|		unsigned int cla = 0, tag, mask = 0xff00;
  489|       |
  490|  93.7k|		buf = p;
  491|       |		/* read a tag */
  492|  93.7k|		if (sc_asn1_read_tag(&p, left, &cla, &tag, &taglen) != SC_SUCCESS
  ------------------
  |  |   28|   187k|#define SC_SUCCESS				0
  ------------------
  |  Branch (492:7): [True: 8.84k, False: 84.8k]
  ------------------
  493|  84.8k|				|| p == NULL)
  ------------------
  |  Branch (493:8): [True: 5.07k, False: 79.8k]
  ------------------
  494|  13.9k|			return NULL;
  495|       |
  496|  79.8k|		left -= (p - buf);
  497|       |		/* we need to shift the class byte to the leftmost
  498|       |		 * byte of the tag */
  499|  81.4k|		while ((tag & mask) != 0) {
  ------------------
  |  Branch (499:10): [True: 1.62k, False: 79.8k]
  ------------------
  500|  1.62k|			cla  <<= 8;
  501|  1.62k|			mask <<= 8;
  502|  1.62k|		}
  503|       |		/* compare the read tag with the given tag */
  504|  79.8k|		if ((tag | cla) == tag_in) {
  ------------------
  |  Branch (504:7): [True: 15.3k, False: 64.4k]
  ------------------
  505|       |			/* we have a match => return length and value part */
  506|  15.3k|			if (taglen > left)
  ------------------
  |  Branch (506:8): [True: 0, False: 15.3k]
  ------------------
  507|      0|				return NULL;
  508|  15.3k|			*taglen_in = taglen;
  509|  15.3k|			return p;
  510|  15.3k|		}
  511|       |		/* otherwise continue reading tags */
  512|  64.4k|		left -= taglen;
  513|  64.4k|		p += taglen;
  514|  64.4k|	}
  515|  17.0k|	return NULL;
  516|  46.2k|}
sc_asn1_skip_tag:
  520|  19.4k|{
  521|  19.4k|	const u8 *p = *buf;
  522|  19.4k|	size_t len = *buflen, taglen;
  523|  19.4k|	unsigned int cla = 0, tag;
  524|       |
  525|  19.4k|	if (sc_asn1_read_tag((const u8 **) &p, len, &cla, &tag, &taglen) != SC_SUCCESS
  ------------------
  |  |   28|  38.8k|#define SC_SUCCESS				0
  ------------------
  |  Branch (525:6): [True: 4.04k, False: 15.3k]
  ------------------
  526|  15.3k|			|| p == NULL)
  ------------------
  |  Branch (526:7): [True: 690, False: 14.6k]
  ------------------
  527|  4.73k|		return NULL;
  528|  14.6k|	switch (cla & 0xC0) {
  ------------------
  |  Branch (528:10): [True: 14.6k, False: 0]
  ------------------
  529|  5.75k|	case SC_ASN1_TAG_UNIVERSAL:
  ------------------
  |  |  185|  5.75k|#define SC_ASN1_TAG_UNIVERSAL		0x00
  ------------------
  |  Branch (529:2): [True: 5.75k, False: 8.92k]
  ------------------
  530|  5.75k|		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_UNI)
  ------------------
  |  |  136|  5.75k|#define SC_ASN1_CLASS_MASK		0xC0000000
  ------------------
              		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_UNI)
  ------------------
  |  |  137|  5.75k|#define SC_ASN1_UNI			0x00000000 /* Universal */
  ------------------
  |  Branch (530:7): [True: 1.97k, False: 3.77k]
  ------------------
  531|  1.97k|			return NULL;
  532|  3.77k|		break;
  533|  3.77k|	case SC_ASN1_TAG_APPLICATION:
  ------------------
  |  |  186|  3.19k|#define SC_ASN1_TAG_APPLICATION		0x40
  ------------------
  |  Branch (533:2): [True: 3.19k, False: 11.4k]
  ------------------
  534|  3.19k|		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_APP)
  ------------------
  |  |  136|  3.19k|#define SC_ASN1_CLASS_MASK		0xC0000000
  ------------------
              		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_APP)
  ------------------
  |  |  138|  3.19k|#define SC_ASN1_APP			0x40000000 /* Application */
  ------------------
  |  Branch (534:7): [True: 644, False: 2.55k]
  ------------------
  535|    644|			return NULL;
  536|  2.55k|		break;
  537|  5.54k|	case SC_ASN1_TAG_CONTEXT:
  ------------------
  |  |  187|  5.54k|#define SC_ASN1_TAG_CONTEXT		0x80
  ------------------
  |  Branch (537:2): [True: 5.54k, False: 9.13k]
  ------------------
  538|  5.54k|		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_CTX)
  ------------------
  |  |  136|  5.54k|#define SC_ASN1_CLASS_MASK		0xC0000000
  ------------------
              		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_CTX)
  ------------------
  |  |  139|  5.54k|#define SC_ASN1_CTX			0x80000000 /* Context */
  ------------------
  |  Branch (538:7): [True: 467, False: 5.07k]
  ------------------
  539|    467|			return NULL;
  540|  5.07k|		break;
  541|  5.07k|	case SC_ASN1_TAG_PRIVATE:
  ------------------
  |  |  188|    189|#define SC_ASN1_TAG_PRIVATE		0xC0
  ------------------
  |  Branch (541:2): [True: 189, False: 14.4k]
  ------------------
  542|    189|		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_PRV)
  ------------------
  |  |  136|    189|#define SC_ASN1_CLASS_MASK		0xC0000000
  ------------------
              		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_PRV)
  ------------------
  |  |  140|    189|#define SC_ASN1_PRV			0xC0000000 /* Private */
  ------------------
  |  Branch (542:7): [True: 189, False: 0]
  ------------------
  543|    189|			return NULL;
  544|      0|		break;
  545|  14.6k|	}
  546|  11.4k|	if (cla & SC_ASN1_TAG_CONSTRUCTED) {
  ------------------
  |  |  190|  11.4k|#define SC_ASN1_TAG_CONSTRUCTED		0x20
  ------------------
  |  Branch (546:6): [True: 6.64k, False: 4.76k]
  ------------------
  547|  6.64k|		if ((tag_in & SC_ASN1_CONS) == 0)
  ------------------
  |  |  141|  6.64k|#define SC_ASN1_CONS			0x20000000
  ------------------
  |  Branch (547:7): [True: 1.15k, False: 5.48k]
  ------------------
  548|  1.15k|			return NULL;
  549|  6.64k|	} else
  550|  4.76k|		if (tag_in & SC_ASN1_CONS)
  ------------------
  |  |  141|  4.76k|#define SC_ASN1_CONS			0x20000000
  ------------------
  |  Branch (550:7): [True: 172, False: 4.59k]
  ------------------
  551|    172|			return NULL;
  552|  10.0k|	if ((tag_in & SC_ASN1_TAG_MASK) != tag)
  ------------------
  |  |  144|  10.0k|#define SC_ASN1_TAG_MASK		0x00FFFFFF
  ------------------
  |  Branch (552:6): [True: 4.33k, False: 5.75k]
  ------------------
  553|  4.33k|		return NULL;
  554|  5.75k|	len -= (p - *buf);	/* header size */
  555|  5.75k|	if (taglen > len) {
  ------------------
  |  Branch (555:6): [True: 0, False: 5.75k]
  ------------------
  556|      0|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "too long ASN.1 object (size %zu while only %zu available)",
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  557|      0|				taglen, len);
  558|      0|		return NULL;
  559|      0|	}
  560|  5.75k|	*buflen -= (p - *buf) + taglen;
  561|  5.75k|	*buf = p + taglen;	/* point to next tag */
  562|  5.75k|	*taglen_out = taglen;
  563|  5.75k|	return p;
  564|  5.75k|}
sc_asn1_verify_tag:
  568|     21|{
  569|     21|	return sc_asn1_skip_tag(ctx, &buf, &buflen, tag_in, taglen_out);
  570|     21|}
sc_asn1_decode_integer:
  729|    617|{
  730|    617|	int    a = 0, is_negative = 0;
  731|    617|	size_t i = 0;
  732|       |
  733|    617|	if (inlen == 0) {
  ------------------
  |  Branch (733:6): [True: 15, False: 602]
  ------------------
  734|     15|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|     15|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  735|     15|	}
  736|    602|	if (inlen > sizeof(int)) {
  ------------------
  |  Branch (736:6): [True: 15, False: 587]
  ------------------
  737|     15|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|     15|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  738|     15|	}
  739|    587|	if (inbuf[0] & 0x80) {
  ------------------
  |  Branch (739:6): [True: 197, False: 390]
  ------------------
  740|    197|		if (strict && inlen > 1 && inbuf[0] == 0xff && (inbuf[1] & 0x80)) {
  ------------------
  |  Branch (740:7): [True: 0, False: 197]
  |  Branch (740:17): [True: 0, False: 0]
  |  Branch (740:30): [True: 0, False: 0]
  |  Branch (740:50): [True: 0, False: 0]
  ------------------
  741|      0|			return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  742|      0|		}
  743|    197|		is_negative = 1;
  744|    197|		a |= 0xff^(*inbuf++);
  745|    197|		i = 1;
  746|    390|	} else {
  747|    390|		if (strict && inlen > 1 && inbuf[0] == 0x00 && (inbuf[1] & 0x80) == 0) {
  ------------------
  |  Branch (747:7): [True: 0, False: 390]
  |  Branch (747:17): [True: 0, False: 0]
  |  Branch (747:30): [True: 0, False: 0]
  |  Branch (747:50): [True: 0, False: 0]
  ------------------
  748|      0|			return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  749|      0|		}
  750|    390|	}
  751|  1.23k|	for (; i < inlen; i++) {
  ------------------
  |  Branch (751:9): [True: 644, False: 587]
  ------------------
  752|    644|		if (a > (INT_MAX >> 8) || a < (INT_MIN + (1<<8))) {
  ------------------
  |  Branch (752:7): [True: 0, False: 644]
  |  Branch (752:29): [True: 0, False: 644]
  ------------------
  753|      0|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  754|      0|		}
  755|    644|		a <<= 8;
  756|    644|		if (is_negative) {
  ------------------
  |  Branch (756:7): [True: 135, False: 509]
  ------------------
  757|    135|			a |= 0xff^(*inbuf++);
  758|    509|		} else {
  759|    509|			a |= *inbuf++;
  760|    509|		}
  761|    644|	}
  762|    587|	if (is_negative) {
  ------------------
  |  Branch (762:6): [True: 197, False: 390]
  ------------------
  763|       |		/* Calculate Two's complement from previously positive number */
  764|    197|		a = (-1 * a) - 1;
  765|    197|	}
  766|    587|	*out = a;
  767|    587|	return 0;
  768|    587|}
sc_asn1_decode_object_id:
  829|  7.40k|{
  830|  7.40k|	int large_second_octet = 0;
  831|  7.40k|	unsigned int a = 0;
  832|  7.40k|	const u8 *p = inbuf;
  833|  7.40k|	int *octet;
  834|       |
  835|  7.40k|	if (inlen == 0 || inbuf == NULL || id == NULL)
  ------------------
  |  Branch (835:6): [True: 299, False: 7.10k]
  |  Branch (835:20): [True: 1, False: 7.10k]
  |  Branch (835:37): [True: 0, False: 7.10k]
  ------------------
  836|    300|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|    300|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  837|       |
  838|  7.10k|	sc_init_oid(id);
  839|  7.10k|	octet = id->value;
  840|       |
  841|       |	/* The first octet can be 0, 1 or 2 and is derived from the first byte */
  842|  7.10k|	a = MIN(*p / 40, 2);
  ------------------
  |  |   70|  7.10k|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 5.15k, False: 1.95k]
  |  |  ------------------
  ------------------
  843|  7.10k|	*octet++ = a;
  844|       |
  845|       |	/* The second octet fits here if the previous was 0 or 1 and second one is smaller than 40.
  846|       |	 * for the value 2 we can go up to 47. Otherwise the first bit needs to be set
  847|       |	 * and we continue reading further */
  848|  7.10k|	if ((*p & 0x80) == 0) {
  ------------------
  |  Branch (848:6): [True: 5.26k, False: 1.84k]
  ------------------
  849|  5.26k|		*octet++ = *p - (a * 40);
  850|  5.26k|		inlen--;
  851|  5.26k|	} else {
  852|  1.84k|		large_second_octet = 1;
  853|  1.84k|	}
  854|       |
  855|  26.8k|	while (inlen) {
  ------------------
  |  Branch (855:9): [True: 21.9k, False: 4.87k]
  ------------------
  856|  21.9k|		if (!large_second_octet)
  ------------------
  |  Branch (856:7): [True: 20.1k, False: 1.84k]
  ------------------
  857|  20.1k|			p++;
  858|       |		/* This signalizes empty most significant bits, which means
  859|       |		 * the unsigned integer encoding is not minimal */
  860|  21.9k|		if (*p == 0x80) {
  ------------------
  |  Branch (860:7): [True: 680, False: 21.3k]
  ------------------
  861|    680|			sc_init_oid(id);
  862|    680|			return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|    680|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  863|    680|		}
  864|       |		/* Use unsigned type here so we can process the whole INT range.
  865|       |		 * Values can not be negative */
  866|  21.3k|		a = *p & 0x7F;
  867|  21.3k|		inlen--;
  868|  29.8k|		while (inlen && *p & 0x80) {
  ------------------
  |  Branch (868:10): [True: 24.4k, False: 5.42k]
  |  Branch (868:19): [True: 8.77k, False: 15.6k]
  ------------------
  869|       |			/* Limit the OID values to int size and do not overflow */
  870|  8.77k|			if (a > (UINT_MAX>>7)) {
  ------------------
  |  Branch (870:8): [True: 251, False: 8.52k]
  ------------------
  871|    251|				sc_init_oid(id);
  872|    251|				return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    251|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  873|    251|			}
  874|  8.52k|			p++;
  875|  8.52k|			a <<= 7;
  876|  8.52k|			a |= *p & 0x7F;
  877|  8.52k|			inlen--;
  878|  8.52k|		}
  879|  21.0k|		if (*p & 0x80) {
  ------------------
  |  Branch (879:7): [True: 736, False: 20.3k]
  ------------------
  880|       |			/* We dropped out from previous cycle on the end of
  881|       |			 * data while still expecting continuation of value */
  882|    736|			sc_init_oid(id);
  883|    736|			return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|    736|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  884|    736|		}
  885|  20.3k|		if (large_second_octet) {
  ------------------
  |  Branch (885:7): [True: 695, False: 19.6k]
  ------------------
  886|    695|			a -= (2 * 40);
  887|    695|		}
  888|  20.3k|		if (a > INT_MAX) {
  ------------------
  |  Branch (888:7): [True: 361, False: 19.9k]
  ------------------
  889|    361|			sc_init_oid(id);
  890|    361|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    361|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  891|    361|		}
  892|  19.9k|		*octet++ = a;
  893|  19.9k|		if (octet - id->value >= SC_MAX_OBJECT_ID_OCTETS)   {
  ------------------
  |  |   46|  19.9k|#define SC_MAX_OBJECT_ID_OCTETS		16
  ------------------
  |  Branch (893:7): [True: 205, False: 19.7k]
  ------------------
  894|    205|			sc_init_oid(id);
  895|    205|			return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|    205|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  896|    205|		}
  897|  19.7k|		large_second_octet = 0;
  898|  19.7k|	}
  899|       |
  900|  4.87k|	return 0;
  901|  7.10k|}
sc_asn1_encode_object_id:
  905|  12.0k|{
  906|  12.0k|	u8 temp[SC_MAX_OBJECT_ID_OCTETS*5], *p = temp;
  907|  12.0k|	int	i;
  908|       |
  909|  12.0k|	if (!buflen || !id)
  ------------------
  |  Branch (909:6): [True: 0, False: 12.0k]
  |  Branch (909:17): [True: 0, False: 12.0k]
  ------------------
  910|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  911|       |
  912|       |	/* an OID must have at least two components */
  913|  12.0k|	if (id->value[0] == -1 || id->value[1] == -1)
  ------------------
  |  Branch (913:6): [True: 0, False: 12.0k]
  |  Branch (913:28): [True: 0, False: 12.0k]
  ------------------
  914|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  915|       |
  916|  92.5k|	for (i = 0; i < SC_MAX_OBJECT_ID_OCTETS; i++) {
  ------------------
  |  |   46|  92.5k|#define SC_MAX_OBJECT_ID_OCTETS		16
  ------------------
  |  Branch (916:14): [True: 92.5k, False: 41]
  ------------------
  917|  92.5k|		unsigned int k, shift;
  918|       |
  919|  92.5k|		if (id->value[i] == -1)
  ------------------
  |  Branch (919:7): [True: 11.9k, False: 80.5k]
  ------------------
  920|  11.9k|			break;
  921|       |
  922|  80.5k|		k = id->value[i];
  923|  80.5k|		switch (i) {
  924|  12.0k|		case 0:
  ------------------
  |  Branch (924:3): [True: 12.0k, False: 68.5k]
  ------------------
  925|  12.0k|			if (k > 2)
  ------------------
  |  Branch (925:8): [True: 10, False: 12.0k]
  ------------------
  926|     10|				return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|     10|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  927|  12.0k|			*p = k * 40;
  928|  12.0k|			break;
  929|  12.0k|		case 1:
  ------------------
  |  Branch (929:3): [True: 12.0k, False: 68.5k]
  ------------------
  930|  12.0k|			if (k > 39 && id->value[0] < 2) {
  ------------------
  |  Branch (930:8): [True: 20, False: 11.9k]
  |  Branch (930:18): [True: 20, False: 0]
  ------------------
  931|     20|				return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|     20|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  932|     20|			}
  933|       |			/* We can encode larger IDs to multiple bytes
  934|       |			 * similarly as the following IDs */
  935|  11.9k|			k += *p;
  936|       |			/* fall through */
  937|  68.5k|		default:
  ------------------
  |  Branch (937:3): [True: 56.5k, False: 24.0k]
  ------------------
  938|  68.5k|			shift = 28;
  939|   325k|			while (shift && (k >> shift) == 0)
  ------------------
  |  Branch (939:11): [True: 274k, False: 51.6k]
  |  Branch (939:20): [True: 257k, False: 16.9k]
  ------------------
  940|   257k|				shift -= 7;
  941|  85.4k|			while (shift) {
  ------------------
  |  Branch (941:11): [True: 16.9k, False: 68.5k]
  ------------------
  942|  16.9k|				*p++ = 0x80 | ((k >> shift) & 0x7f);
  943|  16.9k|				shift -= 7;
  944|  16.9k|			}
  945|  68.5k|			*p++ = k & 0x7F;
  946|  68.5k|			break;
  947|  80.5k|		}
  948|  80.5k|	}
  949|       |
  950|  11.9k|	*buflen = p - temp;
  951|       |
  952|  11.9k|	if (buf)   {
  ------------------
  |  Branch (952:6): [True: 11.9k, False: 0]
  ------------------
  953|  11.9k|		*buf = malloc(*buflen);
  954|  11.9k|		if (!*buf)
  ------------------
  |  Branch (954:7): [True: 0, False: 11.9k]
  ------------------
  955|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  956|  11.9k|		memcpy(*buf, temp, *buflen);
  957|  11.9k|	}
  958|  11.9k|	return 0;
  959|  11.9k|}
sc_asn1_put_tag:
  976|  3.87k|{
  977|  3.87k|	size_t c = 0;
  978|  3.87k|	unsigned int tag_len, ii;
  979|  3.87k|	u8 *p = out;
  980|  3.87k|	u8 tag_char[4] = {0, 0, 0, 0};
  981|       |
  982|       |	/* Check tag */
  983|  3.87k|	if (tag == 0 || tag > 0xFFFFFFFF) {
  ------------------
  |  Branch (983:6): [True: 0, False: 3.87k]
  |  Branch (983:18): [True: 0, False: 3.87k]
  ------------------
  984|       |		/* A tag of 0x00 is not valid and at most 4-byte tag names are supported. */
  985|      0|		return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  986|      0|	}
  987|  7.75k|	for (tag_len = 0; tag; tag >>= 8) {
  ------------------
  |  Branch (987:20): [True: 3.87k, False: 3.87k]
  ------------------
  988|       |		/* Note: tag char will be reversed order. */
  989|  3.87k|		tag_char[tag_len++] = tag & 0xFF;
  990|  3.87k|	}
  991|       |
  992|  3.87k|	if (tag_len > 1)   {
  ------------------
  |  Branch (992:6): [True: 0, False: 3.87k]
  ------------------
  993|      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 (993:7): [True: 0, False: 0]
  ------------------
  994|       |			/* First byte is not escape marker. */
  995|      0|			return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  996|      0|		}
  997|      0|		for (ii = 1; ii < tag_len - 1; ii++) {
  ------------------
  |  Branch (997:16): [True: 0, False: 0]
  ------------------
  998|      0|			if ((tag_char[ii] & 0x80) != 0x80) {
  ------------------
  |  Branch (998:8): [True: 0, False: 0]
  ------------------
  999|       |				/* MS bit is not 'one'. */
 1000|      0|				return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 1001|      0|			}
 1002|      0|		}
 1003|      0|		if ((tag_char[0] & 0x80) != 0x00) {
  ------------------
  |  Branch (1003:7): [True: 0, False: 0]
  ------------------
 1004|       |			/* MS bit of the last byte is not 'zero'. */
 1005|      0|			return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 1006|      0|		}
 1007|      0|	}
 1008|       |
 1009|       |	/* Calculate the number of additional bytes necessary to encode the length. */
 1010|       |	/* c+1 is the size of the length field. */
 1011|  3.87k|	if (datalen > 127) {
  ------------------
  |  Branch (1011:6): [True: 0, False: 3.87k]
  ------------------
 1012|      0|		c = 1;
 1013|      0|		while (datalen >> (c << 3))
  ------------------
  |  Branch (1013:10): [True: 0, False: 0]
  ------------------
 1014|      0|			c++;
 1015|      0|	}
 1016|  3.87k|	if (outlen == 0 || out == NULL) {
  ------------------
  |  Branch (1016:6): [True: 0, False: 3.87k]
  |  Branch (1016:21): [True: 0, False: 3.87k]
  ------------------
 1017|       |		/* Caller only asks for the length that would be written. */
 1018|      0|		return (int)(tag_len + (c + 1) + datalen);
 1019|      0|	}
 1020|       |	/* We will write the tag, so check the length. */
 1021|  3.87k|	if (outlen < tag_len + (c+1) + datalen)
  ------------------
  |  Branch (1021:6): [True: 0, False: 3.87k]
  ------------------
 1022|      0|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
 1023|  7.75k|	for (ii=0;ii<tag_len;ii++)
  ------------------
  |  Branch (1023:12): [True: 3.87k, False: 3.87k]
  ------------------
 1024|  3.87k|		*p++ = tag_char[tag_len - ii - 1];
 1025|       |
 1026|  3.87k|	if (c > 0) {
  ------------------
  |  Branch (1026:6): [True: 0, False: 3.87k]
  ------------------
 1027|      0|		*p++ = 0x80 | c;
 1028|      0|		while (c--)
  ------------------
  |  Branch (1028:10): [True: 0, False: 0]
  ------------------
 1029|      0|			*p++ = (datalen >> (c << 3)) & 0xFF;
 1030|      0|	}
 1031|  3.87k|	else {
 1032|  3.87k|		*p++ = datalen & 0x7F;
 1033|  3.87k|	}
 1034|  3.87k|	if(data && datalen > 0) {
  ------------------
  |  Branch (1034:5): [True: 3.87k, False: 0]
  |  Branch (1034:13): [True: 3.87k, False: 1]
  ------------------
 1035|  3.87k|		memcpy(p, data, datalen);
 1036|  3.87k|		p += datalen;
 1037|  3.87k|	}
 1038|  3.87k|	if (ptr != NULL)
  ------------------
  |  Branch (1038:6): [True: 3.87k, False: 0]
  ------------------
 1039|  3.87k|		*ptr = p;
 1040|  3.87k|	return 0;
 1041|  3.87k|}
sc_asn1_decode:
 1814|  4.83k|{
 1815|  4.83k|	return asn1_decode(ctx, asn1, in, len, newp, len_left, 0, 0);
 1816|  4.83k|}
sc_asn1_decode_choice:
 1820|    903|{
 1821|    903|	return asn1_decode(ctx, asn1, in, len, newp, len_left, 1, 0);
 1822|    903|}
sc_asn1_encode:
 2082|  5.51k|{
 2083|  5.51k|	return asn1_encode(ctx, asn1, ptr, size, 0);
 2084|  5.51k|}
_sc_asn1_encode:
 2088|  11.4k|{
 2089|  11.4k|	return asn1_encode(ctx, asn1, ptr, size, depth);
 2090|  11.4k|}
sc_der_copy:
 2102|  3.97k|{
 2103|  3.97k|	if (!dst || !src)
  ------------------
  |  Branch (2103:6): [True: 0, False: 3.97k]
  |  Branch (2103:14): [True: 0, False: 3.97k]
  ------------------
 2104|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 2105|  3.97k|	memset(dst, 0, sizeof(*dst));
 2106|  3.97k|	if (src->len) {
  ------------------
  |  Branch (2106:6): [True: 3.97k, False: 0]
  ------------------
 2107|  3.97k|		if (!src->value)
  ------------------
  |  Branch (2107:7): [True: 0, False: 3.97k]
  ------------------
 2108|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 2109|  3.97k|		dst->value = malloc(src->len);
 2110|  3.97k|		if (!dst->value)
  ------------------
  |  Branch (2110:7): [True: 0, False: 3.97k]
  ------------------
 2111|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2112|  3.97k|		dst->len = src->len;
 2113|  3.97k|		memcpy(dst->value, src->value, src->len);
 2114|  3.97k|	}
 2115|  3.97k|	return SC_SUCCESS;
  ------------------
  |  |   28|  3.97k|#define SC_SUCCESS				0
  ------------------
 2116|  3.97k|}
sc_encode_oid:
 2121|  11.4k|{
 2122|  11.4k|	static const struct sc_asn1_entry c_asn1_object_id[2] = {
 2123|  11.4k|		{ "oid", SC_ASN1_OBJECT, SC_ASN1_TAG_OBJECT, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  159|  11.4k|#define SC_ASN1_OBJECT                  6
  ------------------
              		{ "oid", SC_ASN1_OBJECT, SC_ASN1_TAG_OBJECT, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  200|  11.4k|#define SC_ASN1_TAG_OBJECT		6
  ------------------
              		{ "oid", SC_ASN1_OBJECT, SC_ASN1_TAG_OBJECT, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  149|  11.4k|#define SC_ASN1_ALLOC			0x00000004
  ------------------
 2124|  11.4k|		{ NULL, 0, 0, 0, NULL, NULL }
 2125|  11.4k|	};
 2126|  11.4k|	struct sc_asn1_entry asn1_object_id[2];
 2127|  11.4k|	int rv;
 2128|       |
 2129|  11.4k|	sc_copy_asn1_entry(c_asn1_object_id, asn1_object_id);
 2130|  11.4k|	sc_format_asn1_entry(asn1_object_id + 0, id, NULL, 1);
 2131|       |
 2132|  11.4k|	rv = _sc_asn1_encode(ctx, asn1_object_id, out, size, 1);
 2133|  11.4k|	LOG_TEST_RET(ctx, rv, "Cannot encode object ID");
  ------------------
  |  |  174|  11.4k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  11.4k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  11.4k|	int _ret = (r); \
  |  |  |  |  168|  11.4k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 11.4k]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#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.4k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 11.4k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2134|       |
 2135|  11.4k|	return SC_SUCCESS;
  ------------------
  |  |   28|  11.4k|#define SC_SUCCESS				0
  ------------------
 2136|  11.4k|}
asn1.c:decode_bit_string:
  574|    306|{
  575|    306|	const u8 *in = inbuf;
  576|    306|	u8 *out = (u8 *) outbuf;
  577|    306|	int i, count = 0;
  578|    306|	int zero_bits;
  579|    306|	size_t octets_left;
  580|       |
  581|    306|	if (inlen < 1)
  ------------------
  |  Branch (581:6): [True: 1, False: 305]
  ------------------
  582|      1|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      1|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  583|       |
  584|       |	/* The formatting is only enforced by SHALL keyword so we should accept
  585|       |	 * by default also non-strict values. */
  586|    305|	if (strict) {
  ------------------
  |  Branch (586:6): [True: 0, False: 305]
  ------------------
  587|       |		/* 8.6.2.3 If the bitstring is empty, there shall be no
  588|       |		 * subsequent octets,and the initial octet shall be zero. */
  589|      0|		if (inlen == 1 && *in != 0)
  ------------------
  |  Branch (589:7): [True: 0, False: 0]
  |  Branch (589:21): [True: 0, False: 0]
  ------------------
  590|      0|			return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  591|       |		/* ITU-T Rec. X.690 8.6.2.2: The number shall be in the range zero to seven. */
  592|      0|		if ((*in & ~0x07) != 0)
  ------------------
  |  Branch (592:7): [True: 0, False: 0]
  ------------------
  593|      0|			return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  594|      0|	}
  595|       |
  596|    305|	memset(outbuf, 0, outlen);
  597|    305|	zero_bits = *in & 0x07;
  598|    305|	in++;
  599|    305|	octets_left = inlen - 1;
  600|    305|	if (outlen < octets_left)
  ------------------
  |  Branch (600:6): [True: 1, False: 304]
  ------------------
  601|      1|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      1|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  602|       |
  603|    642|	while (octets_left) {
  ------------------
  |  Branch (603:9): [True: 339, False: 303]
  ------------------
  604|       |		/* 1st octet of input:  ABCDEFGH, where A is the MSB */
  605|       |		/* 1st octet of output: HGFEDCBA, where A is the LSB */
  606|       |		/* first bit in bit string is the LSB in first resulting octet */
  607|    339|		int bits_to_go;
  608|       |
  609|    339|		*out = 0;
  610|    339|		if (octets_left == 1 && zero_bits > 0) {
  ------------------
  |  Branch (610:7): [True: 297, False: 42]
  |  Branch (610:27): [True: 225, False: 72]
  ------------------
  611|    225|			bits_to_go = 8 - zero_bits;
  612|       |			/* Verify the padding is zero bits */
  613|    225|			if (*in & (1 << (zero_bits-1))) {
  ------------------
  |  Branch (613:8): [True: 1, False: 224]
  ------------------
  614|      1|				return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      1|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  615|      1|			}
  616|    225|		} else
  617|    114|			bits_to_go = 8;
  618|    338|		if (invert)
  ------------------
  |  Branch (618:7): [True: 338, False: 0]
  ------------------
  619|  2.14k|			for (i = 0; i < bits_to_go; i++) {
  ------------------
  |  Branch (619:16): [True: 1.80k, False: 338]
  ------------------
  620|  1.80k|				*out |= ((*in >> (7 - i)) & 1) << i;
  621|  1.80k|			}
  622|      0|		else {
  623|      0|			*out = *in;
  624|      0|		}
  625|    338|		out++;
  626|    338|		in++;
  627|    338|		octets_left--;
  628|    338|		count++;
  629|    338|	}
  630|    303|	return (count * 8) - zero_bits;
  631|    304|}
asn1.c:asn1_write_element:
 1051|  36.0k|{
 1052|  36.0k|	unsigned char t;
 1053|  36.0k|	unsigned char *buf, *p;
 1054|  36.0k|	int c = 0;
 1055|  36.0k|	unsigned short_tag;
 1056|  36.0k|	unsigned char tag_char[3] = {0, 0, 0};
 1057|  36.0k|	size_t tag_len, ii;
 1058|       |
 1059|  36.0k|	short_tag = tag & SC_ASN1_TAG_MASK;
  ------------------
  |  |  144|  36.0k|#define SC_ASN1_TAG_MASK		0x00FFFFFF
  ------------------
 1060|  73.1k|	for (tag_len = 0; short_tag >> (8 * tag_len); tag_len++)
  ------------------
  |  Branch (1060:20): [True: 37.0k, False: 36.0k]
  ------------------
 1061|  37.0k|		tag_char[tag_len] = (short_tag >> (8 * tag_len)) & 0xFF;
 1062|  36.0k|	if (!tag_len)
  ------------------
  |  Branch (1062:6): [True: 1.16k, False: 34.9k]
  ------------------
 1063|  1.16k|		tag_len = 1;
 1064|       |
 1065|  36.0k|	if (tag_len > 1)   {
  ------------------
  |  Branch (1065:6): [True: 2.15k, False: 33.9k]
  ------------------
 1066|  2.15k|		if ((tag_char[tag_len - 1] & SC_ASN1_TAG_PRIMITIVE) != SC_ASN1_TAG_ESCAPE_MARKER)
  ------------------
  |  |  191|  2.15k|#define SC_ASN1_TAG_PRIMITIVE		0x1F
  ------------------
              		if ((tag_char[tag_len - 1] & SC_ASN1_TAG_PRIMITIVE) != SC_ASN1_TAG_ESCAPE_MARKER)
  ------------------
  |  |  222|  2.15k|#define SC_ASN1_TAG_ESCAPE_MARKER	31
  ------------------
  |  Branch (1066:7): [True: 0, False: 2.15k]
  ------------------
 1067|      0|			SC_TEST_RET(ctx, SC_LOG_DEBUG_ASN1, SC_ERROR_INVALID_DATA, "First byte of the long tag is not 'escape marker'");
  ------------------
  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  167|      0|	int _ret = (r); \
  |  |  168|      0|	if (_ret < 0) { \
  |  |  ------------------
  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  171|      0|		return _ret; \
  |  |  172|      0|	} \
  |  |  173|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1068|       |
 1069|  2.15k|		for (ii = 1; ii < tag_len - 1; ii++)
  ------------------
  |  Branch (1069:16): [True: 0, False: 2.15k]
  ------------------
 1070|      0|			if (!(tag_char[ii] & 0x80))
  ------------------
  |  Branch (1070:8): [True: 0, False: 0]
  ------------------
 1071|      0|				SC_TEST_RET(ctx, SC_LOG_DEBUG_ASN1, SC_ERROR_INVALID_DATA, "MS bit expected to be 'one'");
  ------------------
  |  |  166|  2.15k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  167|      0|	int _ret = (r); \
  |  |  168|      0|	if (_ret < 0) { \
  |  |  ------------------
  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  171|      0|		return _ret; \
  |  |  172|      0|	} \
  |  |  173|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1072|       |
 1073|  2.15k|		if (tag_char[0] & 0x80)
  ------------------
  |  Branch (1073:7): [True: 0, False: 2.15k]
  ------------------
 1074|      0|			SC_TEST_RET(ctx, SC_LOG_DEBUG_ASN1, SC_ERROR_INVALID_DATA, "MS bit of the last byte expected to be 'zero'");
  ------------------
  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  167|      0|	int _ret = (r); \
  |  |  168|      0|	if (_ret < 0) { \
  |  |  ------------------
  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  171|      0|		return _ret; \
  |  |  172|      0|	} \
  |  |  173|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1075|  2.15k|	}
 1076|       |
 1077|  36.0k|	t = tag_char[tag_len - 1] & 0x1F;
 1078|       |
 1079|  36.0k|	switch (tag & SC_ASN1_CLASS_MASK) {
  ------------------
  |  |  136|  36.0k|#define SC_ASN1_CLASS_MASK		0xC0000000
  ------------------
  |  Branch (1079:10): [True: 36.0k, False: 0]
  ------------------
 1080|  24.6k|	case SC_ASN1_UNI:
  ------------------
  |  |  137|  24.6k|#define SC_ASN1_UNI			0x00000000 /* Universal */
  ------------------
  |  Branch (1080:2): [True: 24.6k, False: 11.4k]
  ------------------
 1081|  24.6k|		break;
 1082|  6.22k|	case SC_ASN1_APP:
  ------------------
  |  |  138|  6.22k|#define SC_ASN1_APP			0x40000000 /* Application */
  ------------------
  |  Branch (1082:2): [True: 6.22k, False: 29.8k]
  ------------------
 1083|  6.22k|		t |= SC_ASN1_TAG_APPLICATION;
  ------------------
  |  |  186|  6.22k|#define SC_ASN1_TAG_APPLICATION		0x40
  ------------------
 1084|  6.22k|		break;
 1085|  5.21k|	case SC_ASN1_CTX:
  ------------------
  |  |  139|  5.21k|#define SC_ASN1_CTX			0x80000000 /* Context */
  ------------------
  |  Branch (1085:2): [True: 5.21k, False: 30.8k]
  ------------------
 1086|  5.21k|		t |= SC_ASN1_TAG_CONTEXT;
  ------------------
  |  |  187|  5.21k|#define SC_ASN1_TAG_CONTEXT		0x80
  ------------------
 1087|  5.21k|		break;
 1088|      0|	case SC_ASN1_PRV:
  ------------------
  |  |  140|      0|#define SC_ASN1_PRV			0xC0000000 /* Private */
  ------------------
  |  Branch (1088:2): [True: 0, False: 36.0k]
  ------------------
 1089|      0|		t |= SC_ASN1_TAG_PRIVATE;
  ------------------
  |  |  188|      0|#define SC_ASN1_TAG_PRIVATE		0xC0
  ------------------
 1090|      0|		break;
 1091|  36.0k|	}
 1092|  36.0k|	if (tag & SC_ASN1_CONS)
  ------------------
  |  |  141|  36.0k|#define SC_ASN1_CONS			0x20000000
  ------------------
  |  Branch (1092:6): [True: 9.72k, False: 26.3k]
  ------------------
 1093|  9.72k|		t |= SC_ASN1_TAG_CONSTRUCTED;
  ------------------
  |  |  190|  9.72k|#define SC_ASN1_TAG_CONSTRUCTED		0x20
  ------------------
 1094|  36.0k|	if (datalen > 127) {
  ------------------
  |  Branch (1094:6): [True: 848, False: 35.2k]
  ------------------
 1095|    848|		c = 1;
 1096|    966|		while (datalen >> (c << 3))
  ------------------
  |  Branch (1096:10): [True: 118, False: 848]
  ------------------
 1097|    118|			c++;
 1098|    848|	}
 1099|       |
 1100|  36.0k|	*outlen = tag_len + 1 + c + datalen;
 1101|  36.0k|	buf = malloc(*outlen);
 1102|  36.0k|	if (buf == NULL)
  ------------------
  |  Branch (1102:6): [True: 0, False: 36.0k]
  ------------------
 1103|      0|		SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_ASN1, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      0|	int _ret = r; \
  |  |  155|      0|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  ------------------
  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      0|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|      0|	return _ret; \
  |  |  163|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1104|       |
 1105|  36.0k|	*out = p = buf;
 1106|  36.0k|	*p++ = t;
 1107|  38.2k|	for (ii=1;ii<tag_len;ii++)
  ------------------
  |  Branch (1107:12): [True: 2.15k, False: 36.0k]
  ------------------
 1108|  2.15k|		*p++ = tag_char[tag_len - ii - 1];
 1109|       |
 1110|  36.0k|	if (c) {
  ------------------
  |  Branch (1110:6): [True: 848, False: 35.2k]
  ------------------
 1111|    848|		*p++ = 0x80 | c;
 1112|  1.81k|		while (c--)
  ------------------
  |  Branch (1112:10): [True: 966, False: 848]
  ------------------
 1113|    966|			*p++ = (datalen >> (c << 3)) & 0xFF;
 1114|    848|	}
 1115|  35.2k|	else   {
 1116|  35.2k|		*p++ = datalen & 0x7F;
 1117|  35.2k|	}
 1118|  36.0k|	if (datalen && data) {
  ------------------
  |  Branch (1118:6): [True: 35.8k, False: 176]
  |  Branch (1118:17): [True: 35.8k, False: 0]
  ------------------
 1119|  35.8k|		memcpy(p, data, datalen);
 1120|  35.8k|	}
 1121|       |
 1122|  36.0k|	return SC_SUCCESS;
  ------------------
  |  |   28|  36.0k|#define SC_SUCCESS				0
  ------------------
 1123|  36.0k|}
asn1.c:asn1_decode:
 1723|  8.18k|{
 1724|  8.18k|	int r, idx = 0;
 1725|  8.18k|	const u8 *p = in, *obj;
 1726|  8.18k|	struct sc_asn1_entry *entry = asn1;
 1727|  8.18k|	size_t left = len, objlen;
 1728|       |
 1729|  8.18k|	sc_debug(ctx, SC_LOG_DEBUG_ASN1, "%*.*s""called, left=%zu, depth %d%s",
  ------------------
  |  |   70|  16.3k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  |  Branch (70:115): [True: 1.03k, False: 7.14k]
  |  |  ------------------
  ------------------
 1730|  8.18k|			depth, depth, "", left, depth, choice ? ", choice" : "");
 1731|       |
 1732|  8.18k|	if (!p)
  ------------------
  |  Branch (1732:6): [True: 0, False: 8.18k]
  ------------------
 1733|      0|		return SC_ERROR_ASN1_OBJECT_NOT_FOUND;
  ------------------
  |  |   83|      0|#define SC_ERROR_ASN1_OBJECT_NOT_FOUND		-1402
  ------------------
 1734|  8.18k|	if (left < 2) {
  ------------------
  |  Branch (1734:6): [True: 664, False: 7.52k]
  ------------------
 1735|  1.48k|		while (asn1->name && (asn1->flags & SC_ASN1_OPTIONAL))
  ------------------
  |  |  148|  1.18k|#define SC_ASN1_OPTIONAL		0x00000002
  ------------------
  |  Branch (1735:10): [True: 1.18k, False: 302]
  |  Branch (1735:24): [True: 825, False: 362]
  ------------------
 1736|    825|			asn1++;
 1737|       |		/* If all elements were optional, there's nothing
 1738|       |		 * to complain about */
 1739|    664|		if (asn1->name == NULL)
  ------------------
  |  Branch (1739:7): [True: 302, False: 362]
  ------------------
 1740|    302|			return 0;
 1741|    362|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "End of ASN.1 stream, "
  ------------------
  |  |   70|    362|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1742|    362|			      "non-optional field \"%s\" not found\n",
 1743|    362|			      asn1->name);
 1744|    362|		return SC_ERROR_ASN1_OBJECT_NOT_FOUND;
  ------------------
  |  |   83|    362|#define SC_ERROR_ASN1_OBJECT_NOT_FOUND		-1402
  ------------------
 1745|    664|	}
 1746|  7.52k|	if (p[0] == 0 || p[0] == 0xFF || len == 0)
  ------------------
  |  Branch (1746:6): [True: 639, False: 6.88k]
  |  Branch (1746:19): [True: 97, False: 6.78k]
  |  Branch (1746:35): [True: 0, False: 6.78k]
  ------------------
 1747|    736|		return SC_ERROR_ASN1_END_OF_CONTENTS;
  ------------------
  |  |   84|    736|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
 1748|       |
 1749|  24.0k|	for (idx = 0; asn1[idx].name != NULL; idx++) {
  ------------------
  |  Branch (1749:16): [True: 19.5k, False: 4.52k]
  ------------------
 1750|  19.5k|		entry = &asn1[idx];
 1751|       |
 1752|  19.5k|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "Looking for '%s', tag 0x%x%s%s\n",
  ------------------
  |  |   70|  19.5k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               #define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  | 1753|  19.5k|			entry->name, entry->tag, choice? ", CHOICE" : "",
  |  |  |  | 1754|  19.5k|			(entry->flags & SC_ASN1_OPTIONAL)? ", OPTIONAL": "");
  |  |  |  |  ------------------
  |  |  |  |  |  |  148|  19.5k|#define SC_ASN1_OPTIONAL		0x00000002
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1753|  19.5k|			entry->name, entry->tag, choice? ", CHOICE" : "",
 1754|  19.5k|			(entry->flags & SC_ASN1_OPTIONAL)? ", OPTIONAL": "");
 1755|       |
 1756|       |		/* Special case CHOICE has no tag */
 1757|  19.5k|		if (entry->type == SC_ASN1_CHOICE) {
  ------------------
  |  |  170|  19.5k|#define SC_ASN1_CHOICE			130
  ------------------
  |  Branch (1757:7): [True: 136, False: 19.3k]
  ------------------
 1758|    136|			r = asn1_decode(ctx,
 1759|    136|				(struct sc_asn1_entry *) entry->parm,
 1760|    136|				p, left, &p, &left, 1, depth + 1);
 1761|       |			/* When the inner call fails it returns before writing
 1762|       |			 * back to *newp and *len_left, so the caller's p/left are
 1763|       |			 * unchanged.  Swallowing the error for an optional
 1764|       |			 * CHOICE is therefore safe: the next field will be
 1765|       |			 * attempted at the same position. */
 1766|    136|			if (r >= 0 || (entry->flags & SC_ASN1_OPTIONAL))
  ------------------
  |  |  148|     34|#define SC_ASN1_OPTIONAL		0x00000002
  ------------------
  |  Branch (1766:8): [True: 102, False: 34]
  |  Branch (1766:18): [True: 10, False: 24]
  ------------------
 1767|    112|				r = 0;
 1768|    136|			goto decode_ok;
 1769|    136|		}
 1770|       |
 1771|  19.3k|		obj = sc_asn1_skip_tag(ctx, &p, &left, entry->tag, &objlen);
 1772|  19.3k|		if (obj == NULL) {
  ------------------
  |  Branch (1772:7): [True: 13.6k, False: 5.74k]
  ------------------
 1773|  13.6k|			sc_debug(ctx, SC_LOG_DEBUG_ASN1, "'%s' not present\n", entry->name);
  ------------------
  |  |   70|  13.6k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1774|  13.6k|			if (choice)
  ------------------
  |  Branch (1774:8): [True: 3.02k, False: 10.6k]
  ------------------
 1775|  3.02k|				continue;
 1776|  10.6k|			if (entry->flags & SC_ASN1_OPTIONAL)
  ------------------
  |  |  148|  10.6k|#define SC_ASN1_OPTIONAL		0x00000002
  ------------------
  |  Branch (1776:8): [True: 9.45k, False: 1.17k]
  ------------------
 1777|  9.45k|				continue;
 1778|  1.17k|			sc_debug(ctx, SC_LOG_DEBUG_ASN1, "mandatory ASN.1 object '%s' not found\n", entry->name);
  ------------------
  |  |   70|  1.17k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1779|  1.17k|			if (left) {
  ------------------
  |  Branch (1779:8): [True: 1.10k, False: 66]
  ------------------
 1780|  1.10k|				u8 line[128], *linep = line;
 1781|  1.10k|				size_t i;
 1782|       |
 1783|  1.10k|				line[0] = 0;
 1784|  9.81k|				for (i = 0; i < 10 && i < left; i++) {
  ------------------
  |  Branch (1784:17): [True: 9.27k, False: 536]
  |  Branch (1784:27): [True: 8.70k, False: 570]
  ------------------
 1785|  8.70k|					sprintf((char *) linep, "%02X ", p[i]);
 1786|  8.70k|					linep += 3;
 1787|  8.70k|				}
 1788|  1.10k|				sc_debug(ctx, SC_LOG_DEBUG_ASN1, "next tag: %s\n", line);
  ------------------
  |  |   70|  1.10k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1789|  1.10k|			}
 1790|  1.17k|			sc_free_entry(asn1);
 1791|  1.17k|			SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_ASN1, SC_ERROR_ASN1_OBJECT_NOT_FOUND);
  ------------------
  |  |  153|  1.17k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  1.17k|	int _ret = r; \
  |  |  155|  1.17k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 1.17k, False: 0]
  |  |  ------------------
  |  |  156|  1.17k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|  1.17k|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 1.17k, False: 0]
  |  |  ------------------
  |  |  157|  1.17k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|  1.17k|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|  1.17k|	return _ret; \
  |  |  163|  1.17k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1792|  1.17k|		}
 1793|  5.74k|		r = asn1_decode_entry(ctx, entry, obj, objlen, depth);
 1794|       |
 1795|  5.87k|decode_ok:
 1796|  5.87k|		if (r)
  ------------------
  |  Branch (1796:7): [True: 413, False: 5.46k]
  ------------------
 1797|    413|			return r;
 1798|  5.46k|		if (choice)
  ------------------
  |  Branch (1798:7): [True: 680, False: 4.78k]
  ------------------
 1799|    680|			break;
 1800|  5.46k| 	}
 1801|  5.20k| 	if (choice && asn1[idx].name == NULL) /* No match */
  ------------------
  |  Branch (1801:7): [True: 744, False: 4.45k]
  |  Branch (1801:17): [True: 64, False: 680]
  ------------------
 1802|     64|		SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_ASN1, SC_ERROR_ASN1_OBJECT_NOT_FOUND);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1803|  5.13k| 	if (newp != NULL)
  ------------------
  |  Branch (1803:7): [True: 943, False: 4.19k]
  ------------------
 1804|    943|		*newp = p;
 1805|  5.13k| 	if (len_left != NULL)
  ------------------
  |  Branch (1805:7): [True: 943, False: 4.19k]
  ------------------
 1806|    943|		*len_left = left;
 1807|  5.13k|	if (choice)
  ------------------
  |  Branch (1807:6): [True: 680, False: 4.45k]
  ------------------
 1808|    680|		SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_ASN1, idx);
  ------------------
  |  |  153|    680|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    680|	int _ret = r; \
  |  |  155|    680|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 244, False: 436]
  |  |  ------------------
  |  |  156|    244|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 244]
  |  |  ------------------
  |  |  157|    244|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    436|	} else { \
  |  |  159|    436|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|    436|			"returning with: %d\n", _ret); \
  |  |  161|    436|	} \
  |  |  162|    680|	return _ret; \
  |  |  163|    680|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1809|  4.45k|	SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_ASN1, 0);
  ------------------
  |  |  153|  4.45k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  4.45k|	int _ret = r; \
  |  |  155|  4.45k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 4.45k, False: 0]
  |  |  ------------------
  |  |  156|  4.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: 4.45k]
  |  |  ------------------
  |  |  157|  4.45k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|  4.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|  4.45k|	return _ret; \
  |  |  163|  4.45k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1810|  4.45k|}
asn1.c:sc_free_entry:
 1688|  5.47k|static void sc_free_entry(struct sc_asn1_entry *asn1) {
 1689|  5.47k|	int idx = 0;
 1690|  5.47k|	struct sc_asn1_entry *entry = asn1;
 1691|       |
 1692|  5.47k|	if (!asn1)
  ------------------
  |  Branch (1692:6): [True: 116, False: 5.35k]
  ------------------
 1693|    116|		return;
 1694|       |
 1695|  26.3k|	for (idx = 0; asn1[idx].name != NULL; idx++) {
  ------------------
  |  Branch (1695:16): [True: 20.9k, False: 5.35k]
  ------------------
 1696|  20.9k|		entry = &asn1[idx];
 1697|  20.9k|		switch (entry->type) {
 1698|  1.62k|		case SC_ASN1_CHOICE:
  ------------------
  |  |  170|  1.62k|#define SC_ASN1_CHOICE			130
  ------------------
  |  Branch (1698:3): [True: 1.62k, False: 19.3k]
  ------------------
 1699|  4.29k|		case SC_ASN1_STRUCT:
  ------------------
  |  |  169|  4.29k|#define SC_ASN1_STRUCT			129
  ------------------
  |  Branch (1699:3): [True: 2.67k, False: 18.2k]
  ------------------
 1700|  4.29k|			sc_free_entry((struct sc_asn1_entry *) entry->parm);
 1701|  4.29k|			break;
 1702|  3.36k|		case SC_ASN1_OCTET_STRING:
  ------------------
  |  |  157|  3.36k|#define SC_ASN1_OCTET_STRING            4
  ------------------
  |  Branch (1702:3): [True: 3.36k, False: 17.6k]
  ------------------
 1703|  3.36k|		case SC_ASN1_BIT_STRING_NI:
  ------------------
  |  |  156|  3.36k|#define SC_ASN1_BIT_STRING_NI           128
  ------------------
  |  Branch (1703:3): [True: 0, False: 20.9k]
  ------------------
 1704|  3.37k|		case SC_ASN1_BIT_STRING:
  ------------------
  |  |  155|  3.37k|#define SC_ASN1_BIT_STRING              3
  ------------------
  |  Branch (1704:3): [True: 6, False: 20.9k]
  ------------------
 1705|  3.47k|		case SC_ASN1_GENERALIZEDTIME:
  ------------------
  |  |  166|  3.47k|#define SC_ASN1_GENERALIZEDTIME         24
  ------------------
  |  Branch (1705:3): [True: 101, False: 20.8k]
  ------------------
 1706|  3.63k|		case SC_ASN1_PRINTABLESTRING:
  ------------------
  |  |  164|  3.63k|#define SC_ASN1_PRINTABLESTRING         19
  ------------------
  |  Branch (1706:3): [True: 162, False: 20.8k]
  ------------------
 1707|  4.54k|		case SC_ASN1_UTF8STRING:
  ------------------
  |  |  161|  4.54k|#define SC_ASN1_UTF8STRING              12
  ------------------
  |  Branch (1707:3): [True: 904, False: 20.0k]
  ------------------
 1708|  4.54k|			if ((entry->flags & SC_ASN1_ALLOC) && (entry->flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  149|  4.54k|#define SC_ASN1_ALLOC			0x00000004
  ------------------
              			if ((entry->flags & SC_ASN1_ALLOC) && (entry->flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  147|    267|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (1708:8): [True: 267, False: 4.27k]
  |  Branch (1708:42): [True: 0, False: 267]
  ------------------
 1709|      0|				u8 **buf = (u8 **)entry->parm;
 1710|      0|				free(*buf);
 1711|      0|				*buf = NULL;
 1712|      0|			}
 1713|  4.54k|			break;
 1714|  12.1k|		default:
  ------------------
  |  Branch (1714:3): [True: 12.1k, False: 8.84k]
  ------------------
 1715|  12.1k|			break;
 1716|  20.9k|		}
 1717|  20.9k|	}
 1718|  5.35k|}
asn1.c:asn1_decode_entry:
 1486|  5.74k|{
 1487|  5.74k|	void *parm = entry->parm;
 1488|  5.74k|	int (*callback_func)(sc_context_t *nctx, void *arg, const u8 *nobj,
 1489|  5.74k|			     size_t nobjlen, int ndepth);
 1490|  5.74k|	size_t *len = (size_t *) entry->arg;
 1491|  5.74k|	int r = 0;
 1492|       |
 1493|  5.74k|	callback_func = parm;
 1494|       |
 1495|  5.74k|	sc_debug(ctx, SC_LOG_DEBUG_ASN1, "%*.*sdecoding '%s', raw data:%s%s\n",
  ------------------
  |  |   70|  22.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: 1.06k, False: 4.67k]
  |  |  |  Branch (70:115): [True: 1.06k, False: 4.67k]
  |  |  ------------------
  ------------------
 1496|  5.74k|		depth, depth, "", entry->name,
 1497|  5.74k|		sc_dump_hex(obj, objlen > 16  ? 16 : objlen),
 1498|  5.74k|		objlen > 16 ? "..." : "");
 1499|       |
 1500|  5.74k|	switch (entry->type) {
 1501|  1.43k|	case SC_ASN1_STRUCT:
  ------------------
  |  |  169|  1.43k|#define SC_ASN1_STRUCT			129
  ------------------
  |  Branch (1501:2): [True: 1.43k, False: 4.31k]
  ------------------
 1502|  1.43k|		if (parm != NULL)
  ------------------
  |  Branch (1502:7): [True: 1.43k, False: 1]
  ------------------
 1503|  1.43k|			r = asn1_decode(ctx, (struct sc_asn1_entry *) parm, obj,
 1504|  1.43k|				       objlen, NULL, NULL, 0, depth + 1);
 1505|  1.43k|		break;
 1506|     91|	case SC_ASN1_NULL:
  ------------------
  |  |  158|     91|#define SC_ASN1_NULL                    5
  ------------------
  |  Branch (1506:2): [True: 91, False: 5.65k]
  ------------------
 1507|     91|		break;
 1508|      0|	case SC_ASN1_BOOLEAN:
  ------------------
  |  |  153|      0|#define SC_ASN1_BOOLEAN                 1
  ------------------
  |  Branch (1508:2): [True: 0, False: 5.74k]
  ------------------
 1509|      0|		if (parm != NULL) {
  ------------------
  |  Branch (1509:7): [True: 0, False: 0]
  ------------------
 1510|      0|			if (objlen != 1) {
  ------------------
  |  Branch (1510:8): [True: 0, False: 0]
  ------------------
 1511|      0|				sc_debug(ctx, SC_LOG_DEBUG_ASN1, "invalid ASN.1 object length: %zu", objlen);
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1512|      0|				r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 1513|      0|			} else
 1514|      0|				*((int *) parm) = obj[0] ? 1 : 0;
  ------------------
  |  Branch (1514:23): [True: 0, False: 0]
  ------------------
 1515|      0|		}
 1516|      0|		break;
 1517|    607|	case SC_ASN1_INTEGER:
  ------------------
  |  |  154|    607|#define SC_ASN1_INTEGER                 2
  ------------------
  |  Branch (1517:2): [True: 607, False: 5.13k]
  ------------------
 1518|    617|	case SC_ASN1_ENUMERATED:
  ------------------
  |  |  160|    617|#define SC_ASN1_ENUMERATED              10
  ------------------
  |  Branch (1518:2): [True: 10, False: 5.73k]
  ------------------
 1519|    617|		if (parm != NULL) {
  ------------------
  |  Branch (1519:7): [True: 617, False: 0]
  ------------------
 1520|    617|			r = sc_asn1_decode_integer(obj, objlen, (int *) entry->parm, 0);
 1521|    617|			if (r == SC_SUCCESS) {
  ------------------
  |  |   28|    617|#define SC_SUCCESS				0
  ------------------
  |  Branch (1521:8): [True: 587, False: 30]
  ------------------
 1522|    587|				sc_debug(ctx, SC_LOG_DEBUG_ASN1, "%*.*sdecoding '%s' returned %d\n",
  ------------------
  |  |   70|    587|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1523|    587|						depth, depth, "", entry->name, *((int *)entry->parm));
 1524|    587|			}
 1525|    617|		}
 1526|    617|		break;
 1527|      0|	case SC_ASN1_BIT_STRING_NI:
  ------------------
  |  |  156|      0|#define SC_ASN1_BIT_STRING_NI           128
  ------------------
  |  Branch (1527:2): [True: 0, False: 5.74k]
  ------------------
 1528|      0|	case SC_ASN1_BIT_STRING:
  ------------------
  |  |  155|      0|#define SC_ASN1_BIT_STRING              3
  ------------------
  |  Branch (1528:2): [True: 0, False: 5.74k]
  ------------------
 1529|      0|		if (parm != NULL) {
  ------------------
  |  Branch (1529:7): [True: 0, False: 0]
  ------------------
 1530|      0|			int invert = entry->type == SC_ASN1_BIT_STRING ? 1 : 0;
  ------------------
  |  |  155|      0|#define SC_ASN1_BIT_STRING              3
  ------------------
  |  Branch (1530:17): [True: 0, False: 0]
  ------------------
 1531|      0|			if (len == NULL)
  ------------------
  |  Branch (1531:8): [True: 0, False: 0]
  ------------------
 1532|      0|				return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1533|      0|			if (objlen < 1) {
  ------------------
  |  Branch (1533:8): [True: 0, False: 0]
  ------------------
 1534|      0|				r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 1535|      0|				break;
 1536|      0|			}
 1537|      0|			if (entry->flags & SC_ASN1_ALLOC) {
  ------------------
  |  |  149|      0|#define SC_ASN1_ALLOC			0x00000004
  ------------------
  |  Branch (1537:8): [True: 0, False: 0]
  ------------------
 1538|      0|				u8 **buf = (u8 **) parm;
 1539|      0|				if (objlen > 1) {
  ------------------
  |  Branch (1539:9): [True: 0, False: 0]
  ------------------
 1540|      0|					*buf = malloc(objlen-1);
 1541|      0|					if (*buf == NULL) {
  ------------------
  |  Branch (1541:10): [True: 0, False: 0]
  ------------------
 1542|      0|						r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1543|      0|						break;
 1544|      0|					}
 1545|      0|				} else {
 1546|      0|					*buf = NULL;
 1547|      0|				}
 1548|      0|				*len = objlen-1;
 1549|      0|				parm = *buf;
 1550|      0|			}
 1551|      0|			r = decode_bit_string(obj, objlen, (u8 *) parm, *len, invert, 0);
 1552|      0|			if (r >= 0) {
  ------------------
  |  Branch (1552:8): [True: 0, False: 0]
  ------------------
 1553|      0|				*len = r;
 1554|      0|				r = 0;
 1555|      0|			}
 1556|      0|		}
 1557|      0|		break;
 1558|    306|	case SC_ASN1_BIT_FIELD:
  ------------------
  |  |  171|    306|#define SC_ASN1_BIT_FIELD		131	/* bit string as integer */
  ------------------
  |  Branch (1558:2): [True: 306, False: 5.43k]
  ------------------
 1559|    306|		if (parm != NULL)
  ------------------
  |  Branch (1559:7): [True: 306, False: 0]
  ------------------
 1560|    306|			r = decode_bit_field(obj, objlen, (u8 *) parm, *len, 0);
 1561|    306|		break;
 1562|  2.00k|	case SC_ASN1_OCTET_STRING:
  ------------------
  |  |  157|  2.00k|#define SC_ASN1_OCTET_STRING            4
  ------------------
  |  Branch (1562:2): [True: 2.00k, False: 3.73k]
  ------------------
 1563|  2.00k|		if (parm != NULL) {
  ------------------
  |  Branch (1563:7): [True: 1.97k, False: 35]
  ------------------
 1564|  1.97k|			size_t c;
 1565|  1.97k|			if (len == NULL)
  ------------------
  |  Branch (1565:8): [True: 0, False: 1.97k]
  ------------------
 1566|      0|				return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1567|       |
 1568|       |			/* Strip off padding zero */
 1569|  1.97k|			if ((entry->flags & SC_ASN1_UNSIGNED)
  ------------------
  |  |  150|  1.97k|#define SC_ASN1_UNSIGNED		0x00000008
  ------------------
  |  Branch (1569:8): [True: 315, False: 1.65k]
  ------------------
 1570|    315|					&& objlen > 1 && obj[0] == 0x00) {
  ------------------
  |  Branch (1570:9): [True: 273, False: 42]
  |  Branch (1570:23): [True: 250, False: 23]
  ------------------
 1571|    250|				objlen--;
 1572|    250|				obj++;
 1573|    250|			}
 1574|       |
 1575|       |			/* Allocate buffer if needed */
 1576|  1.97k|			if (entry->flags & SC_ASN1_ALLOC) {
  ------------------
  |  |  149|  1.97k|#define SC_ASN1_ALLOC			0x00000004
  ------------------
  |  Branch (1576:8): [True: 315, False: 1.65k]
  ------------------
 1577|    315|				u8 **buf = (u8 **) parm;
 1578|    315|				if (objlen > 0) {
  ------------------
  |  Branch (1578:9): [True: 275, False: 40]
  ------------------
 1579|    275|					*buf = malloc(objlen);
 1580|    275|					if (*buf == NULL) {
  ------------------
  |  Branch (1580:10): [True: 0, False: 275]
  ------------------
 1581|      0|						r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1582|      0|						break;
 1583|      0|					}
 1584|    275|				} else {
 1585|     40|					*buf = NULL;
 1586|     40|				}
 1587|    315|				c = *len = objlen;
 1588|    315|				parm = *buf;
 1589|    315|			} else
 1590|  1.65k|				c = objlen > *len ? *len : objlen;
  ------------------
  |  Branch (1590:9): [True: 120, False: 1.53k]
  ------------------
 1591|       |
 1592|  1.97k|			memcpy(parm, obj, c);
 1593|  1.97k|			*len = c;
 1594|  1.97k|		}
 1595|  2.00k|		break;
 1596|  2.00k|	case SC_ASN1_GENERALIZEDTIME:
  ------------------
  |  |  166|     10|#define SC_ASN1_GENERALIZEDTIME         24
  ------------------
  |  Branch (1596:2): [True: 10, False: 5.73k]
  ------------------
 1597|     10|		if (parm != NULL) {
  ------------------
  |  Branch (1597:7): [True: 9, False: 1]
  ------------------
 1598|      9|			size_t c;
 1599|      9|			if (len == NULL)
  ------------------
  |  Branch (1599:8): [True: 0, False: 9]
  ------------------
 1600|      0|				return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1601|      9|			if (entry->flags & SC_ASN1_ALLOC) {
  ------------------
  |  |  149|      9|#define SC_ASN1_ALLOC			0x00000004
  ------------------
  |  Branch (1601:8): [True: 0, False: 9]
  ------------------
 1602|      0|				u8 **buf = (u8 **) parm;
 1603|      0|				if (objlen > 0) {
  ------------------
  |  Branch (1603:9): [True: 0, False: 0]
  ------------------
 1604|      0|					*buf = malloc(objlen);
 1605|      0|					if (*buf == NULL) {
  ------------------
  |  Branch (1605:10): [True: 0, False: 0]
  ------------------
 1606|      0|						r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1607|      0|						break;
 1608|      0|					}
 1609|      0|				} else {
 1610|      0|					*buf = NULL;
 1611|      0|				}
 1612|      0|				c = *len = objlen;
 1613|      0|				parm = *buf;
 1614|      0|			} else
 1615|      9|				c = objlen > *len ? *len : objlen;
  ------------------
  |  Branch (1615:9): [True: 3, False: 6]
  ------------------
 1616|       |
 1617|      9|			memcpy(parm, obj, c);
 1618|      9|			*len = c;
 1619|      9|		}
 1620|     10|		break;
 1621|     35|	case SC_ASN1_OBJECT:
  ------------------
  |  |  159|     35|#define SC_ASN1_OBJECT                  6
  ------------------
  |  Branch (1621:2): [True: 35, False: 5.70k]
  ------------------
 1622|     35|		if (parm != NULL)
  ------------------
  |  Branch (1622:7): [True: 32, False: 3]
  ------------------
 1623|     32|			r = sc_asn1_decode_object_id(obj, objlen, (struct sc_object_id *) parm);
 1624|     35|		break;
 1625|      3|	case SC_ASN1_PRINTABLESTRING:
  ------------------
  |  |  164|      3|#define SC_ASN1_PRINTABLESTRING         19
  ------------------
  |  Branch (1625:2): [True: 3, False: 5.74k]
  ------------------
 1626|    404|	case SC_ASN1_UTF8STRING:
  ------------------
  |  |  161|    404|#define SC_ASN1_UTF8STRING              12
  ------------------
  |  Branch (1626:2): [True: 401, False: 5.34k]
  ------------------
 1627|    404|		if (parm != NULL) {
  ------------------
  |  Branch (1627:7): [True: 401, False: 3]
  ------------------
 1628|    401|			if (len == NULL)
  ------------------
  |  Branch (1628:8): [True: 0, False: 401]
  ------------------
 1629|      0|				return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1630|    401|			if (entry->flags & SC_ASN1_ALLOC) {
  ------------------
  |  |  149|    401|#define SC_ASN1_ALLOC			0x00000004
  ------------------
  |  Branch (1630:8): [True: 0, False: 401]
  ------------------
 1631|      0|				u8 **buf = (u8 **) parm;
 1632|      0|				*buf = malloc(objlen+1);
 1633|      0|				if (*buf == NULL) {
  ------------------
  |  Branch (1633:9): [True: 0, False: 0]
  ------------------
 1634|      0|					r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1635|      0|					break;
 1636|      0|				}
 1637|      0|				*len = objlen+1;
 1638|      0|				parm = *buf;
 1639|      0|			}
 1640|    401|			r = sc_asn1_decode_utf8string(obj, objlen, (u8 *) parm, len);
 1641|    401|			if (entry->flags & SC_ASN1_ALLOC) {
  ------------------
  |  |  149|    401|#define SC_ASN1_ALLOC			0x00000004
  ------------------
  |  Branch (1641:8): [True: 0, False: 401]
  ------------------
 1642|      0|				*len -= 1;
 1643|      0|			}
 1644|    401|		}
 1645|    404|		break;
 1646|    759|	case SC_ASN1_PATH:
  ------------------
  |  |  174|    759|#define SC_ASN1_PATH			256
  ------------------
  |  Branch (1646:2): [True: 759, False: 4.98k]
  ------------------
 1647|    759|		if (entry->parm != NULL)
  ------------------
  |  Branch (1647:7): [True: 759, False: 0]
  ------------------
 1648|    759|			r = asn1_decode_path(ctx, obj, objlen, (sc_path_t *) parm, depth);
 1649|    759|		break;
 1650|     13|	case SC_ASN1_PKCS15_ID:
  ------------------
  |  |  175|     13|#define SC_ASN1_PKCS15_ID		257
  ------------------
  |  Branch (1650:2): [True: 13, False: 5.73k]
  ------------------
 1651|     13|		if (entry->parm != NULL) {
  ------------------
  |  Branch (1651:7): [True: 13, False: 0]
  ------------------
 1652|     13|			struct sc_pkcs15_id *id = (struct sc_pkcs15_id *) parm;
 1653|     13|			size_t c = objlen > sizeof(id->value) ? sizeof(id->value) : objlen;
  ------------------
  |  Branch (1653:15): [True: 0, False: 13]
  ------------------
 1654|       |
 1655|     13|			memcpy(id->value, obj, c);
 1656|     13|			id->len = c;
 1657|     13|		}
 1658|     13|		break;
 1659|     18|	case SC_ASN1_PKCS15_OBJECT:
  ------------------
  |  |  176|     18|#define SC_ASN1_PKCS15_OBJECT		258
  ------------------
  |  Branch (1659:2): [True: 18, False: 5.72k]
  ------------------
 1660|     18|		if (entry->parm != NULL)
  ------------------
  |  Branch (1660:7): [True: 17, False: 1]
  ------------------
 1661|     17|			r = asn1_decode_p15_object(ctx, obj, objlen, (struct sc_asn1_pkcs15_object *) parm, depth);
 1662|     18|		break;
 1663|      0|	case SC_ASN1_ALGORITHM_ID:
  ------------------
  |  |  177|      0|#define SC_ASN1_ALGORITHM_ID		259
  ------------------
  |  Branch (1663:2): [True: 0, False: 5.74k]
  ------------------
 1664|      0|		if (entry->parm != NULL)
  ------------------
  |  Branch (1664:7): [True: 0, False: 0]
  ------------------
 1665|      0|			r = sc_asn1_decode_algorithm_id(ctx, obj, objlen, (struct sc_algorithm_id *) parm, depth);
 1666|      0|		break;
 1667|     51|	case SC_ASN1_SE_INFO:
  ------------------
  |  |  178|     51|#define SC_ASN1_SE_INFO			260
  ------------------
  |  Branch (1667:2): [True: 51, False: 5.69k]
  ------------------
 1668|     51|		if (entry->parm != NULL)
  ------------------
  |  Branch (1668:7): [True: 51, False: 0]
  ------------------
 1669|     51|			r = asn1_decode_se_info(ctx, obj, objlen, (sc_pkcs15_sec_env_info_t ***)entry->parm, len, depth);
 1670|     51|		break;
 1671|      0|	case SC_ASN1_CALLBACK:
  ------------------
  |  |  181|      0|#define SC_ASN1_CALLBACK		384
  ------------------
  |  Branch (1671:2): [True: 0, False: 5.74k]
  ------------------
 1672|      0|		if (entry->parm != NULL)
  ------------------
  |  Branch (1672:7): [True: 0, False: 0]
  ------------------
 1673|      0|			r = callback_func(ctx, entry->arg, obj, objlen, depth);
 1674|      0|		break;
 1675|      0|	default:
  ------------------
  |  Branch (1675:2): [True: 0, False: 5.74k]
  ------------------
 1676|      0|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "invalid ASN.1 type: %d\n", entry->type);
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1677|      0|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 1678|  5.74k|	}
 1679|  5.74k|	if (r) {
  ------------------
  |  Branch (1679:6): [True: 389, False: 5.35k]
  ------------------
 1680|    389|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "decoding of ASN.1 object '%s' failed: %s\n", entry->name,
  ------------------
  |  |   70|    389|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1681|    389|		      sc_strerror(r));
 1682|    389|		return r;
 1683|    389|	}
 1684|  5.35k|	entry->flags |= SC_ASN1_PRESENT;
  ------------------
  |  |  147|  5.35k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
 1685|  5.35k|	return 0;
 1686|  5.74k|}
asn1.c:decode_bit_field:
  687|    306|{
  688|    306|	u8		data[sizeof(unsigned int)];
  689|    306|	unsigned int	field = 0;
  690|    306|	int		i, n;
  691|       |
  692|    306|	if (outlen != sizeof(data))
  ------------------
  |  Branch (692:6): [True: 0, False: 306]
  ------------------
  693|      0|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  694|       |
  695|    306|	n = decode_bit_string(inbuf, inlen, data, sizeof(data), 1, strict);
  696|    306|	if (n < 0)
  ------------------
  |  Branch (696:6): [True: 9, False: 297]
  ------------------
  697|      9|		return n;
  698|       |
  699|    635|	for (i = 0; i < n; i += 8) {
  ------------------
  |  Branch (699:14): [True: 338, False: 297]
  ------------------
  700|    338|		field |= ((unsigned int) data[i/8] << i);
  701|    338|	}
  702|    297|	memcpy(outbuf, &field, outlen);
  703|    297|	return 0;
  704|    306|}
asn1.c:sc_asn1_decode_utf8string:
  963|    401|{
  964|    401|	if (inlen+1 > *outlen)
  ------------------
  |  Branch (964:6): [True: 1, False: 400]
  ------------------
  965|      1|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      1|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  966|    400|	*outlen = inlen+1;
  967|    400|	memcpy(out, inbuf, inlen);
  968|    400|	out[inlen] = 0;
  969|    400|	return 0;
  970|    401|}
asn1.c:asn1_decode_path:
 1145|    759|{
 1146|    759|	int idx, count, r;
 1147|    759|	struct sc_asn1_entry asn1_path_ext[3], asn1_path[5];
 1148|    759|	unsigned char path_value[SC_MAX_PATH_SIZE], aid_value[SC_MAX_AID_SIZE];
 1149|    759|	size_t path_len = sizeof(path_value), aid_len = sizeof(aid_value);
 1150|       |
 1151|    759|	memset(path, 0, sizeof(struct sc_path));
 1152|       |
 1153|    759|	sc_copy_asn1_entry(c_asn1_path_ext, asn1_path_ext);
 1154|    759|	sc_copy_asn1_entry(c_asn1_path, asn1_path);
 1155|       |
 1156|    759|	sc_format_asn1_entry(asn1_path_ext + 0, aid_value, &aid_len, 0);
 1157|    759|	sc_format_asn1_entry(asn1_path_ext + 1, path_value, &path_len, 0);
 1158|       |
 1159|    759|	sc_format_asn1_entry(asn1_path + 0, path_value, &path_len, 0);
 1160|    759|	sc_format_asn1_entry(asn1_path + 1, &idx, NULL, 0);
 1161|    759|	sc_format_asn1_entry(asn1_path + 2, &count, NULL, 0);
 1162|    759|	sc_format_asn1_entry(asn1_path + 3, asn1_path_ext, NULL, 0);
 1163|       |
 1164|    759|	r = asn1_decode(ctx, asn1_path, in, len, NULL, NULL, 0, depth + 1);
 1165|    759|	if (r)
  ------------------
  |  Branch (1165:6): [True: 114, False: 645]
  ------------------
 1166|    114|		return r;
 1167|       |
 1168|    645|	if (asn1_path[3].flags & SC_ASN1_PRESENT)   {
  ------------------
  |  |  147|    645|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (1168:6): [True: 0, False: 645]
  ------------------
 1169|       |		/* extended path present: set 'path' and 'aid' */
 1170|      0|		memcpy(path->aid.value, aid_value, aid_len);
 1171|      0|		path->aid.len = aid_len;
 1172|       |
 1173|      0|		memcpy(path->value, path_value, path_len);
 1174|      0|		path->len = path_len;
 1175|      0|	}
 1176|    645|	else if (asn1_path[0].flags & SC_ASN1_PRESENT)   {
  ------------------
  |  |  147|    645|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (1176:11): [True: 633, False: 12]
  ------------------
 1177|       |		/* path present: set 'path' */
 1178|    633|		memcpy(path->value, path_value, path_len);
 1179|    633|		path->len = path_len;
 1180|    633|	}
 1181|     12|	else   {
 1182|       |		/* failed if both 'path' and 'pathExtended' are absent */
 1183|     12|		return SC_ERROR_ASN1_OBJECT_NOT_FOUND;
  ------------------
  |  |   83|     12|#define SC_ERROR_ASN1_OBJECT_NOT_FOUND		-1402
  ------------------
 1184|     12|	}
 1185|       |
 1186|    633|	if (path->len == 2)
  ------------------
  |  Branch (1186:6): [True: 90, False: 543]
  ------------------
 1187|     90|		path->type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|     90|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
 1188|    543|	else   if (path->aid.len && path->len > 2)
  ------------------
  |  Branch (1188:13): [True: 0, False: 543]
  |  Branch (1188:30): [True: 0, False: 0]
  ------------------
 1189|      0|		path->type = SC_PATH_TYPE_FROM_CURRENT;
  ------------------
  |  |  122|      0|#define SC_PATH_TYPE_FROM_CURRENT	4
  ------------------
 1190|    543|	else
 1191|    543|		path->type = SC_PATH_TYPE_PATH;
  ------------------
  |  |  119|    543|#define SC_PATH_TYPE_PATH		2
  ------------------
 1192|       |
 1193|    633|	if ((asn1_path[1].flags & SC_ASN1_PRESENT) && (asn1_path[2].flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  147|    633|#define SC_ASN1_PRESENT			0x00000001
  ------------------
              	if ((asn1_path[1].flags & SC_ASN1_PRESENT) && (asn1_path[2].flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  147|     26|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (1193:6): [True: 26, False: 607]
  |  Branch (1193:48): [True: 5, False: 21]
  ------------------
 1194|      5|		path->index = idx;
 1195|      5|		path->count = count;
 1196|      5|	}
 1197|    628|	else {
 1198|    628|		path->index = 0;
 1199|    628|		path->count = -1;
 1200|    628|	}
 1201|       |
 1202|    633|	return SC_SUCCESS;
  ------------------
  |  |   28|    633|#define SC_SUCCESS				0
  ------------------
 1203|    645|}
asn1.c:asn1_decode_p15_object:
 1391|     17|{
 1392|     17|	struct sc_pkcs15_object *p15_obj = obj->p15_obj;
 1393|     17|	struct sc_asn1_entry asn1_c_attr[6], asn1_p15_obj[5];
 1394|     17|	struct sc_asn1_entry asn1_ac_rules[SC_PKCS15_MAX_ACCESS_RULES + 1], asn1_ac_rule[SC_PKCS15_MAX_ACCESS_RULES][3];
 1395|     17|	size_t flags_len = sizeof(p15_obj->flags);
 1396|     17|	size_t label_len = sizeof(p15_obj->label);
 1397|     17|	size_t access_mode_len = sizeof(p15_obj->access_rules[0].access_mode);
 1398|     17|	int r, ii;
 1399|       |
 1400|    153|	for (ii=0; ii<SC_PKCS15_MAX_ACCESS_RULES; ii++)
  ------------------
  |  |   42|    153|#define SC_PKCS15_MAX_ACCESS_RULES      8
  ------------------
  |  Branch (1400:13): [True: 136, False: 17]
  ------------------
 1401|    136|		sc_copy_asn1_entry(c_asn1_access_control_rule, asn1_ac_rule[ii]);
 1402|     17|	sc_copy_asn1_entry(c_asn1_access_control_rules, asn1_ac_rules);
 1403|       |
 1404|       |
 1405|     17|	sc_copy_asn1_entry(c_asn1_com_obj_attr, asn1_c_attr);
 1406|     17|	sc_copy_asn1_entry(c_asn1_p15_obj, asn1_p15_obj);
 1407|     17|	sc_format_asn1_entry(asn1_c_attr + 0, p15_obj->label, &label_len, 0);
 1408|     17|	sc_format_asn1_entry(asn1_c_attr + 1, &p15_obj->flags, &flags_len, 0);
 1409|     17|	sc_format_asn1_entry(asn1_c_attr + 2, &p15_obj->auth_id, NULL, 0);
 1410|     17|	sc_format_asn1_entry(asn1_c_attr + 3, &p15_obj->user_consent, NULL, 0);
 1411|       |
 1412|    153|	for (ii=0; ii<SC_PKCS15_MAX_ACCESS_RULES; ii++)   {
  ------------------
  |  |   42|    153|#define SC_PKCS15_MAX_ACCESS_RULES      8
  ------------------
  |  Branch (1412:13): [True: 136, False: 17]
  ------------------
 1413|    136|		sc_format_asn1_entry(asn1_ac_rule[ii] + 0, &p15_obj->access_rules[ii].access_mode, &access_mode_len, 0);
 1414|    136|		sc_format_asn1_entry(asn1_ac_rule[ii] + 1, &p15_obj->access_rules[ii].auth_id, NULL, 0);
 1415|    136|		sc_format_asn1_entry(asn1_ac_rules + ii, asn1_ac_rule[ii], NULL, 0);
 1416|    136|	}
 1417|     17|	sc_format_asn1_entry(asn1_c_attr + 4, asn1_ac_rules, NULL, 0);
 1418|       |
 1419|     17|	sc_format_asn1_entry(asn1_p15_obj + 0, asn1_c_attr, NULL, 0);
 1420|     17|	sc_format_asn1_entry(asn1_p15_obj + 1, obj->asn1_class_attr, NULL, 0);
 1421|     17|	sc_format_asn1_entry(asn1_p15_obj + 2, obj->asn1_subclass_attr, NULL, 0);
 1422|     17|	sc_format_asn1_entry(asn1_p15_obj + 3, obj->asn1_type_attr, NULL, 0);
 1423|       |
 1424|     17|	r = asn1_decode(ctx, asn1_p15_obj, in, len, NULL, NULL, 0, depth + 1);
 1425|     17|	return r;
 1426|     17|}
asn1.c:asn1_decode_se_info:
 1239|     51|{
 1240|     51|	struct sc_pkcs15_sec_env_info **ses;
 1241|     51|	const unsigned char *ptr = obj;
 1242|     51|	size_t idx, ptrlen = objlen;
 1243|     51|	int ret;
 1244|       |
 1245|     51|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     51|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1246|       |
 1247|     51|	ses = calloc(SC_MAX_SE_NUM, sizeof(sc_pkcs15_sec_env_info_t *));
  ------------------
  |  |   51|     51|#define SC_MAX_SE_NUM			8
  ------------------
 1248|     51|	if (ses == NULL) {
  ------------------
  |  Branch (1248:6): [True: 0, False: 51]
  ------------------
 1249|      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]
  |  |  ------------------
  ------------------
 1250|      0|	}
 1251|       |
 1252|    150|	for (idx=0; idx < SC_MAX_SE_NUM && ptrlen; )   {
  ------------------
  |  |   51|    300|#define SC_MAX_SE_NUM			8
  ------------------
  |  Branch (1252:14): [True: 150, False: 0]
  |  Branch (1252:37): [True: 108, False: 42]
  ------------------
 1253|    108|		struct sc_asn1_entry asn1_se[2];
 1254|    108|		struct sc_asn1_entry asn1_se_info[4];
 1255|    108|		struct sc_pkcs15_sec_env_info si;
 1256|       |
 1257|    108|		sc_copy_asn1_entry(c_asn1_se, asn1_se);
 1258|    108|		sc_copy_asn1_entry(c_asn1_se_info, asn1_se_info);
 1259|       |
 1260|    108|		si.aid.len = sizeof(si.aid.value);
 1261|    108|		sc_format_asn1_entry(asn1_se_info + 0, &si.se, NULL, 0);
 1262|    108|		sc_format_asn1_entry(asn1_se_info + 1, &si.owner, NULL, 0);
 1263|    108|		sc_format_asn1_entry(asn1_se_info + 2, &si.aid.value, &si.aid.len, 0);
 1264|    108|		sc_format_asn1_entry(asn1_se + 0, asn1_se_info, NULL, 0);
 1265|       |
 1266|    108|		ret = asn1_decode(ctx, asn1_se, ptr, ptrlen, &ptr, &ptrlen, 0, depth+1);
 1267|    108|		if (ret != SC_SUCCESS)
  ------------------
  |  |   28|    108|#define SC_SUCCESS				0
  ------------------
  |  Branch (1267:7): [True: 9, False: 99]
  ------------------
 1268|      9|			goto err;
 1269|     99|		if (!(asn1_se_info[1].flags & SC_ASN1_PRESENT))
  ------------------
  |  |  147|     99|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (1269:7): [True: 84, False: 15]
  ------------------
 1270|     84|			sc_init_oid(&si.owner);
 1271|       |
 1272|     99|		ses[idx] = calloc(1, sizeof(sc_pkcs15_sec_env_info_t));
 1273|     99|		if (ses[idx] == NULL) {
  ------------------
  |  Branch (1273:7): [True: 0, False: 99]
  ------------------
 1274|      0|			ret = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1275|      0|			goto err;
 1276|      0|		}
 1277|       |
 1278|     99|		memcpy(ses[idx], &si, sizeof(struct sc_pkcs15_sec_env_info));
 1279|     99|		idx++;
 1280|     99|	}
 1281|       |
 1282|     42|	*se  = ses;
 1283|     42|	*num = idx;
 1284|     42|	ret = SC_SUCCESS;
  ------------------
  |  |   28|     42|#define SC_SUCCESS				0
  ------------------
 1285|     51|err:
 1286|     51|	if (ret != SC_SUCCESS) {
  ------------------
  |  |   28|     51|#define SC_SUCCESS				0
  ------------------
  |  Branch (1286:6): [True: 9, False: 42]
  ------------------
 1287|      9|		size_t i;
 1288|     25|		for (i = 0; i < idx; i++)
  ------------------
  |  Branch (1288:15): [True: 16, False: 9]
  ------------------
 1289|     16|			if (ses[i])
  ------------------
  |  Branch (1289:8): [True: 16, False: 0]
  ------------------
 1290|     16|				free(ses[i]);
 1291|      9|		free(ses);
 1292|      9|	}
 1293|       |
 1294|     51|	SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_ASN1, ret);
  ------------------
  |  |  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|      9|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 9, False: 42]
  |  |  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1295|     51|}
asn1.c:asn1_encode:
 2039|  26.8k|{
 2040|  26.8k|	int r, idx = 0;
 2041|  26.8k|	u8 *obj = NULL, *buf = NULL, *tmp;
 2042|  26.8k|	size_t total = 0, objsize;
 2043|       |
 2044|  26.8k|	if (asn1 == NULL) {
  ------------------
  |  Branch (2044:6): [True: 0, False: 26.8k]
  ------------------
 2045|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 2046|      0|	}
 2047|       |
 2048|  82.1k|	for (idx = 0; asn1[idx].name != NULL; idx++) {
  ------------------
  |  Branch (2048:16): [True: 55.6k, False: 26.5k]
  ------------------
 2049|  55.6k|		r = asn1_encode_entry(ctx, &asn1[idx], &obj, &objsize, depth);
 2050|  55.6k|		if (r) {
  ------------------
  |  Branch (2050:7): [True: 338, False: 55.2k]
  ------------------
 2051|    338|			if (obj)
  ------------------
  |  Branch (2051:8): [True: 0, False: 338]
  ------------------
 2052|      0|				free(obj);
 2053|    338|			if (buf)
  ------------------
  |  Branch (2053:8): [True: 157, False: 181]
  ------------------
 2054|    157|				free(buf);
 2055|    338|			return r;
 2056|    338|		}
 2057|       |		/* in case of an empty (optional) element continue with
 2058|       |		 * the next asn1 element */
 2059|  55.2k|		if (!objsize)
  ------------------
  |  Branch (2059:7): [True: 19.2k, False: 36.0k]
  ------------------
 2060|  19.2k|			continue;
 2061|  36.0k|		tmp = (u8 *) realloc(buf, total + objsize);
 2062|  36.0k|		if (!tmp) {
  ------------------
  |  Branch (2062:7): [True: 0, False: 36.0k]
  ------------------
 2063|      0|			if (obj)
  ------------------
  |  Branch (2063:8): [True: 0, False: 0]
  ------------------
 2064|      0|				free(obj);
 2065|      0|			if (buf)
  ------------------
  |  Branch (2065:8): [True: 0, False: 0]
  ------------------
 2066|      0|				free(buf);
 2067|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2068|      0|		}
 2069|  36.0k|		buf = tmp;
 2070|  36.0k|		memcpy(buf + total, obj, objsize);
 2071|  36.0k|		free(obj);
 2072|  36.0k|		obj = NULL;
 2073|  36.0k|		total += objsize;
 2074|  36.0k|	}
 2075|  26.5k|	*ptr = buf;
 2076|  26.5k|	*size = total;
 2077|  26.5k|	return 0;
 2078|  26.8k|}
asn1.c:asn1_encode_entry:
 1826|  56.0k|{
 1827|  56.0k|	void *parm = entry->parm;
 1828|  56.0k|	int (*callback_func)(sc_context_t *nctx, void *arg, u8 **nobj,
 1829|  56.0k|			     size_t *nobjlen, int ndepth);
 1830|  56.0k|	const size_t *len = (const size_t *) entry->arg;
 1831|  56.0k|	int r = 0;
 1832|  56.0k|	u8 * buf = NULL;
 1833|  56.0k|	size_t buflen = 0;
 1834|       |
 1835|  56.0k|	callback_func = parm;
 1836|       |
 1837|  56.0k|	sc_debug(ctx, SC_LOG_DEBUG_ASN1, "%*.*sencoding '%s'%s\n",
  ------------------
  |  |   70|  56.0k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               #define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  | 1838|  56.0k|	       	depth, depth, "", entry->name,
  |  |  |  | 1839|  56.0k|		(entry->flags & SC_ASN1_PRESENT)? "" : " (not present)");
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|  56.0k|#define SC_ASN1_PRESENT			0x00000001
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1838|  56.0k|	       	depth, depth, "", entry->name,
 1839|  56.0k|		(entry->flags & SC_ASN1_PRESENT)? "" : " (not present)");
 1840|  56.0k|	if (!(entry->flags & SC_ASN1_PRESENT))
  ------------------
  |  |  147|  56.0k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (1840:6): [True: 19.2k, False: 36.7k]
  ------------------
 1841|  19.2k|		goto no_object;
 1842|  36.7k|	sc_debug(ctx, SC_LOG_DEBUG_ASN1, "%*.*stype=%d, tag=0x%02x, parm=%p, len=%zu",
  ------------------
  |  |   70|  73.4k|#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: 11.6k, False: 25.0k]
  |  |  ------------------
  ------------------
 1843|  36.7k|			depth, depth, "", entry->type, entry->tag, parm, len ? *len : 0);
 1844|       |
 1845|  36.7k|	if (entry->type == SC_ASN1_CHOICE) {
  ------------------
  |  |  170|  36.7k|#define SC_ASN1_CHOICE			130
  ------------------
  |  Branch (1845:6): [True: 408, False: 36.3k]
  ------------------
 1846|    408|		const struct sc_asn1_entry *list, *choice = NULL;
 1847|       |
 1848|    408|		list = (const struct sc_asn1_entry *) parm;
 1849|  1.60k|		while (list->name != NULL) {
  ------------------
  |  Branch (1849:10): [True: 1.19k, False: 408]
  ------------------
 1850|  1.19k|			if (list->flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|  1.19k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (1850:8): [True: 408, False: 789]
  ------------------
 1851|    408|				if (choice) {
  ------------------
  |  Branch (1851:9): [True: 0, False: 408]
  ------------------
 1852|      0|					sc_debug(ctx, SC_LOG_DEBUG_ASN1,
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1853|      0|						"ASN.1 problem: more than "
 1854|      0|						"one CHOICE when encoding %s: "
 1855|      0|						"%s and %s both present\n",
 1856|      0|						entry->name,
 1857|      0|						choice->name,
 1858|      0|						list->name);
 1859|      0|					return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 1860|      0|				}
 1861|    408|				choice = list;
 1862|    408|			}
 1863|  1.19k|			list++;
 1864|  1.19k|		}
 1865|    408|		if (choice == NULL)
  ------------------
  |  Branch (1865:7): [True: 0, False: 408]
  ------------------
 1866|      0|			goto no_object;
 1867|    408|		return asn1_encode_entry(ctx, choice, obj, objlen, depth + 1);
 1868|    408|	}
 1869|       |
 1870|  36.3k|	if (entry->type != SC_ASN1_NULL && parm == NULL) {
  ------------------
  |  |  158|  72.6k|#define SC_ASN1_NULL                    5
  ------------------
  |  Branch (1870:6): [True: 36.2k, False: 130]
  |  Branch (1870:37): [True: 0, False: 36.2k]
  ------------------
 1871|      0|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "unexpected parm == NULL\n");
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1872|      0|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 1873|      0|	}
 1874|       |
 1875|  36.3k|	switch (entry->type) {
 1876|  6.31k|	case SC_ASN1_STRUCT:
  ------------------
  |  |  169|  6.31k|#define SC_ASN1_STRUCT			129
  ------------------
  |  Branch (1876:2): [True: 6.31k, False: 30.0k]
  ------------------
 1877|  6.31k|		r = asn1_encode(ctx, (const struct sc_asn1_entry *) parm, &buf,
 1878|  6.31k|				&buflen, depth + 1);
 1879|  6.31k|		break;
 1880|    130|	case SC_ASN1_NULL:
  ------------------
  |  |  158|    130|#define SC_ASN1_NULL                    5
  ------------------
  |  Branch (1880:2): [True: 130, False: 36.2k]
  ------------------
 1881|    130|		buf = NULL;
 1882|    130|		buflen = 0;
 1883|    130|		break;
 1884|      0|	case SC_ASN1_BOOLEAN:
  ------------------
  |  |  153|      0|#define SC_ASN1_BOOLEAN                 1
  ------------------
  |  Branch (1884:2): [True: 0, False: 36.3k]
  ------------------
 1885|      0|		buf = malloc(1);
 1886|      0|		if (buf == NULL) {
  ------------------
  |  Branch (1886:7): [True: 0, False: 0]
  ------------------
 1887|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1888|      0|			break;
 1889|      0|		}
 1890|      0|		buf[0] = *((int *) parm) ? 0xFF : 0;
  ------------------
  |  Branch (1890:12): [True: 0, False: 0]
  ------------------
 1891|      0|		buflen = 1;
 1892|      0|		break;
 1893|  2.26k|	case SC_ASN1_INTEGER:
  ------------------
  |  |  154|  2.26k|#define SC_ASN1_INTEGER                 2
  ------------------
  |  Branch (1893:2): [True: 2.26k, False: 34.0k]
  ------------------
 1894|  2.44k|	case SC_ASN1_ENUMERATED:
  ------------------
  |  |  160|  2.44k|#define SC_ASN1_ENUMERATED              10
  ------------------
  |  Branch (1894:2): [True: 177, False: 36.1k]
  ------------------
 1895|  2.44k|		r = asn1_encode_integer(*((int *) entry->parm), &buf, &buflen);
 1896|  2.44k|		break;
 1897|     14|	case SC_ASN1_BIT_STRING_NI:
  ------------------
  |  |  156|     14|#define SC_ASN1_BIT_STRING_NI           128
  ------------------
  |  Branch (1897:2): [True: 14, False: 36.3k]
  ------------------
 1898|     14|	case SC_ASN1_BIT_STRING:
  ------------------
  |  |  155|     14|#define SC_ASN1_BIT_STRING              3
  ------------------
  |  Branch (1898:2): [True: 0, False: 36.3k]
  ------------------
 1899|     14|		if (len != NULL) {
  ------------------
  |  Branch (1899:7): [True: 14, False: 0]
  ------------------
 1900|     14|			if (entry->type == SC_ASN1_BIT_STRING)
  ------------------
  |  |  155|     14|#define SC_ASN1_BIT_STRING              3
  ------------------
  |  Branch (1900:8): [True: 0, False: 14]
  ------------------
 1901|      0|				r = encode_bit_string((const u8 *) parm, *len, &buf, &buflen, 1);
 1902|     14|			else
 1903|     14|				r = encode_bit_string((const u8 *) parm, *len, &buf, &buflen, 0);
 1904|     14|		} else {
 1905|      0|			r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1906|      0|		}
 1907|     14|		break;
 1908|  1.10k|	case SC_ASN1_BIT_FIELD:
  ------------------
  |  |  171|  1.10k|#define SC_ASN1_BIT_FIELD		131	/* bit string as integer */
  ------------------
  |  Branch (1908:2): [True: 1.10k, False: 35.2k]
  ------------------
 1909|  1.10k|		if (len != NULL) {
  ------------------
  |  Branch (1909:7): [True: 1.10k, False: 0]
  ------------------
 1910|  1.10k|			r = encode_bit_field((const u8 *) parm, *len, &buf, &buflen);
 1911|  1.10k|		} else {
 1912|      0|			r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1913|      0|		}
 1914|  1.10k|		break;
 1915|    861|	case SC_ASN1_PRINTABLESTRING:
  ------------------
  |  |  164|    861|#define SC_ASN1_PRINTABLESTRING         19
  ------------------
  |  Branch (1915:2): [True: 861, False: 35.4k]
  ------------------
 1916|  9.56k|	case SC_ASN1_OCTET_STRING:
  ------------------
  |  |  157|  9.56k|#define SC_ASN1_OCTET_STRING            4
  ------------------
  |  Branch (1916:2): [True: 8.70k, False: 27.6k]
  ------------------
 1917|  10.1k|	case SC_ASN1_UTF8STRING:
  ------------------
  |  |  161|  10.1k|#define SC_ASN1_UTF8STRING              12
  ------------------
  |  Branch (1917:2): [True: 555, False: 35.7k]
  ------------------
 1918|  10.1k|		if (len != NULL) {
  ------------------
  |  Branch (1918:7): [True: 10.1k, False: 0]
  ------------------
 1919|  10.1k|			buf = malloc(*len + 1);
 1920|  10.1k|			if (buf == NULL) {
  ------------------
  |  Branch (1920:8): [True: 0, False: 10.1k]
  ------------------
 1921|      0|				r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1922|      0|				break;
 1923|      0|			}
 1924|  10.1k|			buflen = 0;
 1925|       |			/* If the integer is supposed to be unsigned, insert
 1926|       |			 * a padding byte if the MSB is one */
 1927|  10.1k|			if ((entry->flags & SC_ASN1_UNSIGNED)
  ------------------
  |  |  150|  10.1k|#define SC_ASN1_UNSIGNED		0x00000008
  ------------------
  |  Branch (1927:8): [True: 160, False: 9.95k]
  ------------------
 1928|    160|					&& (((u8 *) parm)[0] & 0x80)) {
  ------------------
  |  Branch (1928:9): [True: 41, False: 119]
  ------------------
 1929|     41|				buf[buflen++] = 0x00;
 1930|     41|			}
 1931|  10.1k|			memcpy(buf + buflen, parm, *len);
 1932|  10.1k|			buflen += *len;
 1933|  10.1k|		} else {
 1934|      0|			r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1935|      0|		}
 1936|  10.1k|		break;
 1937|  10.1k|	case SC_ASN1_GENERALIZEDTIME:
  ------------------
  |  |  166|     50|#define SC_ASN1_GENERALIZEDTIME         24
  ------------------
  |  Branch (1937:2): [True: 50, False: 36.2k]
  ------------------
 1938|     50|		if (len != NULL) {
  ------------------
  |  Branch (1938:7): [True: 50, False: 0]
  ------------------
 1939|     50|			buf = malloc(*len);
 1940|     50|			if (buf == NULL) {
  ------------------
  |  Branch (1940:8): [True: 0, False: 50]
  ------------------
 1941|      0|				r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1942|      0|				break;
 1943|      0|			}
 1944|     50|			memcpy(buf, parm, *len);
 1945|     50|			buflen = *len;
 1946|     50|		} else {
 1947|      0|			r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1948|      0|		}
 1949|     50|		break;
 1950|  12.0k|	case SC_ASN1_OBJECT:
  ------------------
  |  |  159|  12.0k|#define SC_ASN1_OBJECT                  6
  ------------------
  |  Branch (1950:2): [True: 12.0k, False: 24.3k]
  ------------------
 1951|  12.0k|		r = sc_asn1_encode_object_id(&buf, &buflen, (struct sc_object_id *) parm);
 1952|  12.0k|		break;
 1953|  3.17k|	case SC_ASN1_PATH:
  ------------------
  |  |  174|  3.17k|#define SC_ASN1_PATH			256
  ------------------
  |  Branch (1953:2): [True: 3.17k, False: 33.1k]
  ------------------
 1954|  3.17k|		r = asn1_encode_path(ctx, (const sc_path_t *) parm, &buf, &buflen, depth, entry->flags);
 1955|  3.17k|		break;
 1956|    529|	case SC_ASN1_PKCS15_ID:
  ------------------
  |  |  175|    529|#define SC_ASN1_PKCS15_ID		257
  ------------------
  |  Branch (1956:2): [True: 529, False: 35.8k]
  ------------------
 1957|    529|		{
 1958|    529|			const struct sc_pkcs15_id *id = (const struct sc_pkcs15_id *) parm;
 1959|       |
 1960|    529|			buf = malloc(id->len);
 1961|    529|			if (buf == NULL) {
  ------------------
  |  Branch (1961:8): [True: 0, False: 529]
  ------------------
 1962|      0|				r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1963|      0|				break;
 1964|      0|			}
 1965|    529|			memcpy(buf, id->value, id->len);
 1966|    529|			buflen = id->len;
 1967|    529|		}
 1968|      0|		break;
 1969|    411|	case SC_ASN1_PKCS15_OBJECT:
  ------------------
  |  |  176|    411|#define SC_ASN1_PKCS15_OBJECT		258
  ------------------
  |  Branch (1969:2): [True: 411, False: 35.9k]
  ------------------
 1970|    411|		r = asn1_encode_p15_object(ctx, (const struct sc_asn1_pkcs15_object *) parm, &buf, &buflen, depth);
 1971|    411|		break;
 1972|     14|	case SC_ASN1_ALGORITHM_ID:
  ------------------
  |  |  177|     14|#define SC_ASN1_ALGORITHM_ID		259
  ------------------
  |  Branch (1972:2): [True: 14, False: 36.3k]
  ------------------
 1973|     14|		r = sc_asn1_encode_algorithm_id(ctx, &buf, &buflen, (const struct sc_algorithm_id *) parm, depth);
 1974|     14|		break;
 1975|     16|	case SC_ASN1_SE_INFO:
  ------------------
  |  |  178|     16|#define SC_ASN1_SE_INFO			260
  ------------------
  |  Branch (1975:2): [True: 16, False: 36.3k]
  ------------------
 1976|     16|		if (!len)
  ------------------
  |  Branch (1976:7): [True: 0, False: 16]
  ------------------
 1977|      0|			return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 1978|     16|		r = asn1_encode_se_info(ctx, (struct sc_pkcs15_sec_env_info **)parm, *len, &buf, &buflen, depth);
 1979|     16|		break;
 1980|      0|	case SC_ASN1_CALLBACK:
  ------------------
  |  |  181|      0|#define SC_ASN1_CALLBACK		384
  ------------------
  |  Branch (1980:2): [True: 0, False: 36.3k]
  ------------------
 1981|      0|		r = callback_func(ctx, entry->arg, &buf, &buflen, depth);
 1982|      0|		break;
 1983|      0|	default:
  ------------------
  |  Branch (1983:2): [True: 0, False: 36.3k]
  ------------------
 1984|      0|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "invalid ASN.1 type: %d\n", entry->type);
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1985|      0|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 1986|  36.3k|	}
 1987|  36.3k|	if (r) {
  ------------------
  |  Branch (1987:6): [True: 236, False: 36.1k]
  ------------------
 1988|    236|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "encoding of ASN.1 object '%s' failed: %s\n", entry->name,
  ------------------
  |  |   70|    236|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1989|    236|		      sc_strerror(r));
 1990|    236|		if (buf)
  ------------------
  |  Branch (1990:7): [True: 0, False: 236]
  ------------------
 1991|      0|			free(buf);
 1992|    236|		return r;
 1993|    236|	}
 1994|       |
 1995|       |	/* Treatment of OPTIONAL elements:
 1996|       |	 *  -	if the encoding has 0 length, and the element is OPTIONAL,
 1997|       |	 *	we don't write anything (unless it's an ASN1 NULL and the
 1998|       |	 *      SC_ASN1_PRESENT flag is set).
 1999|       |	 *  -	if the encoding has 0 length, but the element is non-OPTIONAL,
 2000|       |	 *	constructed, we write a empty element (e.g. a SEQUENCE of
 2001|       |	 *      length 0). In case of an ASN1 NULL just write the tag and
 2002|       |	 *      length (i.e. 0x05,0x00).
 2003|       |	 *  -	any other empty objects are considered bogus
 2004|       |	 */
 2005|  55.3k|no_object:
 2006|  55.3k|	if (!buflen && entry->flags & SC_ASN1_OPTIONAL && !(entry->flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  148|  74.8k|#define SC_ASN1_OPTIONAL		0x00000002
  ------------------
              	if (!buflen && entry->flags & SC_ASN1_OPTIONAL && !(entry->flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  147|  19.2k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (2006:6): [True: 19.4k, False: 35.8k]
  |  Branch (2006:17): [True: 19.2k, False: 214]
  |  Branch (2006:52): [True: 19.2k, False: 64]
  ------------------
 2007|       |		/* This happens when we try to encode e.g. the
 2008|       |		 * subClassAttributes, which may be empty */
 2009|  19.2k|		*obj = NULL;
 2010|  19.2k|		*objlen = 0;
 2011|  19.2k|		r = 0;
 2012|  36.1k|	} else if (!buflen && (entry->flags & SC_ASN1_EMPTY_ALLOWED)) {
  ------------------
  |  |  151|    278|#define SC_ASN1_EMPTY_ALLOWED           0x00000010
  ------------------
  |  Branch (2012:13): [True: 278, False: 35.8k]
  |  Branch (2012:24): [True: 46, False: 232]
  ------------------
 2013|     46|		*obj = NULL;
 2014|     46|		*objlen = 0;
 2015|     46|		r = asn1_write_element(ctx, entry->tag, buf, buflen, obj, objlen);
 2016|     46|		if (r)
  ------------------
  |  Branch (2016:7): [True: 0, False: 46]
  ------------------
 2017|      0|			sc_debug(ctx, SC_LOG_DEBUG_ASN1, "error writing ASN.1 tag and length: %s\n", sc_strerror(r));
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2018|  36.1k|	} else if (buflen || entry->type == SC_ASN1_NULL || entry->tag & SC_ASN1_CONS) {
  ------------------
  |  |  158|  36.3k|#define SC_ASN1_NULL                    5
  ------------------
              	} else if (buflen || entry->type == SC_ASN1_NULL || entry->tag & SC_ASN1_CONS) {
  ------------------
  |  |  141|    102|#define SC_ASN1_CONS			0x20000000
  ------------------
  |  Branch (2018:13): [True: 35.8k, False: 232]
  |  Branch (2018:23): [True: 130, False: 102]
  |  Branch (2018:54): [True: 0, False: 102]
  ------------------
 2019|  36.0k|		r = asn1_write_element(ctx, entry->tag, buf, buflen, obj, objlen);
 2020|  36.0k|		if (r)
  ------------------
  |  Branch (2020:7): [True: 0, False: 36.0k]
  ------------------
 2021|      0|			sc_debug(ctx, SC_LOG_DEBUG_ASN1, "error writing ASN.1 tag and length: %s\n",
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2022|  36.0k|					sc_strerror(r));
 2023|  36.0k|	} else if (!(entry->flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  147|    102|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (2023:13): [True: 75, False: 27]
  ------------------
 2024|     75|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "cannot encode non-optional ASN.1 object: not given by caller\n");
  ------------------
  |  |   70|     75|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2025|     75|		r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|     75|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 2026|     75|	} else {
 2027|     27|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "cannot encode empty non-optional ASN.1 object\n");
  ------------------
  |  |   70|     27|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2028|     27|		r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|     27|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 2029|     27|	}
 2030|  55.3k|	if (buf)
  ------------------
  |  Branch (2030:6): [True: 35.9k, False: 19.4k]
  ------------------
 2031|  35.9k|		free(buf);
 2032|  55.3k|	if (r >= 0)
  ------------------
  |  Branch (2032:6): [True: 55.2k, False: 102]
  ------------------
 2033|  55.2k|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "%*.*slength of encoded item=%zu", depth, depth, "", *objlen);
  ------------------
  |  |   70|  55.2k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2034|  55.3k|	return r;
 2035|  36.3k|}
asn1.c:asn1_encode_integer:
  771|  2.44k|{
  772|  2.44k|	int i = sizeof(in) * 8, skip_zero, skip_sign;
  773|  2.44k|	u8 *p, b;
  774|       |
  775|  2.44k|	if (in < 0)
  ------------------
  |  Branch (775:6): [True: 116, False: 2.33k]
  ------------------
  776|    116|	{
  777|    116|		skip_sign = 1;
  778|    116|		skip_zero= 0;
  779|    116|	}
  780|  2.33k|	else
  781|  2.33k|	{
  782|  2.33k|		skip_sign = 0;
  783|  2.33k|		skip_zero= 1;
  784|  2.33k|	}
  785|  2.44k|	*obj = p = malloc(sizeof(in)+1);
  786|  2.44k|	if (*obj == NULL)
  ------------------
  |  Branch (786:6): [True: 0, False: 2.44k]
  ------------------
  787|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  788|  9.78k|	do {
  789|  9.78k|		i -= 8;
  790|  9.78k|		b = in >> i;
  791|  9.78k|		if (skip_sign)
  ------------------
  |  Branch (791:7): [True: 446, False: 9.33k]
  ------------------
  792|    446|		{
  793|    446|			if (b != 0xff)
  ------------------
  |  Branch (793:8): [True: 70, False: 376]
  ------------------
  794|     70|				skip_sign = 0;
  795|    446|			if (b & 0x80)
  ------------------
  |  Branch (795:8): [True: 439, False: 7]
  ------------------
  796|    439|			{
  797|    439|				*p = b;
  798|    439|				if (0xff == b)
  ------------------
  |  Branch (798:9): [True: 376, False: 63]
  ------------------
  799|    376|					continue;
  800|    439|			}
  801|      7|			else
  802|      7|			{
  803|      7|				p++;
  804|      7|				skip_sign = 0;
  805|      7|			}
  806|    446|		}
  807|  9.40k|		if (b == 0 && skip_zero)
  ------------------
  |  Branch (807:7): [True: 7.63k, False: 1.77k]
  |  Branch (807:17): [True: 7.32k, False: 307]
  ------------------
  808|  7.32k|			continue;
  809|  2.07k|		if (skip_zero) {
  ------------------
  |  Branch (809:7): [True: 1.57k, False: 505]
  ------------------
  810|  1.57k|			skip_zero = 0;
  811|       |			/* prepend 0x00 if MSb is 1 and integer positive */
  812|  1.57k|			if ((b & 0x80) != 0 && in > 0)
  ------------------
  |  Branch (812:8): [True: 107, False: 1.46k]
  |  Branch (812:27): [True: 107, False: 0]
  ------------------
  813|    107|				*p++ = 0;
  814|  1.57k|		}
  815|  2.07k|		*p++ = b;
  816|  9.78k|	} while (i > 0);
  ------------------
  |  Branch (816:11): [True: 7.33k, False: 2.44k]
  ------------------
  817|  2.44k|	if (skip_sign)
  ------------------
  |  Branch (817:6): [True: 46, False: 2.40k]
  ------------------
  818|     46|		p++;
  819|  2.44k|	*objsize = p - *obj;
  820|  2.44k|	if (*objsize == 0) {
  ------------------
  |  Branch (820:6): [True: 756, False: 1.69k]
  ------------------
  821|    756|		*objsize = 1;
  822|    756|		(*obj)[0] = 0;
  823|    756|	}
  824|  2.44k|	return 0;
  825|  2.44k|}
asn1.c:encode_bit_string:
  647|  1.11k|{
  648|  1.11k|	const u8 *in = inbuf;
  649|  1.11k|	u8 *out;
  650|  1.11k|	size_t bytes, skipped = 0;
  651|       |
  652|  1.11k|	bytes = BYTES4BITS(bits_left) + 1;
  ------------------
  |  |  146|  1.11k|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  653|  1.11k|	*outbuf = out = malloc(bytes);
  654|  1.11k|	if (out == NULL)
  ------------------
  |  Branch (654:6): [True: 0, False: 1.11k]
  ------------------
  655|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  656|  1.11k|	*outlen = bytes;
  657|  1.11k|	out += 1;
  658|  3.30k|	while (bits_left) {
  ------------------
  |  Branch (658:9): [True: 2.18k, False: 1.11k]
  ------------------
  659|  2.18k|		size_t i, bits_to_go = 8;
  660|       |
  661|  2.18k|		*out = 0;
  662|  2.18k|		if (bits_left < 8) {
  ------------------
  |  Branch (662:7): [True: 1.05k, False: 1.13k]
  ------------------
  663|  1.05k|			bits_to_go = bits_left;
  664|  1.05k|			skipped = 8 - bits_left;
  665|  1.05k|		}
  666|  2.18k|		if (invert) {
  ------------------
  |  Branch (666:7): [True: 1.13k, False: 1.05k]
  ------------------
  667|  5.16k|			for (i = 0; i < bits_to_go; i++)
  ------------------
  |  Branch (667:16): [True: 4.03k, False: 1.13k]
  ------------------
  668|  4.03k|				*out |= ((*in >> i) & 1) << (7 - i);
  669|  1.13k|		} else {
  670|  1.05k|			*out = *in;
  671|  1.05k|			if (bits_left < 8)
  ------------------
  |  Branch (671:8): [True: 0, False: 1.05k]
  ------------------
  672|      0|				return SC_ERROR_NOT_SUPPORTED; /* FIXME */
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  673|  1.05k|		}
  674|  2.18k|		bits_left -= bits_to_go;
  675|  2.18k|		out++, in++;
  676|  2.18k|	}
  677|  1.11k|	out = *outbuf;
  678|  1.11k|	out[0] = skipped;
  679|  1.11k|	return 0;
  680|  1.11k|}
asn1.c:encode_bit_field:
  708|  1.10k|{
  709|  1.10k|	u8		data[sizeof(unsigned int)];
  710|  1.10k|	unsigned int	field = 0;
  711|  1.10k|	size_t		i, bits;
  712|       |
  713|  1.10k|	if (inlen != sizeof(data))
  ------------------
  |  Branch (713:6): [True: 0, False: 1.10k]
  ------------------
  714|      0|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  715|       |
  716|       |	/* count the bits */
  717|  1.10k|	memcpy(&field, inbuf, inlen);
  718|  5.14k|	for (bits = 0; field; bits++)
  ------------------
  |  Branch (718:17): [True: 4.03k, False: 1.10k]
  ------------------
  719|  4.03k|		field >>= 1;
  720|       |
  721|  1.10k|	memcpy(&field, inbuf, inlen);
  722|  2.23k|	for (i = 0; i < bits; i += 8)
  ------------------
  |  Branch (722:14): [True: 1.13k, False: 1.10k]
  ------------------
  723|  1.13k|		data[i/8] = field >> i;
  724|       |
  725|  1.10k|	return encode_bit_string(data, bits, outbuf, outlen, 1);
  726|  1.10k|}
asn1.c:asn1_encode_path:
 1207|  3.17k|{
 1208|  3.17k|	int r;
 1209|  3.17k| 	struct sc_asn1_entry asn1_path[5];
 1210|  3.17k|	sc_path_t tpath = *path;
 1211|       |
 1212|  3.17k|	sc_copy_asn1_entry(c_asn1_path, asn1_path);
 1213|  3.17k|	sc_format_asn1_entry(asn1_path + 0, (void *) &tpath.value, (void *) &tpath.len, 1);
 1214|       |
 1215|  3.17k|	asn1_path[0].flags |= parent_flags;
 1216|  3.17k|	if (path->count > 0) {
  ------------------
  |  Branch (1216:6): [True: 8, False: 3.16k]
  ------------------
 1217|      8|		sc_format_asn1_entry(asn1_path + 1, (void *) &tpath.index, NULL, 1);
 1218|       |		sc_format_asn1_entry(asn1_path + 2, (void *) &tpath.count, NULL, 1);
 1219|      8|	}
 1220|  3.17k|	r = asn1_encode(ctx, asn1_path, buf, bufsize, depth + 1);
 1221|  3.17k|	return r;
 1222|  3.17k|}
asn1.c:asn1_encode_p15_object:
 1430|    411|{
 1431|    411|	struct sc_pkcs15_object p15_obj = *obj->p15_obj;
 1432|    411|	struct sc_asn1_entry    asn1_c_attr[6], asn1_p15_obj[5];
 1433|    411|	struct sc_asn1_entry asn1_ac_rules[SC_PKCS15_MAX_ACCESS_RULES + 1], asn1_ac_rule[SC_PKCS15_MAX_ACCESS_RULES][3];
 1434|    411|	size_t label_len = strlen(p15_obj.label);
 1435|    411|	size_t flags_len;
 1436|    411|	size_t access_mode_len;
 1437|    411|	int r, ii;
 1438|       |
 1439|    411|	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|    411|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1440|    411|	if (p15_obj.access_rules[0].access_mode)   {
  ------------------
  |  Branch (1440:6): [True: 0, False: 411]
  ------------------
 1441|      0|		for (ii=0; ii<SC_PKCS15_MAX_ACCESS_RULES; ii++)   {
  ------------------
  |  |   42|      0|#define SC_PKCS15_MAX_ACCESS_RULES      8
  ------------------
  |  Branch (1441:14): [True: 0, False: 0]
  ------------------
 1442|      0|			sc_copy_asn1_entry(c_asn1_access_control_rule, asn1_ac_rule[ii]);
 1443|      0|			if (p15_obj.access_rules[ii].auth_id.len == 0)   {
  ------------------
  |  Branch (1443:8): [True: 0, False: 0]
  ------------------
 1444|      0|				asn1_ac_rule[ii][1].type = SC_ASN1_NULL;
  ------------------
  |  |  158|      0|#define SC_ASN1_NULL                    5
  ------------------
 1445|      0|				asn1_ac_rule[ii][1].tag = SC_ASN1_TAG_NULL;
  ------------------
  |  |  199|      0|#define SC_ASN1_TAG_NULL		5
  ------------------
 1446|      0|			}
 1447|      0|		}
 1448|      0|		sc_copy_asn1_entry(c_asn1_access_control_rules, asn1_ac_rules);
 1449|      0|	}
 1450|       |
 1451|    411|	sc_copy_asn1_entry(c_asn1_com_obj_attr, asn1_c_attr);
 1452|    411|	sc_copy_asn1_entry(c_asn1_p15_obj, asn1_p15_obj);
 1453|    411|	if (label_len != 0)
  ------------------
  |  Branch (1453:6): [True: 365, False: 46]
  ------------------
 1454|    365|		sc_format_asn1_entry(asn1_c_attr + 0, (void *) p15_obj.label, &label_len, 1);
 1455|    411|	if (p15_obj.flags) {
  ------------------
  |  Branch (1455:6): [True: 411, False: 0]
  ------------------
 1456|    411|		flags_len = sizeof(p15_obj.flags);
 1457|    411|		sc_format_asn1_entry(asn1_c_attr + 1, (void *) &p15_obj.flags, &flags_len, 1);
 1458|    411|	}
 1459|    411|	if (p15_obj.auth_id.len)
  ------------------
  |  Branch (1459:6): [True: 171, False: 240]
  ------------------
 1460|    171|		sc_format_asn1_entry(asn1_c_attr + 2, (void *) &p15_obj.auth_id, NULL, 1);
 1461|    411|	if (p15_obj.user_consent)
  ------------------
  |  Branch (1461:6): [True: 0, False: 411]
  ------------------
 1462|      0|		sc_format_asn1_entry(asn1_c_attr + 3, (void *) &p15_obj.user_consent, NULL, 1);
 1463|       |
 1464|    411|	if (p15_obj.access_rules[0].access_mode)   {
  ------------------
  |  Branch (1464:6): [True: 0, False: 411]
  ------------------
 1465|      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 (1465:16): [True: 0, False: 0]
  |  Branch (1465:51): [True: 0, False: 0]
  ------------------
 1466|      0|			access_mode_len = sizeof(p15_obj.access_rules[ii].access_mode);
 1467|      0|			sc_format_asn1_entry(asn1_ac_rule[ii] + 0, (void *) &p15_obj.access_rules[ii].access_mode, &access_mode_len, 1);
 1468|      0|			sc_format_asn1_entry(asn1_ac_rule[ii] + 1, (void *) &p15_obj.access_rules[ii].auth_id, NULL, 1);
 1469|      0|			sc_format_asn1_entry(asn1_ac_rules + ii, asn1_ac_rule[ii], NULL, 1);
 1470|      0|		}
 1471|      0|		sc_format_asn1_entry(asn1_c_attr + 4, asn1_ac_rules, NULL, 1);
 1472|      0|	}
 1473|       |
 1474|    411|	sc_format_asn1_entry(asn1_p15_obj + 0, asn1_c_attr, NULL, 1);
 1475|    411|	sc_format_asn1_entry(asn1_p15_obj + 1, obj->asn1_class_attr, NULL, 1);
 1476|    411|	if (obj->asn1_subclass_attr != NULL && obj->asn1_subclass_attr->name)
  ------------------
  |  Branch (1476:6): [True: 171, False: 240]
  |  Branch (1476:41): [True: 97, False: 74]
  ------------------
 1477|     97|		sc_format_asn1_entry(asn1_p15_obj + 2, obj->asn1_subclass_attr, NULL, 1);
 1478|    411|	sc_format_asn1_entry(asn1_p15_obj + 3, obj->asn1_type_attr, NULL, 1);
 1479|       |
 1480|    411|	r = asn1_encode(ctx, asn1_p15_obj, buf, bufsize, depth + 1);
 1481|    411|	return r;
 1482|    411|}
asn1.c:asn1_encode_se_info:
 1301|     16|{
 1302|     16|	unsigned char *ptr = NULL, *out = NULL, *p;
 1303|     16|	size_t ptrlen = 0, outlen = 0, idx;
 1304|     16|	int ret;
 1305|       |
 1306|     47|	for (idx=0; idx < se_num; idx++)   {
  ------------------
  |  Branch (1306:14): [True: 31, False: 16]
  ------------------
 1307|     31|		struct sc_asn1_entry asn1_se[2];
 1308|     31|		struct sc_asn1_entry asn1_se_info[4];
 1309|       |
 1310|     31|		sc_copy_asn1_entry(c_asn1_se, asn1_se);
 1311|     31|		sc_copy_asn1_entry(c_asn1_se_info, asn1_se_info);
 1312|       |
 1313|     31|		sc_format_asn1_entry(asn1_se_info + 0, &se[idx]->se, NULL, 1);
 1314|     31|		if (sc_valid_oid(&se[idx]->owner))
  ------------------
  |  Branch (1314:7): [True: 5, False: 26]
  ------------------
 1315|      5|			sc_format_asn1_entry(asn1_se_info + 1, &se[idx]->owner, NULL, 1);
 1316|     31|		if (se[idx]->aid.len)
  ------------------
  |  Branch (1316:7): [True: 28, False: 3]
  ------------------
 1317|     28|			sc_format_asn1_entry(asn1_se_info + 2, &se[idx]->aid.value, &se[idx]->aid.len, 1);
 1318|     31|		sc_format_asn1_entry(asn1_se + 0, asn1_se_info, NULL, 1);
 1319|       |
 1320|     31|		ret = sc_asn1_encode(ctx, asn1_se, &ptr, &ptrlen);
 1321|     31|		if (ret != SC_SUCCESS)
  ------------------
  |  |   28|     31|#define SC_SUCCESS				0
  ------------------
  |  Branch (1321:7): [True: 0, False: 31]
  ------------------
 1322|      0|			goto err;
 1323|       |
 1324|     31|		if (!ptrlen)
  ------------------
  |  Branch (1324:7): [True: 0, False: 31]
  ------------------
 1325|      0|			continue;
 1326|     31|		p = (unsigned char *) realloc(out, outlen + ptrlen);
 1327|     31|		if (!p)   {
  ------------------
  |  Branch (1327:7): [True: 0, False: 31]
  ------------------
 1328|      0|			ret = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1329|      0|			goto err;
 1330|      0|		}
 1331|     31|		out = p;
 1332|     31|		memcpy(out + outlen, ptr, ptrlen);
 1333|     31|		outlen += ptrlen;
 1334|     31|		free(ptr);
 1335|     31|		ptr = NULL;
 1336|     31|		ptrlen = 0;
 1337|     31|	}
 1338|       |
 1339|     16|	*buf = out;
 1340|     16|	*bufsize = outlen;
 1341|     16|	ret = SC_SUCCESS;
  ------------------
  |  |   28|     16|#define SC_SUCCESS				0
  ------------------
 1342|     16|err:
 1343|     16|	if (ret != SC_SUCCESS && out != NULL)
  ------------------
  |  |   28|     32|#define SC_SUCCESS				0
  ------------------
  |  Branch (1343:6): [True: 0, False: 16]
  |  Branch (1343:27): [True: 0, False: 0]
  ------------------
 1344|      0|		free(out);
 1345|     16|	return ret;
 1346|     16|}

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

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

sc_get_atrust_acos_driver:
  814|  16.3k|{
  815|  16.3k|	return sc_get_driver();
  816|  16.3k|}
card-atrust-acos.c:sc_get_driver:
  789|  16.3k|{
  790|  16.3k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
  791|  16.3k|	if (iso_ops == NULL)
  ------------------
  |  Branch (791:6): [True: 1, False: 16.3k]
  ------------------
  792|      1|		iso_ops = iso_drv->ops;
  793|       |
  794|  16.3k|	atrust_acos_ops = *iso_drv->ops;
  795|  16.3k|	atrust_acos_ops.match_card = atrust_acos_match_card;
  796|  16.3k|	atrust_acos_ops.init   = atrust_acos_init;
  797|  16.3k|	atrust_acos_ops.finish = atrust_acos_finish;
  798|  16.3k|	atrust_acos_ops.select_file = atrust_acos_select_file;
  799|  16.3k|	atrust_acos_ops.check_sw    = atrust_acos_check_sw;
  800|  16.3k|	atrust_acos_ops.create_file = NULL;
  801|  16.3k|	atrust_acos_ops.delete_file = NULL;
  802|  16.3k|	atrust_acos_ops.set_security_env  = atrust_acos_set_security_env;
  803|  16.3k|	atrust_acos_ops.compute_signature = atrust_acos_compute_signature;
  804|  16.3k|	atrust_acos_ops.decipher    = atrust_acos_decipher;
  805|  16.3k|	atrust_acos_ops.card_ctl    = atrust_acos_card_ctl;
  806|  16.3k|	atrust_acos_ops.logout      = atrust_acos_logout;
  807|       |
  808|  16.3k|	return &atrust_acos_drv;
  809|  16.3k|}
card-atrust-acos.c:atrust_acos_match_card:
   76|  16.3k|{
   77|  16.3k|	int		i, match = 0;
   78|       |
   79|       |
   80|  81.7k|	for (i = 0; atrust_acos_atrs[i] != NULL; i++)
  ------------------
  |  Branch (80:14): [True: 65.4k, False: 16.3k]
  ------------------
   81|  65.4k|	{
   82|  65.4k|		u8 defatr[SC_MAX_ATR_SIZE];
   83|  65.4k|		size_t len = sizeof(defatr);
   84|  65.4k|		const char *atrp = atrust_acos_atrs[i];
   85|       |
   86|  65.4k|		if (sc_hex_to_bin(atrp, defatr, &len))
  ------------------
  |  Branch (86:7): [True: 0, False: 65.4k]
  ------------------
   87|      0|			continue;
   88|       |		/* we may only verify part of ATR since */
   89|       |		/* part of the hist chars is variable */
   90|  65.4k|		if (len > card->atr.len)
  ------------------
  |  Branch (90:7): [True: 31.3k, False: 34.1k]
  ------------------
   91|  31.3k|			continue;
   92|  34.1k|		if (memcmp(card->atr.value, defatr, len) != 0)
  ------------------
  |  Branch (92:7): [True: 34.1k, False: 4]
  ------------------
   93|  34.1k|			continue;
   94|       |
   95|      4|		match = 1;
   96|      4|		card->name = atrust_acos_names[i];
   97|       |
   98|      4|		break;
   99|  34.1k|    }
  100|  16.3k|	return match;
  101|  16.3k|}
card-atrust-acos.c:atrust_acos_init:
  106|      4|{
  107|      4|	unsigned int flags;
  108|      4|	atrust_acos_ex_data *ex_data;
  109|       |
  110|      4|	ex_data = calloc(1, sizeof(atrust_acos_ex_data));
  111|      4|	if (ex_data == NULL)
  ------------------
  |  Branch (111:6): [True: 0, False: 4]
  ------------------
  112|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  113|       |
  114|      4|	card->cla  = 0x00;
  115|      4|	card->drv_data = (void *)ex_data;
  116|       |
  117|       |	/* set the supported algorithm */
  118|       |
  119|      4|	flags = SC_ALGORITHM_RSA_PAD_PKCS1
  ------------------
  |  |  111|      4|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|      4|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|      4|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  120|      4|		| SC_ALGORITHM_RSA_HASH_NONE
  ------------------
  |  |  133|      4|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  121|      4|		| SC_ALGORITHM_RSA_HASH_SHA1
  ------------------
  |  |  134|      4|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  ------------------
  122|      4|		| SC_ALGORITHM_RSA_HASH_MD5
  ------------------
  |  |  135|      4|#define SC_ALGORITHM_RSA_HASH_MD5	0x00000400
  ------------------
  123|      4|		| SC_ALGORITHM_RSA_HASH_RIPEMD160
  ------------------
  |  |  137|      4|#define SC_ALGORITHM_RSA_HASH_RIPEMD160	0x00001000
  ------------------
  124|      4|		| SC_ALGORITHM_RSA_HASH_MD5_SHA1;
  ------------------
  |  |  136|      4|#define SC_ALGORITHM_RSA_HASH_MD5_SHA1	0x00000800
  ------------------
  125|       |
  126|      4|	if (card->name != NULL && !strcmp(card->name, ACOS_EMV_A05))
  ------------------
  |  |   37|      4|#define ACOS_EMV_A05		"A-TRUST ACOS A05"
  ------------------
  |  Branch (126:6): [True: 4, False: 0]
  |  Branch (126:28): [True: 2, False: 2]
  ------------------
  127|      2|		flags |= SC_ALGORITHM_RSA_HASH_SHA256;
  ------------------
  |  |  138|      2|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  ------------------
  128|       |
  129|      4|	_sc_card_add_rsa_alg(card, 1536, flags, 0x10001);
  130|       |
  131|       |	/* we need read_binary&friends with max 128 bytes per read */
  132|      4|	card->max_send_size = 128;
  133|      4|	card->max_recv_size = 128;
  134|       |
  135|      4|	return 0;
  136|      4|}
card-atrust-acos.c:atrust_acos_finish:
  141|      4|{
  142|      4|	if (card->drv_data)
  ------------------
  |  Branch (142:6): [True: 4, False: 0]
  ------------------
  143|      4|		free((atrust_acos_ex_data *)card->drv_data);
  144|      4|	return 0;
  145|      4|}
card-atrust-acos.c:atrust_acos_card_ctl:
  748|      4|{
  749|       |
  750|      4|	switch (cmd)
  751|      4|	{
  752|      0|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (752:2): [True: 0, False: 4]
  ------------------
  753|      0|		return acos_get_serialnr(card, (sc_serial_number_t *)ptr);
  754|      4|	default:
  ------------------
  |  Branch (754:2): [True: 4, False: 0]
  ------------------
  755|      4|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      4|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  756|      4|	}
  757|      4|}

sc_get_authentic_driver:
 2149|  16.3k|{
 2150|  16.3k|	return sc_get_driver();
 2151|  16.3k|}
card-authentic.c:sc_get_driver:
 2114|  16.3k|{
 2115|  16.3k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 2116|       |
 2117|  16.3k|	if (!iso_ops)
  ------------------
  |  Branch (2117:6): [True: 1, False: 16.3k]
  ------------------
 2118|      1|		iso_ops = iso_drv->ops;
 2119|       |
 2120|  16.3k|	authentic_ops = *iso_ops;
 2121|       |
 2122|  16.3k|	authentic_ops.match_card = authentic_match_card;
 2123|  16.3k|	authentic_ops.init = authentic_init;
 2124|  16.3k|	authentic_ops.finish = authentic_finish;
 2125|  16.3k|	authentic_ops.read_binary = authentic_read_binary;
 2126|  16.3k|	authentic_ops.write_binary = authentic_write_binary;
 2127|  16.3k|	authentic_ops.update_binary = authentic_update_binary;
 2128|  16.3k|	authentic_ops.erase_binary = authentic_erase_binary;
 2129|       |	/* authentic_ops.resize_file = authentic_resize_file; */
 2130|  16.3k|	authentic_ops.select_file = authentic_select_file;
 2131|       |	/* get_response: Untested */
 2132|  16.3k|	authentic_ops.get_challenge = authentic_get_challenge;
 2133|  16.3k|	authentic_ops.set_security_env = authentic_set_security_env;
 2134|       |	/* decipher: Untested */
 2135|  16.3k|	authentic_ops.decipher = authentic_decipher;
 2136|       |	/* authentic_ops.compute_signature = authentic_compute_signature; */
 2137|  16.3k|	authentic_ops.create_file = authentic_create_file;
 2138|  16.3k|	authentic_ops.delete_file = authentic_delete_file;
 2139|  16.3k|	authentic_ops.card_ctl = authentic_card_ctl;
 2140|  16.3k|	authentic_ops.process_fci = authentic_process_fci;
 2141|  16.3k|	authentic_ops.pin_cmd = authentic_pin_cmd;
 2142|  16.3k|	authentic_ops.card_reader_lock_obtained = authentic_card_reader_lock_obtained;
 2143|       |
 2144|  16.3k|	return &authentic_drv;
 2145|  16.3k|}
card-authentic.c:authentic_match_card:
  390|  13.2k|{
  391|  13.2k|	struct sc_context *ctx = card->ctx;
  392|  13.2k|	int i;
  393|       |
  394|  13.2k|	sc_log_hex(ctx, "try to match card with ATR", card->atr.value, card->atr.len);
  ------------------
  |  |  129|  13.2k|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|  13.2k|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  395|  13.2k|	i = _sc_match_atr(card, authentic_known_atrs, &card->type);
  396|  13.2k|	if (i < 0)   {
  ------------------
  |  Branch (396:6): [True: 12.7k, False: 427]
  ------------------
  397|  12.7k|		sc_log(ctx, "card not matched");
  ------------------
  |  |   71|  12.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__
  |  |  ------------------
  ------------------
  398|  12.7k|		return 0;
  399|  12.7k|	}
  400|       |
  401|    427|	sc_log(ctx, "'%s' card matched", authentic_known_atrs[i].name);
  ------------------
  |  |   71|    427|#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|    427|	return 1;
  403|  13.2k|}
card-authentic.c:authentic_init:
  442|    427|{
  443|    427|	struct sc_context *ctx = card->ctx;
  444|    427|	int ii, rv = SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|    427|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  445|       |
  446|    427|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    427|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    427|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    427|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    427|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 427]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  447|    427|	for(ii=0;authentic_known_atrs[ii].atr;ii++)   {
  ------------------
  |  Branch (447:11): [True: 427, False: 0]
  ------------------
  448|    427|		if (card->type == authentic_known_atrs[ii].type)   {
  ------------------
  |  Branch (448:7): [True: 427, False: 0]
  ------------------
  449|    427|			card->name = authentic_known_atrs[ii].name;
  450|    427|			card->flags = authentic_known_atrs[ii].flags;
  451|    427|			break;
  452|    427|		}
  453|    427|	}
  454|       |
  455|    427|	if (!authentic_known_atrs[ii].atr)
  ------------------
  |  Branch (455:6): [True: 0, False: 427]
  ------------------
  456|    427|		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|    427|	card->cla  = 0x00;
  459|    427|	card->drv_data = (struct authentic_private_data *) calloc(1, sizeof(struct authentic_private_data));
  460|    427|	if (!card->drv_data)
  ------------------
  |  Branch (460:6): [True: 0, False: 427]
  ------------------
  461|    427|		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|    427|	if (card->type == SC_CARD_TYPE_OBERTHUR_AUTHENTIC_3_2)
  ------------------
  |  Branch (463:6): [True: 427, False: 0]
  ------------------
  464|    427|		rv = authentic_init_oberthur_authentic_3_2(card);
  465|       |
  466|    427|	if (rv != SC_SUCCESS)
  ------------------
  |  |   28|    427|#define SC_SUCCESS				0
  ------------------
  |  Branch (466:6): [True: 193, False: 234]
  ------------------
  467|    193|		rv = authentic_get_serialnr(card, NULL);
  468|       |
  469|    427|	if (rv != SC_SUCCESS)
  ------------------
  |  |   28|    427|#define SC_SUCCESS				0
  ------------------
  |  Branch (469:6): [True: 31, False: 396]
  ------------------
  470|     31|		rv = SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|     31|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  471|       |
  472|       |	/* Free private data on error */
  473|    427|	if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|    427|#define SC_SUCCESS				0
  ------------------
  |  Branch (473:6): [True: 31, False: 396]
  ------------------
  474|     31|		free(card->drv_data);
  475|     31|		card->drv_data = NULL;
  476|     31|	}
  477|    427|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    427|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    427|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    427|	int _ret = r; \
  |  |  |  |  155|    427|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 427, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    427|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     31|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 31, False: 396]
  |  |  |  |  ------------------
  |  |  |  |  157|    427|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    427|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    427|	return _ret; \
  |  |  |  |  163|    427|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  478|    427|}
card-authentic.c:authentic_init_oberthur_authentic_3_2:
  408|    427|{
  409|    427|	struct sc_context *ctx = card->ctx;
  410|    427|	unsigned int flags;
  411|    427|	int rv = 0;
  412|       |
  413|    427|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    427|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    427|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    427|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    427|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 427]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  414|       |
  415|    427|	flags = AUTHENTIC_CARD_DEFAULT_FLAGS;
  ------------------
  |  |   43|    427|#define AUTHENTIC_CARD_DEFAULT_FLAGS ( 0		\
  |  |   44|    427|		| SC_ALGORITHM_ONBOARD_KEY_GEN		\
  |  |  ------------------
  |  |  |  |   93|    427|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  |  |  ------------------
  |  |   45|    427|		| SC_ALGORITHM_RSA_PAD_ISO9796		\
  |  |  ------------------
  |  |  |  |  106|    427|#define SC_ALGORITHM_RSA_PAD_ISO9796	0x00000008
  |  |  ------------------
  |  |   46|    427|		| SC_ALGORITHM_RSA_PAD_PKCS1		\
  |  |  ------------------
  |  |  |  |  111|    427|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|    427|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  |  |  ------------------
  |  |  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|    427|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   47|    427|		| SC_ALGORITHM_RSA_HASH_NONE		\
  |  |  ------------------
  |  |  |  |  133|    427|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  |  |   48|    427|		| SC_ALGORITHM_RSA_HASH_SHA1		\
  |  |  ------------------
  |  |  |  |  134|    427|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  ------------------
  |  |   49|    427|		| SC_ALGORITHM_RSA_HASH_SHA256)
  |  |  ------------------
  |  |  |  |  138|    427|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  |  |  ------------------
  ------------------
  416|       |
  417|    427|	card->caps = SC_CARD_CAP_RNG;
  ------------------
  |  |  550|    427|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  418|    427|	card->caps |= SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  547|    427|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  419|    427|	card->caps |= SC_CARD_CAP_USE_FCI_AC;
  ------------------
  |  |  557|    427|#define SC_CARD_CAP_USE_FCI_AC		0x00000010
  ------------------
  420|       |
  421|    427|#ifdef ENABLE_SM
  422|    427|	card->sm_ctx.ops.open = authentic_sm_open;
  423|    427|	card->sm_ctx.ops.get_sm_apdu = authentic_sm_get_wrapped_apdu;
  424|    427|	card->sm_ctx.ops.free_sm_apdu = authentic_sm_free_wrapped_apdu;
  425|    427|#endif
  426|       |
  427|    427|	rv = iso7816_select_aid(card, aid_AuthentIC_3_2, sizeof(aid_AuthentIC_3_2), NULL, NULL);
  428|    427|	LOG_TEST_RET(ctx, rv, "AuthentIC application select error");
  ------------------
  |  |  174|    427|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    427|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    427|	int _ret = (r); \
  |  |  |  |  168|    427|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 169, False: 258]
  |  |  |  |  ------------------
  |  |  |  |  169|    169|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    169|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    169|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    169|		return _ret; \
  |  |  |  |  172|    169|	} \
  |  |  |  |  173|    427|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 258]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  429|       |
  430|    258|	rv = authentic_select_mf(card, NULL);
  431|    258|	LOG_TEST_RET(ctx, rv, "MF selection 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: 24, False: 234]
  |  |  |  |  ------------------
  |  |  |  |  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|    258|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 234]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  432|       |
  433|    234|	_sc_card_add_rsa_alg(card, 1024, flags, 0x10001);
  434|    234|	_sc_card_add_rsa_alg(card, 2048, flags, 0x10001);
  435|       |
  436|    234|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    234|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    234|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    234|	int _ret = r; \
  |  |  |  |  155|    234|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 234, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    234|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 234]
  |  |  |  |  ------------------
  |  |  |  |  157|    234|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    234|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    234|	return _ret; \
  |  |  |  |  163|    234|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  437|    234|}
card-authentic.c:authentic_select_mf:
  544|    258|{
  545|    258|	struct sc_context *ctx = card->ctx;
  546|    258|	struct sc_path mfpath;
  547|    258|	int rv;
  548|       |
  549|    258|	struct sc_apdu apdu;
  550|    258|	unsigned char rbuf[SC_MAX_APDU_BUFFER_SIZE];
  551|       |
  552|    258|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    258|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    258|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    258|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    258|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 258]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  553|       |
  554|    258|	sc_format_path("3F00", &mfpath);
  555|    258|	mfpath.type = SC_PATH_TYPE_PATH;
  ------------------
  |  |  119|    258|#define SC_PATH_TYPE_PATH		2
  ------------------
  556|       |
  557|    258|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xA4, 0x00, 0x00);
  ------------------
  |  |  292|    258|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  558|       |
  559|    258|	apdu.resp = rbuf;
  560|    258|	apdu.resplen = sizeof(rbuf);
  561|       |
  562|    258|	rv = sc_transmit_apdu(card, &apdu);
  563|    258|	LOG_TEST_RET(ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|    258|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    258|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    258|	int _ret = (r); \
  |  |  |  |  168|    258|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 257]
  |  |  |  |  ------------------
  |  |  |  |  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|    258|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 257]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  564|    257|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  565|    257|	LOG_TEST_RET(ctx, rv, "authentic_select_file() check SW failed");
  ------------------
  |  |  174|    257|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    257|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    257|	int _ret = (r); \
  |  |  |  |  168|    257|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 11, False: 246]
  |  |  |  |  ------------------
  |  |  |  |  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|    257|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 246]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  566|       |
  567|    246|	rv = authentic_set_current_files(card, &mfpath, apdu.resp, apdu.resplen, file_out);
  568|    246|	LOG_TEST_RET(ctx, rv, "authentic_select_file() cannot set 'current_file'");
  ------------------
  |  |  174|    246|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    246|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    246|	int _ret = (r); \
  |  |  |  |  168|    246|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 12, False: 234]
  |  |  |  |  ------------------
  |  |  |  |  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|    246|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 234]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  569|       |
  570|    234|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    234|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    234|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    234|	int _ret = r; \
  |  |  |  |  155|    234|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 234, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    234|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 234]
  |  |  |  |  ------------------
  |  |  |  |  157|    234|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    234|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    234|	return _ret; \
  |  |  |  |  163|    234|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  571|    234|}
card-authentic.c:authentic_set_current_files:
  505|  1.76k|{
  506|  1.76k|	struct sc_context *ctx = card->ctx;
  507|  1.76k|	struct sc_file *file = NULL;
  508|  1.76k|	int rv;
  509|       |
  510|  1.76k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  1.76k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.76k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.76k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.76k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.76k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  511|  1.76k|	if (resplen)   {
  ------------------
  |  Branch (511:6): [True: 708, False: 1.06k]
  ------------------
  512|    708|		switch (resp[0]) {
  513|     13|		case 0x62:
  ------------------
  |  Branch (513:3): [True: 13, False: 695]
  ------------------
  514|    685|		case 0x6F:
  ------------------
  |  Branch (514:3): [True: 672, False: 36]
  ------------------
  515|    685|			file = sc_file_new();
  516|    685|			if (file == NULL)
  ------------------
  |  Branch (516:8): [True: 0, False: 685]
  ------------------
  517|    685|				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|    685|			if (path)
  ------------------
  |  Branch (518:8): [True: 685, False: 0]
  ------------------
  519|    685|				file->path = *path;
  520|       |
  521|    685|			rv = authentic_process_fci(card, file, resp, resplen);
  522|    685|			if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|    685|#define SC_SUCCESS				0
  ------------------
  |  Branch (522:8): [True: 48, False: 637]
  ------------------
  523|     48|				sc_file_free(file);
  524|     48|				LOG_TEST_RET(ctx, rv, "cannot set 'current file': FCI process error");
  ------------------
  |  |  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: 48, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|     48|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  525|     48|			}
  526|       |
  527|    637|			break;
  528|    637|		default:
  ------------------
  |  Branch (528:3): [True: 23, False: 685]
  ------------------
  529|     23|			LOG_FUNC_RETURN(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|     23|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     23|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     23|	int _ret = r; \
  |  |  |  |  155|     23|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 23, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     23|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     23|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 23, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     23|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     23|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     23|	return _ret; \
  |  |  |  |  163|     23|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  530|    708|		}
  531|       |
  532|    637|		if (file_out)
  ------------------
  |  Branch (532:7): [True: 379, False: 258]
  ------------------
  533|    379|			*file_out = file;
  534|    258|		else
  535|    258|			sc_file_free(file);
  536|    637|	}
  537|       |
  538|  1.69k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  1.69k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.69k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.69k|	int _ret = r; \
  |  |  |  |  155|  1.69k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.69k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.69k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 1.69k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.69k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.69k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|  1.69k|	return _ret; \
  |  |  |  |  163|  1.69k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  539|  1.69k|}
card-authentic.c:authentic_get_serialnr:
 1464|    556|{
 1465|    556|	struct sc_context *ctx = card->ctx;
 1466|    556|	struct authentic_private_data *prv_data = (struct authentic_private_data *) card->drv_data;
 1467|    556|	int rv;
 1468|       |
 1469|    556|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    556|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    556|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    556|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    556|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 556]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1470|    556|	if (!card->serialnr.len)   {
  ------------------
  |  Branch (1470:6): [True: 462, False: 94]
  ------------------
 1471|    462|		rv = authentic_get_cplc(card);
 1472|    462|		LOG_TEST_RET(ctx, rv, "get CPLC data error");
  ------------------
  |  |  174|    462|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    462|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    462|	int _ret = (r); \
  |  |  |  |  168|    462|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 219, False: 243]
  |  |  |  |  ------------------
  |  |  |  |  169|    219|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    219|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    219|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    219|		return _ret; \
  |  |  |  |  172|    219|	} \
  |  |  |  |  173|    462|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 243]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1473|       |
 1474|    243|		card->serialnr.len = 4;
 1475|    243|		memcpy(card->serialnr.value, prv_data->cplc.value + 15, 4);
 1476|       |
 1477|    243|		sc_log(ctx, "serial %02X%02X%02X%02X",
  ------------------
  |  |   71|    243|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1478|    243|				card->serialnr.value[0], card->serialnr.value[1],
 1479|    243|				card->serialnr.value[2], card->serialnr.value[3]);
 1480|    243|	}
 1481|       |
 1482|    337|	if (serial)
  ------------------
  |  Branch (1482:6): [True: 175, False: 162]
  ------------------
 1483|    175|		memcpy(serial, &card->serialnr, sizeof(*serial));
 1484|       |
 1485|    337|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    337|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    337|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    337|	int _ret = r; \
  |  |  |  |  155|    337|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 337, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 337]
  |  |  |  |  ------------------
  |  |  |  |  157|    337|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    337|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    337|	return _ret; \
  |  |  |  |  163|    337|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1486|    337|}
card-authentic.c:authentic_get_cplc:
  360|    462|{
  361|    462|	struct authentic_private_data *prv_data = (struct authentic_private_data *) card->drv_data;
  362|    462|	struct sc_apdu apdu;
  363|    462|	int rv, ii;
  364|    462|	unsigned char p1, p2;
  365|       |
  366|    462|	p1 = (SC_CPLC_TAG >> 8) & 0xFF;
  ------------------
  |  |  345|    462|#define SC_CPLC_TAG		0x9F7F
  ------------------
  367|    462|	p2 = SC_CPLC_TAG & 0xFF;
  ------------------
  |  |  345|    462|#define SC_CPLC_TAG		0x9F7F
  ------------------
  368|    462|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xCA, p1, p2);
  ------------------
  |  |  292|    462|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  369|    467|	for (ii=0;ii<2;ii++)   {
  ------------------
  |  Branch (369:12): [True: 466, False: 1]
  ------------------
  370|    466|		apdu.le = SC_CPLC_DER_SIZE;
  ------------------
  |  |  346|    466|#define SC_CPLC_DER_SIZE	45
  ------------------
  371|    466|		apdu.resplen = sizeof(prv_data->cplc.value);
  372|    466|		apdu.resp = prv_data->cplc.value;
  373|       |
  374|    466|		rv = sc_transmit_apdu(card, &apdu);
  375|    466|		LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|    466|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    466|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    466|	int _ret = (r); \
  |  |  |  |  168|    466|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 463]
  |  |  |  |  ------------------
  |  |  |  |  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|    466|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 463]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  376|    463|		rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  377|    463|		if (rv != SC_ERROR_CLASS_NOT_SUPPORTED)
  ------------------
  |  |   53|    463|#define SC_ERROR_CLASS_NOT_SUPPORTED		-1203
  ------------------
  |  Branch (377:7): [True: 458, False: 5]
  ------------------
  378|    458|			break;
  379|       |
  380|      5|		apdu.cla = 0x80;
  381|      5|	}
  382|    459|        LOG_TEST_RET(card->ctx, rv, "'GET CPLC' error");
  ------------------
  |  |  174|    459|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    459|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    459|	int _ret = (r); \
  |  |  |  |  168|    459|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 216, False: 243]
  |  |  |  |  ------------------
  |  |  |  |  169|    216|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    216|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    216|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    216|		return _ret; \
  |  |  |  |  172|    216|	} \
  |  |  |  |  173|    459|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 243]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  383|       |
  384|    243|	prv_data->cplc.len = SC_CPLC_DER_SIZE;
  ------------------
  |  |  346|    243|#define SC_CPLC_DER_SIZE	45
  ------------------
  385|    243|	return SC_SUCCESS;
  ------------------
  |  |   28|    243|#define SC_SUCCESS				0
  ------------------
  386|    459|}
card-authentic.c:authentic_finish:
 1847|    396|{
 1848|    396|	struct sc_context *ctx = card->ctx;
 1849|       |
 1850|    396|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    396|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    396|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    396|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    396|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 396]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1851|       |
 1852|    396|#ifdef ENABLE_SM
 1853|    396|	if (card->sm_ctx.ops.close)
  ------------------
  |  Branch (1853:6): [True: 0, False: 396]
  ------------------
 1854|      0|		card->sm_ctx.ops.close(card);
 1855|    396|#endif
 1856|       |
 1857|    396|	if (card->drv_data)
  ------------------
  |  Branch (1857:6): [True: 396, False: 0]
  ------------------
 1858|    396|		free(card->drv_data);
 1859|    396|	card->drv_data = NULL;
 1860|    396|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    396|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    396|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    396|	int _ret = r; \
  |  |  |  |  155|    396|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 396, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    396|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 396]
  |  |  |  |  ------------------
  |  |  |  |  157|    396|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    396|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    396|	return _ret; \
  |  |  |  |  163|    396|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1861|    396|}
card-authentic.c:authentic_read_binary:
  643|     86|{
  644|     86|	struct sc_context *ctx = card->ctx;
  645|     86|	struct sc_apdu apdu;
  646|     86|	size_t sz, rest, ret_count = 0;
  647|     86|	int rv = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|     86|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  648|       |
  649|     86|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     86|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     86|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     86|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     86|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 86]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  650|     86|	sc_log(ctx, "offs:%i,count:%zu,max_recv_size:%zu", idx, count, card->max_recv_size);
  ------------------
  |  |   71|     86|#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|       |
  652|     86|	rest = count;
  653|  1.64k|	while(rest)   {
  ------------------
  |  Branch (653:8): [True: 1.56k, False: 78]
  ------------------
  654|  1.56k|		sz = rest > 256 ? 256 : rest;
  ------------------
  |  Branch (654:8): [True: 1.48k, False: 78]
  ------------------
  655|  1.56k|		sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xB0, (idx >> 8) & 0x7F, idx & 0xFF);
  ------------------
  |  |  292|  1.56k|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  656|  1.56k|		apdu.le = sz;
  657|  1.56k|		apdu.resplen = sz;
  658|  1.56k|		apdu.resp = (buf + ret_count);
  659|       |
  660|  1.56k|		rv = sc_transmit_apdu(card, &apdu);
  661|  1.56k|		if(!rv)
  ------------------
  |  Branch (661:6): [True: 1.55k, False: 8]
  ------------------
  662|  1.55k|			ret_count += apdu.resplen;
  663|      8|		else
  664|      8|			break;
  665|       |
  666|  1.55k|		idx += sz;
  667|  1.55k|		rest -= sz;
  668|  1.55k|	}
  669|       |
  670|     86|	if (rv)   {
  ------------------
  |  Branch (670:6): [True: 8, False: 78]
  ------------------
  671|      8|		LOG_TEST_RET(ctx, SC_ERROR_INTERNAL, "authentic_read_binary() failed");
  ------------------
  |  |  174|      8|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      8|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      8|	int _ret = (r); \
  |  |  |  |  168|      8|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 8, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      8|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      8|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      8|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      8|		return _ret; \
  |  |  |  |  172|      8|	} \
  |  |  |  |  173|      8|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  672|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  673|      0|	}
  674|       |
  675|     78|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  676|     78|	if (!rv)
  ------------------
  |  Branch (676:6): [True: 56, False: 22]
  ------------------
  677|     56|		count = ret_count;
  678|       |
  679|     78|	LOG_TEST_RET(ctx, rv, "authentic_read_binary() failed");
  ------------------
  |  |  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: 22, False: 56]
  |  |  |  |  ------------------
  |  |  |  |  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|     78|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 56]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  680|     56|	LOG_FUNC_RETURN(ctx, (int)count);
  ------------------
  |  |  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: 3, False: 53]
  |  |  |  |  ------------------
  |  |  |  |  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|     53|	} else { \
  |  |  |  |  159|     53|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     53|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     53|	} \
  |  |  |  |  162|     56|	return _ret; \
  |  |  |  |  163|     56|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  681|     56|}
card-authentic.c:authentic_update_binary:
  728|     44|{
  729|     44|	struct sc_context *ctx = card->ctx;
  730|     44|	struct sc_apdu apdu;
  731|     44|	size_t sz, rest;
  732|     44|	int rv = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|     44|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  733|       |
  734|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  735|     44|	sc_log(ctx, "offs:%i,count:%zu,max_send_size:%zu", idx, count, card->max_send_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__
  |  |  ------------------
  ------------------
  736|       |
  737|     44|	rest = count;
  738|  1.03k|	while(rest)   {
  ------------------
  |  Branch (738:8): [True: 996, False: 39]
  ------------------
  739|    996|		sz = rest > 255 ? 255 : rest;
  ------------------
  |  Branch (739:8): [True: 957, False: 39]
  ------------------
  740|    996|		sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xD6, (idx >> 8) & 0x7F, idx & 0xFF);
  ------------------
  |  |  293|    996|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  741|    996|		apdu.lc = sz;
  742|    996|		apdu.datalen = sz;
  743|    996|		apdu.data = buf + count - rest;
  744|       |
  745|    996|		rv = sc_transmit_apdu(card, &apdu);
  746|    996|		if(rv)
  ------------------
  |  Branch (746:6): [True: 5, False: 991]
  ------------------
  747|      5|			break;
  748|       |
  749|    991|		idx += sz;
  750|    991|		rest -= sz;
  751|    991|	}
  752|       |
  753|     44|	if (rv)
  ------------------
  |  Branch (753:6): [True: 5, False: 39]
  ------------------
  754|      5|	{
  755|      5|		LOG_TEST_RET(ctx, SC_ERROR_INTERNAL, "authentic_update_binary() 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  756|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  757|      0|	}
  758|       |
  759|     39|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  760|       |
  761|     39|	LOG_TEST_RET(ctx, rv, "authentic_update_binary() failed");
  ------------------
  |  |  174|     39|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     39|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     39|	int _ret = (r); \
  |  |  |  |  168|     39|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 20, False: 19]
  |  |  |  |  ------------------
  |  |  |  |  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|     39|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 19]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  762|     19|	LOG_FUNC_RETURN(ctx, (int)count);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  763|     19|}
card-authentic.c:authentic_erase_binary:
  482|     39|{
  483|     39|	struct sc_context *ctx = card->ctx;
  484|     39|	int rv;
  485|     39|	unsigned char *buf_zero = NULL;
  486|       |
  487|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  488|     39|	if (!count)
  ------------------
  |  Branch (488:6): [True: 0, False: 39]
  ------------------
  489|     39|		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|     39|	buf_zero = calloc(1, count);
  492|     39|	if (!buf_zero)
  ------------------
  |  Branch (492:6): [True: 0, False: 39]
  ------------------
  493|     39|		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|     39|	rv = sc_update_binary(card, offs, buf_zero, count, flags);
  496|     39|	free(buf_zero);
  497|       |
  498|     39|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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: 21, False: 18]
  |  |  |  |  ------------------
  |  |  |  |  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|     20|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 20, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|     21|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     21|	} 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|     39|	return _ret; \
  |  |  |  |  163|     39|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  499|     39|}
card-authentic.c:authentic_select_file:
  576|  4.11k|{
  577|  4.11k|	struct sc_context *ctx = card->ctx;
  578|  4.11k|	struct sc_apdu apdu;
  579|  4.11k|	struct sc_path lpath;
  580|  4.11k|	unsigned char rbuf[SC_MAX_APDU_BUFFER_SIZE];
  581|  4.11k|	size_t pathlen;
  582|  4.11k|	int rv;
  583|       |
  584|  4.11k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  4.11k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  4.11k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  4.11k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  4.11k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 4.11k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  585|       |
  586|  4.11k|	memcpy(&lpath, path, sizeof(struct sc_path));
  587|       |
  588|  4.11k|	if (lpath.type == SC_PATH_TYPE_PATH && (lpath.len == 2))
  ------------------
  |  |  119|  8.23k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (588:6): [True: 2.49k, False: 1.62k]
  |  Branch (588:41): [True: 325, False: 2.16k]
  ------------------
  589|    325|		lpath.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|    325|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  590|       |
  591|  4.11k|	pathlen = lpath.len;
  592|  4.11k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0x00, 0x00);
  ------------------
  |  |  294|  4.11k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  593|       |
  594|  4.11k|	if (card->type != SC_CARD_TYPE_OBERTHUR_AUTHENTIC_3_2)
  ------------------
  |  Branch (594:6): [True: 0, False: 4.11k]
  ------------------
  595|  4.11k|		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|  4.11k|	if (lpath.type == SC_PATH_TYPE_FILE_ID)   {
  ------------------
  |  |  117|  4.11k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (597:6): [True: 424, False: 3.69k]
  ------------------
  598|    424|		apdu.p1 = 0x00;
  599|    424|	}
  600|  3.69k|	else if (lpath.type == SC_PATH_TYPE_PATH)  {
  ------------------
  |  |  119|  3.69k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (600:11): [True: 2.16k, False: 1.52k]
  ------------------
  601|  2.16k|		apdu.p1 = 0x08;
  602|  2.16k|	}
  603|  1.52k|	else if (lpath.type == SC_PATH_TYPE_FROM_CURRENT)  {
  ------------------
  |  |  122|  1.52k|#define SC_PATH_TYPE_FROM_CURRENT	4
  ------------------
  |  Branch (603:11): [True: 0, False: 1.52k]
  ------------------
  604|      0|		apdu.p1 = 0x09;
  605|      0|	}
  606|  1.52k|	else if (lpath.type == SC_PATH_TYPE_DF_NAME)   {
  ------------------
  |  |  118|  1.52k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (606:11): [True: 1.52k, False: 0]
  ------------------
  607|  1.52k|		apdu.p1 = 4;
  608|  1.52k|	}
  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|  4.11k|	apdu.lc = pathlen;
  620|  4.11k|	apdu.data = lpath.value;
  621|  4.11k|	apdu.datalen = pathlen;
  622|       |
  623|  4.11k|	if (apdu.cse == SC_APDU_CASE_4_SHORT || apdu.cse == SC_APDU_CASE_2_SHORT)   {
  ------------------
  |  |  294|  8.23k|#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: 4.11k, False: 0]
  |  Branch (623:42): [True: 0, False: 0]
  ------------------
  624|  4.11k|		apdu.resp = rbuf;
  625|  4.11k|		apdu.resplen = sizeof(rbuf);
  626|  4.11k|		apdu.le = 256;
  627|  4.11k|	}
  628|       |
  629|  4.11k|	rv = sc_transmit_apdu(card, &apdu);
  630|  4.11k|	LOG_TEST_RET(ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|  4.11k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  4.11k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  4.11k|	int _ret = (r); \
  |  |  |  |  168|  4.11k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 42, False: 4.07k]
  |  |  |  |  ------------------
  |  |  |  |  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|  4.11k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4.07k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  631|  4.07k|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  632|  4.07k|	LOG_TEST_RET(ctx, rv, "authentic_select_file() check SW failed");
  ------------------
  |  |  174|  4.07k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  4.07k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  4.07k|	int _ret = (r); \
  |  |  |  |  168|  4.07k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2.55k, False: 1.52k]
  |  |  |  |  ------------------
  |  |  |  |  169|  2.55k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.55k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  2.55k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  2.55k|		return _ret; \
  |  |  |  |  172|  2.55k|	} \
  |  |  |  |  173|  4.07k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.52k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  633|       |
  634|  1.52k|	rv = authentic_set_current_files(card, &lpath, apdu.resp, apdu.resplen, file_out);
  635|  1.52k|	LOG_TEST_RET(ctx, rv, "authentic_select_file() cannot set 'current_file'");
  ------------------
  |  |  174|  1.52k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.52k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.52k|	int _ret = (r); \
  |  |  |  |  168|  1.52k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 59, False: 1.46k]
  |  |  |  |  ------------------
  |  |  |  |  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.52k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.46k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  636|       |
  637|  1.46k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  1.46k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.46k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.46k|	int _ret = r; \
  |  |  |  |  155|  1.46k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.46k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 1.46k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.46k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.46k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|  1.46k|	return _ret; \
  |  |  |  |  163|  1.46k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  638|  1.46k|}
card-authentic.c:authentic_get_challenge:
 1491|     26|{
 1492|       |	/* 'GET CHALLENGE' returns always 24 bytes */
 1493|     26|	unsigned char rbuf[0x18];
 1494|     26|	size_t out_len;
 1495|     26|	int r;
 1496|       |
 1497|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1498|       |
 1499|     26|	r = iso_ops->get_challenge(card, rbuf, sizeof rbuf);
 1500|     26|	LOG_TEST_RET(card->ctx, r, "GET CHALLENGE cmd 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: 6, False: 20]
  |  |  |  |  ------------------
  |  |  |  |  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|     26|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1501|       |
 1502|     20|	if (len < (size_t) r) {
  ------------------
  |  Branch (1502:6): [True: 6, False: 14]
  ------------------
 1503|      6|		out_len = len;
 1504|     14|	} else {
 1505|     14|		out_len = (size_t) r;
 1506|     14|	}
 1507|     20|	memcpy(rnd, rbuf, out_len);
 1508|       |
 1509|     20|	LOG_FUNC_RETURN(card->ctx, (int)out_len);
  ------------------
  |  |  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: 2, False: 18]
  |  |  |  |  ------------------
  |  |  |  |  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|     18|	} 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|     20|	return _ret; \
  |  |  |  |  163|     20|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1510|     20|}
card-authentic.c:authentic_create_file:
  906|      5|{
  907|      5|	struct sc_context *ctx = card->ctx;
  908|      5|	struct sc_apdu apdu;
  909|      5|	unsigned char sbuf[0x100];
  910|      5|	size_t sbuf_len;
  911|      5|	struct sc_path path;
  912|      5|	int rv;
  913|       |
  914|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  915|       |
  916|      5|	if (file->type != SC_FILE_TYPE_WORKING_EF)
  ------------------
  |  |  216|      5|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (916:6): [True: 1, False: 4]
  ------------------
  917|      5|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  918|       |
  919|      4|	rv = authentic_fcp_encode(card, file, sbuf + 2, sizeof(sbuf)-2);
  920|      4|	LOG_TEST_RET(ctx, rv, "FCP encode 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  921|      3|	sbuf_len = rv;
  922|       |
  923|      3|	sbuf[0] = ISO7816_TAG_FCP;
  ------------------
  |  |   17|      3|#define ISO7816_TAG_FCP			0x62
  ------------------
  924|      3|	sbuf[1] = sbuf_len;
  925|       |
  926|      3|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE0, 0, 0);
  ------------------
  |  |  293|      3|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  927|      3|	apdu.data = sbuf;
  928|      3|	apdu.datalen = sbuf_len + 2;
  929|      3|	apdu.lc = sbuf_len + 2;
  930|       |
  931|      3|	rv = sc_transmit_apdu(card, &apdu);
  932|      3|	LOG_TEST_RET(ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|      3|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      3|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      3|	int _ret = (r); \
  |  |  |  |  168|      3|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      3|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  933|      2|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  934|      2|	LOG_TEST_RET(ctx, rv, "authentic_create_file() create file error");
  ------------------
  |  |  174|      2|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      2|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      2|	int _ret = (r); \
  |  |  |  |  168|      2|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  935|       |
  936|      1|	path = file->path;
  937|      1|	memcpy(path.value, path.value + path.len - 2, 2);
  938|      1|	path.len = 2;
  939|      1|	rv = authentic_set_current_files(card, &path, sbuf, sbuf_len + 2, NULL);
  940|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  941|       |
  942|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  943|      1|}
card-authentic.c:authentic_fcp_encode:
  840|      4|{
  841|      4|	struct sc_context *ctx = card->ctx;
  842|      4|	unsigned char buf[0x80];
  843|      4|	size_t ii, offs;
  844|      4|	unsigned char ops_ef[4] = { SC_AC_OP_READ, SC_AC_OP_DELETE, SC_AC_OP_UPDATE, SC_AC_OP_RESIZE };
  ------------------
  |  |  188|      4|#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|      4|#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|      4|#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|      4|#define SC_AC_OP_RESIZE			25
  ------------------
  845|      4|	unsigned char ops_df[3] = { SC_AC_OP_CREATE, SC_AC_OP_DELETE, SC_AC_OP_CRYPTO };
  ------------------
  |  |  169|      4|#define SC_AC_OP_CREATE			3
  ------------------
              	unsigned char ops_df[3] = { SC_AC_OP_CREATE, SC_AC_OP_DELETE, SC_AC_OP_CRYPTO };
  ------------------
  |  |  168|      4|#define SC_AC_OP_DELETE			2
  ------------------
              	unsigned char ops_df[3] = { SC_AC_OP_CREATE, SC_AC_OP_DELETE, SC_AC_OP_CRYPTO };
  ------------------
  |  |  173|      4|#define SC_AC_OP_CRYPTO			7
  ------------------
  846|      4|	unsigned char *ops = file->type == SC_FILE_TYPE_DF ? ops_df : ops_ef;
  ------------------
  |  |  214|      4|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (846:23): [True: 0, False: 4]
  ------------------
  847|      4|	size_t ops_len = file->type == SC_FILE_TYPE_DF ? 3 : 4;
  ------------------
  |  |  214|      4|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (847:19): [True: 0, False: 4]
  ------------------
  848|       |
  849|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  850|       |
  851|      4|	offs = 0;
  852|      4|	buf[offs++] = ISO7816_TAG_FCP_SIZE;
  ------------------
  |  |   18|      4|#define ISO7816_TAG_FCP_SIZE		0x80
  ------------------
  853|      4|	buf[offs++] = 2;
  854|      4|	buf[offs++] = (file->size >> 8) & 0xFF;
  855|      4|	buf[offs++] = file->size & 0xFF;
  856|       |
  857|      4|	buf[offs++] = ISO7816_TAG_FCP_TYPE;
  ------------------
  |  |   20|      4|#define ISO7816_TAG_FCP_TYPE		0x82
  ------------------
  858|      4|	buf[offs++] = 1;
  859|      4|	buf[offs++] = file->type == SC_FILE_TYPE_DF ? ISO7816_FILE_TYPE_DF : ISO7816_FILE_TYPE_TRANSPARENT_EF;
  ------------------
  |  |  214|      4|#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|      8|#define ISO7816_FILE_TYPE_TRANSPARENT_EF	0x01
  ------------------
  |  Branch (859:16): [True: 0, False: 4]
  ------------------
  860|       |
  861|      4|	buf[offs++] = ISO7816_TAG_FCP_FID;
  ------------------
  |  |   21|      4|#define ISO7816_TAG_FCP_FID		0x83
  ------------------
  862|      4|	buf[offs++] = 2;
  863|      4|	buf[offs++] = (file->id >> 8) & 0xFF;
  864|      4|	buf[offs++] = file->id & 0xFF;
  865|       |
  866|      4|	buf[offs++] = ISO7816_TAG_FCP_ACLS;
  ------------------
  |  |   24|      4|#define ISO7816_TAG_FCP_ACLS		0x86
  ------------------
  867|      4|	buf[offs++] = ops_len * 2;
  868|     17|	for (ii=0; ii < ops_len; ii++) {
  ------------------
  |  Branch (868:13): [True: 14, False: 3]
  ------------------
  869|     14|		const struct sc_acl_entry *entry;
  870|       |
  871|     14|		entry = sc_file_get_acl_entry(file, ops[ii]);
  872|     14|		sc_log(ctx, "acl entry(method:%X,ref:%X)", entry->method, entry->key_ref);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  873|       |
  874|     14|		if (entry->method == SC_AC_NEVER)   {
  ------------------
  |  |  163|     14|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (874:7): [True: 1, False: 13]
  ------------------
  875|       |			/* TODO: After development change for 0xFF */
  876|      1|			buf[offs++] = 0x00;
  877|      1|			buf[offs++] = 0x00;
  878|      1|		}
  879|     13|		else if (entry->method == SC_AC_NONE)   {
  ------------------
  |  |  150|     13|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (879:12): [True: 12, False: 1]
  ------------------
  880|     12|			buf[offs++] = 0x00;
  881|     12|			buf[offs++] = 0x00;
  882|     12|		}
  883|      1|		else if (entry->method == SC_AC_CHV)   {
  ------------------
  |  |  151|      1|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (883:12): [True: 0, False: 1]
  ------------------
  884|      0|			if (!(entry->key_ref & AUTHENTIC_V3_CREDENTIAL_ID_MASK)
  ------------------
  |  |   38|      0|#define AUTHENTIC_V3_CREDENTIAL_ID_MASK	7
  ------------------
  |  Branch (884:8): [True: 0, False: 0]
  ------------------
  885|      0|					|| (entry->key_ref & ~AUTHENTIC_V3_CREDENTIAL_ID_MASK))
  ------------------
  |  |   38|      0|#define AUTHENTIC_V3_CREDENTIAL_ID_MASK	7
  ------------------
  |  Branch (885:9): [True: 0, False: 0]
  ------------------
  886|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  887|      0|			buf[offs++] = 0x00;
  888|      0|			buf[offs++] = 0x01 << (entry->key_ref - 1);
  889|      0|		}
  890|      1|		else
  891|      1|			LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Non supported AC method");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  892|     14|	}
  893|       |
  894|      3|	if (out)   {
  ------------------
  |  Branch (894:6): [True: 3, False: 0]
  ------------------
  895|      3|		if (out_len < offs)
  ------------------
  |  Branch (895:7): [True: 0, False: 3]
  ------------------
  896|      3|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  897|      3|		memcpy(out, buf, offs);
  898|      3|	}
  899|       |
  900|      3|	LOG_FUNC_RETURN(ctx, (int)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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  901|      3|}
card-authentic.c:authentic_delete_file:
  948|      4|{
  949|      4|	struct sc_context *ctx = card->ctx;
  950|      4|	struct sc_apdu apdu;
  951|      4|	unsigned char p1;
  952|      4|	int rv, ii;
  953|       |
  954|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  955|       |
  956|      4|	if (!path)
  ------------------
  |  Branch (956:6): [True: 0, False: 4]
  ------------------
  957|      4|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  958|       |
  959|      5|	for (ii=0, p1 = 0x02; ii<2; ii++, p1 = 0x01)   {
  ------------------
  |  Branch (959:24): [True: 5, False: 0]
  ------------------
  960|      5|		sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE4, p1, 0x00);
  ------------------
  |  |  293|      5|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  961|      5|		apdu.data = path->value + path->len - 2;
  962|      5|		apdu.datalen = 2;
  963|      5|		apdu.lc = 2;
  964|       |
  965|      5|		rv = sc_transmit_apdu(card, &apdu);
  966|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  967|      4|		rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  968|      4|		if (rv != SC_ERROR_FILE_NOT_FOUND || p1 != 0x02)
  ------------------
  |  |   51|      8|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (968:7): [True: 3, False: 1]
  |  Branch (968:40): [True: 0, False: 1]
  ------------------
  969|      3|			break;
  970|      4|	}
  971|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  972|       |
  973|      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|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  974|      2|}
card-authentic.c:authentic_card_ctl:
 1738|    800|{
 1739|    800|	struct sc_context *ctx = card->ctx;
 1740|    800|	struct sc_authentic_sdo *sdo = (struct sc_authentic_sdo *) ptr;
 1741|       |
 1742|    800|	switch (cmd) {
  ------------------
  |  Branch (1742:10): [True: 395, False: 405]
  ------------------
 1743|    363|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (1743:2): [True: 363, False: 437]
  ------------------
 1744|    363|		return authentic_get_serialnr(card, (struct sc_serial_number *)ptr);
 1745|     31|	case SC_CARDCTL_AUTHENTIC_SDO_CREATE:
  ------------------
  |  Branch (1745:2): [True: 31, False: 769]
  ------------------
 1746|     31|		sc_log(ctx, "CARDCTL SDO_CREATE: sdo(mech:%X,id:%X)", sdo->docp.mech, sdo->docp.id);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1747|     31|		return authentic_manage_sdo(card, (struct sc_authentic_sdo *) ptr, cmd);
 1748|      1|	case SC_CARDCTL_AUTHENTIC_SDO_DELETE:
  ------------------
  |  Branch (1748:2): [True: 1, False: 799]
  ------------------
 1749|      1|		sc_log(ctx, "CARDCTL SDO_DELETE: sdo(mech:%X,id:%X)", sdo->docp.mech, sdo->docp.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__
  |  |  ------------------
  ------------------
 1750|      1|		return authentic_manage_sdo(card, (struct sc_authentic_sdo *) ptr, cmd);
 1751|      0|	case SC_CARDCTL_AUTHENTIC_SDO_STORE:
  ------------------
  |  Branch (1751:2): [True: 0, False: 800]
  ------------------
 1752|      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__
  |  |  ------------------
  ------------------
 1753|      0|		return authentic_manage_sdo(card, (struct sc_authentic_sdo *) ptr, cmd);
 1754|      0|	case SC_CARDCTL_AUTHENTIC_SDO_GENERATE:
  ------------------
  |  Branch (1754:2): [True: 0, False: 800]
  ------------------
 1755|      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__
  |  |  ------------------
  ------------------
 1756|      0|		return authentic_manage_sdo_generate(card, (struct sc_authentic_sdo *) ptr);
 1757|    800|	}
 1758|    405|	return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    405|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1759|    800|}
card-authentic.c:authentic_manage_sdo:
 1699|     32|{
 1700|     32|	struct sc_context *ctx = card->ctx;
 1701|     32|	struct sc_apdu apdu;
 1702|     32|	unsigned char *data = NULL;
 1703|     32|	size_t data_len = 0, save_max_send = card->max_send_size;
 1704|     32|	int rv;
 1705|       |
 1706|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1707|     32|	sc_log(ctx, "SDO(cmd:%lX,mech:%X,id:%X)", cmd, sdo->docp.mech, sdo->docp.id);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1708|       |
 1709|     32|	rv = authentic_manage_sdo_encode(card, sdo, cmd, &data, &data_len);
 1710|     32|	LOG_TEST_RET(ctx, rv, "Cannot encode SDO data");
  ------------------
  |  |  174|     32|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     32|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     32|	int _ret = (r); \
  |  |  |  |  168|     32|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 32]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|     32|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 32]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1711|     32|	sc_log(ctx, "encoded SDO length %zu", data_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__
  |  |  ------------------
  ------------------
 1712|       |
 1713|     32|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xDB, 0x3F, 0xFF);
  ------------------
  |  |  293|     32|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1714|     32|	apdu.data = data;
 1715|     32|	apdu.datalen = data_len;
 1716|     32|	apdu.lc = data_len;
 1717|     32|	apdu.flags |= SC_APDU_FLAGS_CHAINING;
  ------------------
  |  |  306|     32|#define SC_APDU_FLAGS_CHAINING		0x00000001UL
  ------------------
 1718|       |
 1719|     32|	if (card->max_send_size > 255)
  ------------------
  |  Branch (1719:6): [True: 32, False: 0]
  ------------------
 1720|     32|		card->max_send_size = 255;
 1721|       |
 1722|     32|	rv = sc_transmit_apdu(card, &apdu);
 1723|     32|	card->max_send_size = save_max_send;
 1724|     32|	free(data);
 1725|     32|	if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|     32|#define SC_SUCCESS				0
  ------------------
  |  Branch (1725:6): [True: 2, False: 30]
  ------------------
 1726|      2|		LOG_TEST_RET(ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|      2|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      2|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      2|	int _ret = (r); \
  |  |  |  |  168|      2|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      2|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      2|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      2|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      2|		return _ret; \
  |  |  |  |  172|      2|	} \
  |  |  |  |  173|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1727|      2|	}
 1728|       |
 1729|     30|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1730|     30|	LOG_TEST_RET(ctx, rv, "authentic_sdo_create() SDO put 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: 12, False: 18]
  |  |  |  |  ------------------
  |  |  |  |  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|     30|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 18]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1731|       |
 1732|     18|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 18]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1733|     18|}
card-authentic.c:authentic_manage_sdo_encode:
 1581|     32|{
 1582|     32|	struct sc_context *ctx = card->ctx;
 1583|     32|	unsigned char *data = NULL;
 1584|     32|	size_t data_len = 0;
 1585|     32|	unsigned char data_tag = AUTHENTIC_TAG_DOCP;
  ------------------
  |  |   72|     32|#define AUTHENTIC_TAG_DOCP			0xA1
  ------------------
 1586|     32|	int rv;
 1587|       |
 1588|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1589|     32|	sc_log(ctx, "encode SDO operation (cmd:%lX,mech:%X,id:%X)", cmd, sdo->docp.mech, sdo->docp.id);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1590|       |
 1591|     32|	if (!out || !out_len)
  ------------------
  |  Branch (1591:6): [True: 0, False: 32]
  |  Branch (1591:14): [True: 0, False: 32]
  ------------------
 1592|     32|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1593|       |
 1594|     32|	rv = authentic_update_blob(ctx, AUTHENTIC_TAG_DOCP_MECH, &sdo->docp.mech, sizeof(sdo->docp.mech),
  ------------------
  |  |   73|     32|#define AUTHENTIC_TAG_DOCP_MECH			0x80
  ------------------
 1595|     32|			&data, &data_len);
 1596|     32|	LOG_TEST_GOTO_ERR(ctx, rv, "DOCP MECH encode error");
  ------------------
  |  |  184|     32|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     32|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     32|	int _ret = (r); \
  |  |  |  |  178|     32|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 32]
  |  |  |  |  ------------------
  |  |  |  |  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|     32|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 32]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1597|       |
 1598|     32|	rv = authentic_update_blob(ctx, AUTHENTIC_TAG_DOCP_ID, &sdo->docp.id, sizeof(sdo->docp.id),
  ------------------
  |  |   74|     32|#define AUTHENTIC_TAG_DOCP_ID			0x83
  ------------------
 1599|     32|			&data, &data_len);
 1600|     32|	LOG_TEST_GOTO_ERR(ctx, rv, "DOCP ID encode error");
  ------------------
  |  |  184|     32|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     32|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     32|	int _ret = (r); \
  |  |  |  |  178|     32|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 32]
  |  |  |  |  ------------------
  |  |  |  |  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|     32|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 32]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1601|       |
 1602|     32|	if (cmd == SC_CARDCTL_AUTHENTIC_SDO_CREATE)   {
  ------------------
  |  Branch (1602:6): [True: 31, False: 1]
  ------------------
 1603|     31|		rv = authentic_update_blob(ctx, AUTHENTIC_TAG_DOCP_ACLS, sdo->docp.acl_data, sdo->docp.acl_data_len,
  ------------------
  |  |   75|     31|#define AUTHENTIC_TAG_DOCP_ACLS			0x86
  ------------------
 1604|     31|				&data, &data_len);
 1605|     31|		LOG_TEST_GOTO_ERR(ctx, rv, "DOCP ACLs encode error");
  ------------------
  |  |  184|     31|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     31|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     31|	int _ret = (r); \
  |  |  |  |  178|     31|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 31]
  |  |  |  |  ------------------
  |  |  |  |  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|     31|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 31]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1606|       |
 1607|     31|		if (sdo->docp.security_parameter)  {
  ------------------
  |  Branch (1607:7): [True: 0, False: 31]
  ------------------
 1608|      0|			rv = authentic_update_blob(ctx, AUTHENTIC_TAG_DOCP_SCP,
  ------------------
  |  |   76|      0|#define AUTHENTIC_TAG_DOCP_SCP			0x87
  ------------------
 1609|      0|					&sdo->docp.security_parameter, sizeof(sdo->docp.security_parameter),
 1610|      0|					&data, &data_len);
 1611|      0|			LOG_TEST_GOTO_ERR(ctx, rv, "DOCP ACLs encode 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1612|      0|		}
 1613|     31|		if (sdo->docp.usage_counter[0] || sdo->docp.usage_counter[1])  {
  ------------------
  |  Branch (1613:7): [True: 0, False: 31]
  |  Branch (1613:37): [True: 0, False: 31]
  ------------------
 1614|      0|			rv = authentic_update_blob(ctx, AUTHENTIC_TAG_DOCP_USAGE_COUNTER,
  ------------------
  |  |   77|      0|#define AUTHENTIC_TAG_DOCP_USAGE_COUNTER	0x90
  ------------------
 1615|      0|					sdo->docp.usage_counter, sizeof(sdo->docp.usage_counter),
 1616|      0|					&data, &data_len);
 1617|      0|			LOG_TEST_GOTO_ERR(ctx, rv, "DOCP ACLs encode 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1618|      0|		}
 1619|     31|	}
 1620|      1|	else if (cmd == SC_CARDCTL_AUTHENTIC_SDO_STORE)   {
  ------------------
  |  Branch (1620:11): [True: 0, False: 1]
  ------------------
 1621|      0|		if (sdo->docp.mech == AUTHENTIC_MECH_CRYPTO_RSA1024
  ------------------
  |  |   66|      0|#define AUTHENTIC_MECH_CRYPTO_RSA1024	0x08
  ------------------
  |  Branch (1621:7): [True: 0, False: 0]
  ------------------
 1622|      0|				|| sdo->docp.mech == AUTHENTIC_MECH_CRYPTO_RSA1280
  ------------------
  |  |   67|      0|#define AUTHENTIC_MECH_CRYPTO_RSA1280	0x09
  ------------------
  |  Branch (1622:8): [True: 0, False: 0]
  ------------------
 1623|      0|				|| sdo->docp.mech == AUTHENTIC_MECH_CRYPTO_RSA1536
  ------------------
  |  |   68|      0|#define AUTHENTIC_MECH_CRYPTO_RSA1536	0x0A
  ------------------
  |  Branch (1623:8): [True: 0, False: 0]
  ------------------
 1624|      0|				|| sdo->docp.mech == AUTHENTIC_MECH_CRYPTO_RSA1792
  ------------------
  |  |   69|      0|#define AUTHENTIC_MECH_CRYPTO_RSA1792	0x0B
  ------------------
  |  Branch (1624:8): [True: 0, False: 0]
  ------------------
 1625|      0|				|| sdo->docp.mech == AUTHENTIC_MECH_CRYPTO_RSA2048)   {
  ------------------
  |  |   70|      0|#define AUTHENTIC_MECH_CRYPTO_RSA2048	0x0C
  ------------------
  |  Branch (1625:8): [True: 0, False: 0]
  ------------------
 1626|      0|			rv = authentic_manage_sdo_encode_prvkey(card, sdo->data.prvkey, &data, &data_len);
 1627|      0|			LOG_TEST_GOTO_ERR(ctx, rv, "SDO RSA encode 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1628|      0|		}
 1629|      0|		else  {
 1630|      0|			LOG_TEST_GOTO_ERR(ctx, SC_ERROR_NOT_SUPPORTED, "Cryptographic object unsupported for encoding");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1631|      0|		}
 1632|      0|	}
 1633|      1|	else if (cmd == SC_CARDCTL_AUTHENTIC_SDO_GENERATE)   {
  ------------------
  |  Branch (1633:11): [True: 0, False: 1]
  ------------------
 1634|      0|		if (sdo->data.prvkey)   {
  ------------------
  |  Branch (1634:7): [True: 0, False: 0]
  ------------------
 1635|      0|		        rv = authentic_update_blob(ctx, AUTHENTIC_TAG_RSA_PUBLIC_EXPONENT,
  ------------------
  |  |   90|      0|#define AUTHENTIC_TAG_RSA_PUBLIC_EXPONENT	0x82
  ------------------
 1636|      0|					sdo->data.prvkey->u.rsa.exponent.data, sdo->data.prvkey->u.rsa.exponent.len,
 1637|      0|					&data, &data_len);
 1638|      0|		        LOG_TEST_GOTO_ERR(ctx, rv, "SDO RSA Exponent encode 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1639|      0|		}
 1640|       |
 1641|      0|		data_tag = AUTHENTIC_TAG_RSA_GENERATE_DATA;
  ------------------
  |  |   92|      0|#define AUTHENTIC_TAG_RSA_GENERATE_DATA	0xAC
  ------------------
 1642|      0|	}
 1643|      1|	else if (cmd != SC_CARDCTL_AUTHENTIC_SDO_DELETE)   {
  ------------------
  |  Branch (1643:11): [True: 0, False: 1]
  ------------------
 1644|      0|		LOG_TEST_GOTO_ERR(ctx, SC_ERROR_INVALID_DATA, "Invalid SDO operation");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1645|      0|	}
 1646|       |
 1647|     32|	rv = authentic_update_blob(ctx, data_tag, data, data_len, out, out_len);
 1648|     32|	LOG_TEST_GOTO_ERR(ctx, rv, "SDO DOCP encode error");
  ------------------
  |  |  184|     32|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     32|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     32|	int _ret = (r); \
  |  |  |  |  178|     32|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 32]
  |  |  |  |  ------------------
  |  |  |  |  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|     32|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 32]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1649|       |
 1650|     32|	sc_log_hex(ctx, "encoded SDO operation data", *out, *out_len);
  ------------------
  |  |  129|     32|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|     32|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1651|       |
 1652|     32|err:
 1653|     32|	free(data);
 1654|       |
 1655|     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|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1656|     32|}
card-authentic.c:authentic_update_blob:
  103|    127|{
  104|    127|	unsigned char *pp = NULL;
  105|    127|	int offs = 0;
  106|    127|	size_t sz;
  107|       |
  108|    127|	if (data_len == 0)
  ------------------
  |  Branch (108:6): [True: 31, False: 96]
  ------------------
  109|     31|		return SC_SUCCESS;
  ------------------
  |  |   28|     31|#define SC_SUCCESS				0
  ------------------
  110|       |
  111|     96|	sz = data_len + 2;
  112|       |
  113|     96|	if (tag > 0xFF)
  ------------------
  |  Branch (113:6): [True: 0, False: 96]
  ------------------
  114|      0|		sz++;
  115|       |
  116|     96|	if (data_len > 0x7F && data_len < 0x100)
  ------------------
  |  Branch (116:6): [True: 0, False: 96]
  |  Branch (116:25): [True: 0, False: 0]
  ------------------
  117|      0|		sz++;
  118|     96|	else if (data_len >= 0x100)
  ------------------
  |  Branch (118:11): [True: 0, False: 96]
  ------------------
  119|      0|		sz += 2;
  120|       |
  121|     96|	pp = realloc(*blob, *blob_size + sz);
  122|     96|	if (!pp)
  ------------------
  |  Branch (122:6): [True: 0, False: 96]
  ------------------
  123|     96|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  124|       |
  125|     96|	if (tag > 0xFF)
  ------------------
  |  Branch (125:6): [True: 0, False: 96]
  ------------------
  126|      0|		*(pp + *blob_size + offs++) = (tag >> 8) & 0xFF;
  127|     96|	*(pp + *blob_size + offs++) = tag & 0xFF;
  128|       |
  129|     96|	if (data_len >= 0x100) {
  ------------------
  |  Branch (129:6): [True: 0, False: 96]
  ------------------
  130|      0|		*(pp + *blob_size + offs++) = 0x82;
  131|      0|		*(pp + *blob_size + offs++) = (data_len >> 8) & 0xFF;
  132|      0|	}
  133|     96|	else if (data_len > 0x7F)   {
  ------------------
  |  Branch (133:11): [True: 0, False: 96]
  ------------------
  134|      0|		*(pp + *blob_size + offs++) = 0x81;
  135|      0|	}
  136|     96|	*(pp + *blob_size + offs++) = data_len & 0xFF;
  137|       |
  138|     96|	memcpy(pp + *blob_size + offs, data, data_len);
  139|       |
  140|     96|	*blob_size += sz;
  141|     96|	*blob = pp;
  142|       |
  143|     96|	return SC_SUCCESS;
  ------------------
  |  |   28|     96|#define SC_SUCCESS				0
  ------------------
  144|     96|}
card-authentic.c:authentic_get_tagged_data:
  177|    523|{
  178|    523|	size_t size_len, tag_len, offs, size;
  179|    523|	int rv;
  180|    523|	unsigned tag;
  181|       |
  182|    523|	if (!out || !out_len)
  ------------------
  |  Branch (182:6): [True: 0, False: 523]
  |  Branch (182:14): [True: 0, False: 523]
  ------------------
  183|    523|		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|  2.24k|	for (offs = 0; offs < in_len; )   {
  ------------------
  |  Branch (185:17): [True: 2.14k, False: 96]
  ------------------
  186|  2.14k|		if ((*(in + offs) == 0x7F) || (*(in + offs) == 0x5F))   {
  ------------------
  |  Branch (186:7): [True: 41, False: 2.10k]
  |  Branch (186:33): [True: 160, False: 1.94k]
  ------------------
  187|    201|			if (offs + 1 >= in_len)
  ------------------
  |  Branch (187:8): [True: 4, False: 197]
  ------------------
  188|    201|				LOG_TEST_RET(ctx, SC_ERROR_INTERNAL, "parse error: invalid data");
  ------------------
  |  |  174|      4|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      4|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      4|	int _ret = (r); \
  |  |  |  |  168|      4|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 4, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      4|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      4|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      4|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      4|		return _ret; \
  |  |  |  |  172|      4|	} \
  |  |  |  |  173|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  189|    197|			tag = *(in + offs) * 0x100 + *(in + offs + 1);
  190|    197|			tag_len = 2;
  191|    197|		}
  192|  1.94k|		else   {
  193|  1.94k|			tag = *(in + offs);
  194|  1.94k|			tag_len = 1;
  195|  1.94k|		}
  196|       |
  197|  2.14k|		if (offs + tag_len >= in_len)
  ------------------
  |  Branch (197:7): [True: 16, False: 2.12k]
  ------------------
  198|  2.14k|			LOG_TEST_RET(ctx, SC_ERROR_INTERNAL, "parse error: invalid data");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  199|       |
  200|  2.12k|		rv = authentic_parse_size(in + offs + tag_len, in_len - (offs + tag_len), &size);
  201|  2.12k|		LOG_TEST_RET(ctx, rv, "parse error: invalid size data");
  ------------------
  |  |  174|  2.12k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.12k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.12k|	int _ret = (r); \
  |  |  |  |  168|  2.12k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 61, False: 2.06k]
  |  |  |  |  ------------------
  |  |  |  |  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|  2.12k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.06k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  202|  2.06k|		size_len = rv;
  203|       |
  204|  2.06k|		if (tag == in_tag)   {
  ------------------
  |  Branch (204:7): [True: 346, False: 1.72k]
  ------------------
  205|    346|			if (in_len - (offs + tag_len + size_len) < size)
  ------------------
  |  Branch (205:8): [True: 9, False: 337]
  ------------------
  206|    346|				LOG_TEST_RET(ctx, SC_ERROR_INTERNAL, "parse error: invalid data");
  ------------------
  |  |  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: 9, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|      9|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  207|       |
  208|    337|			*out = in + offs + tag_len + size_len;
  209|    337|			*out_len = size;
  210|       |
  211|    337|			return SC_SUCCESS;
  ------------------
  |  |   28|    337|#define SC_SUCCESS				0
  ------------------
  212|    346|		}
  213|       |
  214|  1.72k|		offs += tag_len + size_len + size;
  215|  1.72k|	}
  216|       |
  217|     96|	return SC_ERROR_ASN1_OBJECT_NOT_FOUND;
  ------------------
  |  |   83|     96|#define SC_ERROR_ASN1_OBJECT_NOT_FOUND		-1402
  ------------------
  218|    523|}
card-authentic.c:authentic_parse_size:
  149|  2.12k|{
  150|  2.12k|	if (!in || !out || in_len < 1)
  ------------------
  |  Branch (150:6): [True: 0, False: 2.12k]
  |  Branch (150:13): [True: 0, False: 2.12k]
  |  Branch (150:21): [True: 0, False: 2.12k]
  ------------------
  151|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  152|       |
  153|  2.12k|	if (*in < 0x80)   {
  ------------------
  |  Branch (153:6): [True: 1.99k, False: 135]
  ------------------
  154|  1.99k|		*out = *in;
  155|  1.99k|		return 1;
  156|  1.99k|	}
  157|    135|	else if (*in == 0x81)   {
  ------------------
  |  Branch (157:11): [True: 24, False: 111]
  ------------------
  158|     24|		if (in_len < 2)
  ------------------
  |  Branch (158:7): [True: 1, False: 23]
  ------------------
  159|      1|			return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      1|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  160|     23|		*out = *(in + 1);
  161|     23|		return 2;
  162|     24|	}
  163|    111|	else if (*in == 0x82)   {
  ------------------
  |  Branch (163:11): [True: 52, False: 59]
  ------------------
  164|     52|		if (in_len < 3)
  ------------------
  |  Branch (164:7): [True: 1, False: 51]
  ------------------
  165|      1|			return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      1|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  166|     51|		*out = *(in + 1) * 0x100 + *(in + 2);
  167|     51|		return 3;
  168|     52|	}
  169|       |
  170|     59|	return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|     59|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  171|  2.12k|}
card-authentic.c:authentic_process_fci:
  769|    685|{
  770|    685|	struct sc_context *ctx = card->ctx;
  771|    685|	size_t taglen;
  772|    685|	int rv;
  773|    685|	unsigned ii;
  774|    685|	const unsigned char *tag = NULL;
  775|    685|	unsigned char ops_DF[8] = {
  776|    685|		SC_AC_OP_CREATE, SC_AC_OP_DELETE, SC_AC_OP_CRYPTO, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
  ------------------
  |  |  169|    685|#define SC_AC_OP_CREATE			3
  ------------------
              		SC_AC_OP_CREATE, SC_AC_OP_DELETE, SC_AC_OP_CRYPTO, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
  ------------------
  |  |  168|    685|#define SC_AC_OP_DELETE			2
  ------------------
              		SC_AC_OP_CREATE, SC_AC_OP_DELETE, SC_AC_OP_CRYPTO, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
  ------------------
  |  |  173|    685|#define SC_AC_OP_CRYPTO			7
  ------------------
  777|    685|	};
  778|    685|	unsigned char ops_EF[8] = {
  779|    685|		SC_AC_OP_READ, SC_AC_OP_DELETE, SC_AC_OP_UPDATE, SC_AC_OP_RESIZE, 0xFF, 0xFF, 0xFF, 0xFF
  ------------------
  |  |  188|    685|#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|    685|#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|    685|#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|    685|#define SC_AC_OP_RESIZE			25
  ------------------
  780|    685|	};
  781|       |
  782|    685|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    685|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    685|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    685|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    685|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 685]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  783|       |
  784|    685|	tag = sc_asn1_find_tag(card->ctx,  buf, buflen, 0x6F, &taglen);
  785|    685|	if (tag != NULL) {
  ------------------
  |  Branch (785:6): [True: 657, False: 28]
  ------------------
  786|    657|		sc_log(ctx, "  FCP length %zu", taglen);
  ------------------
  |  |   71|    657|#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|    657|		buf = tag;
  788|    657|		buflen = taglen;
  789|    657|	}
  790|       |
  791|    685|	tag = sc_asn1_find_tag(card->ctx,  buf, buflen, 0x62, &taglen);
  792|    685|	if (tag != NULL) {
  ------------------
  |  Branch (792:6): [True: 15, False: 670]
  ------------------
  793|     15|		sc_log(ctx, "  FCP length %zu", taglen);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  794|     15|		buf = tag;
  795|     15|		buflen = taglen;
  796|     15|	}
  797|       |
  798|    685|	rv = iso_ops->process_fci(card, file, buf, buflen);
  799|    685|	LOG_TEST_RET(ctx, rv, "ISO parse FCI failed");
  ------------------
  |  |  174|    685|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    685|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    685|	int _ret = (r); \
  |  |  |  |  168|    685|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 685]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|    685|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 685]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  800|       |
  801|    685|	if (!file->sec_attr_len)   {
  ------------------
  |  Branch (801:6): [True: 327, False: 358]
  ------------------
  802|    327|		sc_log_hex(ctx, "ACLs not found in data", buf, buflen);
  ------------------
  |  |  129|    327|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|    327|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  803|    327|		sc_log(ctx, "Path:%s; Type:%X; PathType:%X", sc_print_path(&file->path), file->type, file->path.type);
  ------------------
  |  |   71|    327|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  804|    327|		if (file->path.type == SC_PATH_TYPE_DF_NAME || file->type == SC_FILE_TYPE_DF)   {
  ------------------
  |  |  118|    654|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
              		if (file->path.type == SC_PATH_TYPE_DF_NAME || file->type == SC_FILE_TYPE_DF)   {
  ------------------
  |  |  214|    305|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (804:7): [True: 22, False: 305]
  |  Branch (804:50): [True: 257, False: 48]
  ------------------
  805|    279|			file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|    279|#define SC_FILE_TYPE_DF			0x04
  ------------------
  806|    279|		}
  807|     48|		else   {
  808|     48|			LOG_TEST_RET(ctx, SC_ERROR_OBJECT_NOT_FOUND, "ACLs tag missing");
  ------------------
  |  |  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: 48, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|     48|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  809|     48|		}
  810|    327|	}
  811|       |
  812|    637|	sc_log_hex(ctx, "ACL data", file->sec_attr, file->sec_attr_len);
  ------------------
  |  |  129|    637|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|    637|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  813|  1.94k|	for (ii = 0; ii < file->sec_attr_len / 2 && ii < sizeof ops_DF; ii++)  {
  ------------------
  |  Branch (813:15): [True: 1.31k, False: 633]
  |  Branch (813:46): [True: 1.30k, False: 4]
  ------------------
  814|  1.30k|		unsigned char op = file->type == SC_FILE_TYPE_DF ? ops_DF[ii] : ops_EF[ii];
  ------------------
  |  |  214|  1.30k|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (814:22): [True: 58, False: 1.24k]
  ------------------
  815|  1.30k|		unsigned char acl = *(file->sec_attr + ii*2);
  816|  1.30k|		unsigned char cred_id = *(file->sec_attr + ii*2 + 1);
  817|  1.30k|		unsigned sc = acl * 0x100 + cred_id;
  818|       |
  819|  1.30k|		sc_log(ctx, "ACL(%i) op 0x%X, acl %X:%X", ii, op, acl, cred_id);
  ------------------
  |  |   71|  1.30k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  820|  1.30k|		if (op == 0xFF)
  ------------------
  |  Branch (820:7): [True: 335, False: 971]
  ------------------
  821|    335|			;
  822|    971|		else if (!acl && !cred_id)
  ------------------
  |  Branch (822:12): [True: 344, False: 627]
  |  Branch (822:20): [True: 184, False: 160]
  ------------------
  823|    184|			sc_file_add_acl_entry(file, op, SC_AC_NONE, 0);
  ------------------
  |  |  150|    184|#define SC_AC_NONE			0x00000000
  ------------------
  824|    787|		else if (acl == 0xFF)
  ------------------
  |  Branch (824:12): [True: 80, False: 707]
  ------------------
  825|     80|			sc_file_add_acl_entry(file, op, SC_AC_NEVER, 0);
  ------------------
  |  |  163|     80|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  826|    707|		else if (acl & AUTHENTIC_AC_SM_MASK)
  ------------------
  |  |  119|    707|#define AUTHENTIC_AC_SM_MASK	0x60
  ------------------
  |  Branch (826:12): [True: 231, False: 476]
  ------------------
  827|    231|			sc_file_add_acl_entry(file, op, SC_AC_SCB, sc);
  ------------------
  |  |  157|    231|#define SC_AC_SCB                       0x00000040 /* IAS/ECC SCB byte. */
  ------------------
  828|    476|		else if (cred_id)
  ------------------
  |  Branch (828:12): [True: 393, False: 83]
  ------------------
  829|    393|			sc_file_add_acl_entry(file, op, SC_AC_CHV, cred_id);
  ------------------
  |  |  151|    393|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  830|     83|		else
  831|     83|			sc_file_add_acl_entry(file, op, SC_AC_NEVER, 0);
  ------------------
  |  |  163|     83|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  832|  1.30k|	}
  833|       |
  834|    637|	LOG_FUNC_RETURN(ctx, 0);
  ------------------
  |  |  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: 637, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    637|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 637]
  |  |  |  |  ------------------
  |  |  |  |  157|    637|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    637|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    637|	return _ret; \
  |  |  |  |  163|    637|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  835|    637|}
card-authentic.c:authentic_pin_cmd:
 1432|    373|{
 1433|    373|	struct sc_context *ctx = card->ctx;
 1434|    373|	int rv = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|    373|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1435|       |
 1436|    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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1437|    373|	sc_log(ctx, "PIN-CMD:%X,PIN(type:%X,ret:%i)", data->cmd, data->pin_type, data->pin_reference);
  ------------------
  |  |   71|    373|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1438|    373|	sc_log(ctx, "PIN1(%p,len:%zu,tries-left:%i)", data->pin1.data, data->pin1.len, data->pin1.tries_left);
  ------------------
  |  |   71|    373|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1439|    373|	sc_log(ctx, "PIN2(%p,len:%zu)", data->pin2.data, data->pin2.len);
  ------------------
  |  |   71|    373|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1440|       |
 1441|    373|	switch (data->cmd)   {
 1442|     10|	case SC_PIN_CMD_VERIFY:
  ------------------
  |  |  415|     10|#define SC_PIN_CMD_VERIFY	0
  ------------------
  |  Branch (1442:2): [True: 10, False: 363]
  ------------------
 1443|     10|		rv = authentic_pin_verify(card, data);
 1444|     10|		break;
 1445|      0|	case SC_PIN_CMD_CHANGE:
  ------------------
  |  |  416|      0|#define SC_PIN_CMD_CHANGE	1
  ------------------
  |  Branch (1445:2): [True: 0, False: 373]
  ------------------
 1446|      0|		rv = authentic_pin_change(card, data);
 1447|      0|		break;
 1448|      0|	case SC_PIN_CMD_UNBLOCK:
  ------------------
  |  |  417|      0|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (1448:2): [True: 0, False: 373]
  ------------------
 1449|      0|		rv = authentic_pin_reset(card, data);
 1450|      0|		break;
 1451|    363|	case SC_PIN_CMD_GET_INFO:
  ------------------
  |  |  418|    363|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (1451:2): [True: 363, False: 10]
  ------------------
 1452|    363|		rv = authentic_pin_get_policy(card, data, NULL);
 1453|    363|		break;
 1454|      0|	default:
  ------------------
  |  Branch (1454:2): [True: 0, False: 373]
  ------------------
 1455|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1456|    373|	}
 1457|       |
 1458|    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|    272|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 272, False: 101]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1459|    373|}
card-authentic.c:authentic_pin_verify:
 1097|     10|{
 1098|     10|	struct sc_context *ctx = card->ctx;
 1099|     10|	struct authentic_private_data *prv_data = (struct authentic_private_data *) card->drv_data;
 1100|     10|	unsigned char pin_sha1[SHA_DIGEST_LENGTH];
 1101|     10|	int rv;
 1102|       |
 1103|     10|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     10|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     10|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     10|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     10|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1104|     10|	sc_log(ctx, "PIN(type:%X,reference:%X,data:%p,length:%zu)",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1105|     10|			pin_cmd->pin_type, pin_cmd->pin_reference, pin_cmd->pin1.data, pin_cmd->pin1.len);
 1106|       |
 1107|     10|	if (pin_cmd->pin_reference < 0 || pin_cmd->pin_reference >= AUTHENTIC_N_PINS) {
  ------------------
  |  |   64|     10|#define AUTHENTIC_N_PINS 8
  ------------------
  |  Branch (1107:6): [True: 0, False: 10]
  |  Branch (1107:36): [True: 10, False: 0]
  ------------------
 1108|     10|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "PIN reference out of bounds");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1109|     10|	}
 1110|       |
 1111|      0|	if (pin_cmd->pin1.data && !pin_cmd->pin1.len)   {
  ------------------
  |  Branch (1111:6): [True: 0, False: 0]
  |  Branch (1111:28): [True: 0, False: 0]
  ------------------
 1112|      0|		pin_cmd->pin1.tries_left = -1;
 1113|      0|		rv = authentic_pin_is_verified(card, pin_cmd);
 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|	}
 1116|       |
 1117|      0|	if (pin_cmd->pin1.data)
  ------------------
  |  Branch (1117:6): [True: 0, False: 0]
  ------------------
 1118|      0|		SHA1(pin_cmd->pin1.data, pin_cmd->pin1.len, pin_sha1);
 1119|      0|	else
 1120|      0|		SHA1((unsigned char *)"", 0, pin_sha1);
 1121|       |
 1122|      0|	if (!memcmp(pin_sha1, prv_data->pins_sha1[pin_cmd->pin_reference], SHA_DIGEST_LENGTH))   {
  ------------------
  |  Branch (1122:6): [True: 0, False: 0]
  ------------------
 1123|      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__
  |  |  ------------------
  ------------------
 1124|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1125|      0|	}
 1126|       |
 1127|      0|	memset(prv_data->pins_sha1[pin_cmd->pin_reference], 0, sizeof(prv_data->pins_sha1[0]));
 1128|       |
 1129|      0|	rv = authentic_pin_get_policy(card, pin_cmd, NULL);
 1130|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1131|       |
 1132|      0|	if (pin_cmd->pin1.len > pin_cmd->pin1.max_length)
  ------------------
  |  Branch (1132:6): [True: 0, False: 0]
  ------------------
 1133|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1134|       |
 1135|      0|	pin_cmd->pin1.tries_left = -1;
 1136|      0|	rv = authentic_chv_verify(card, pin_cmd);
 1137|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1138|       |
 1139|      0|	memcpy(prv_data->pins_sha1[pin_cmd->pin_reference], pin_sha1, SHA_DIGEST_LENGTH);
 1140|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1141|      0|}
card-authentic.c:authentic_pin_get_policy:
 1293|    363|{
 1294|    363|	struct sc_context *ctx = card->ctx;
 1295|    363|	struct sc_apdu apdu;
 1296|    363|	unsigned char rbuf[0x100];
 1297|    363|	int ii, rv;
 1298|       |
 1299|    363|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    363|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1300|    363|	sc_log(ctx, "get PIN(type:%X,ref:%X,tries-left:%i)", data->pin_type, data->pin_reference, data->pin1.tries_left);
  ------------------
  |  |   71|    363|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1301|       |
 1302|    363|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xCA, 0x5F, data->pin_reference);
  ------------------
  |  |  292|    363|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1303|    367|	for (ii=0;ii<2;ii++)   {
  ------------------
  |  Branch (1303:12): [True: 366, False: 1]
  ------------------
 1304|    366|		apdu.le = sizeof(rbuf);
 1305|    366|		apdu.resp = rbuf;
 1306|    366|		apdu.resplen = sizeof(rbuf);
 1307|       |
 1308|    366|		rv = sc_transmit_apdu(card, &apdu);
 1309|    366|		LOG_TEST_RET(ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|    366|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    366|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    366|	int _ret = (r); \
  |  |  |  |  168|    366|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 4, False: 362]
  |  |  |  |  ------------------
  |  |  |  |  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|    366|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 362]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1310|    362|		rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1311|       |
 1312|    362|		if (rv != SC_ERROR_CLASS_NOT_SUPPORTED)
  ------------------
  |  |   53|    362|#define SC_ERROR_CLASS_NOT_SUPPORTED		-1203
  ------------------
  |  Branch (1312:7): [True: 358, False: 4]
  ------------------
 1313|    358|			break;
 1314|       |
 1315|      4|		apdu.cla = 0x80;
 1316|      4|	}
 1317|    359|        LOG_TEST_RET(ctx, rv, "'GET DATA' error");
  ------------------
  |  |  174|    359|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    359|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    359|	int _ret = (r); \
  |  |  |  |  168|    359|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 169, False: 190]
  |  |  |  |  ------------------
  |  |  |  |  169|    169|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    169|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    169|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    169|		return _ret; \
  |  |  |  |  172|    169|	} \
  |  |  |  |  173|    359|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 190]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1318|       |
 1319|    190|	data->pin1.tries_left = -1;
 1320|       |
 1321|    190|	rv = authentic_parse_credential_data(ctx, data, acls, apdu.resp, apdu.resplen);
 1322|    190|        LOG_TEST_RET(ctx, rv, "Cannot parse credential data");
  ------------------
  |  |  174|    190|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    190|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    190|	int _ret = (r); \
  |  |  |  |  168|    190|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 89, False: 101]
  |  |  |  |  ------------------
  |  |  |  |  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|    190|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 101]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1323|       |
 1324|    101|	data->pin1.encoding = SC_PIN_ENCODING_ASCII;
  ------------------
  |  |  425|    101|#define SC_PIN_ENCODING_ASCII	0
  ------------------
 1325|    101|	data->pin1.offset = 5;
 1326|    101|	data->pin1.pad_char = 0xFF;
 1327|    101|	data->pin1.pad_length = data->pin1.max_length;
 1328|    101|	data->pin1.logged_in = SC_PIN_STATE_UNKNOWN;
  ------------------
  |  |  430|    101|#define SC_PIN_STATE_UNKNOWN	0
  ------------------
 1329|       |
 1330|    101|	data->flags |= SC_PIN_CMD_NEED_PADDING;
  ------------------
  |  |  422|    101|#define SC_PIN_CMD_NEED_PADDING		0x0002
  ------------------
 1331|       |
 1332|    101|	sc_log(ctx, "PIN policy: size max/min/pad %zu/%zu/%zu, tries max/left %i/%i",
  ------------------
  |  |   71|    101|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1333|    101|			data->pin1.max_length, data->pin1.min_length, data->pin1.pad_length,
 1334|    101|			data->pin1.max_tries, data->pin1.tries_left);
 1335|       |
 1336|    101|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    101|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    101|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    101|	int _ret = r; \
  |  |  |  |  155|    101|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 101, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    101|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 101]
  |  |  |  |  ------------------
  |  |  |  |  157|    101|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    101|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    101|	return _ret; \
  |  |  |  |  163|    101|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1337|    101|}
card-authentic.c:authentic_parse_credential_data:
  286|    190|{
  287|    190|	unsigned char *data;
  288|    190|	size_t data_len;
  289|    190|	int rv, ii;
  290|    190|	unsigned tag = AUTHENTIC_TAG_CREDENTIAL | pin_cmd->pin_reference;
  ------------------
  |  |   94|    190|#define AUTHENTIC_TAG_CREDENTIAL			0x5F00
  ------------------
  291|       |
  292|    190|	rv = authentic_get_tagged_data(ctx, blob, blob_len, tag, &blob, &blob_len);
  293|    190|	LOG_TEST_RET(ctx, rv, "cannot get credential data");
  ------------------
  |  |  174|    190|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    190|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    190|	int _ret = (r); \
  |  |  |  |  168|    190|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 74, False: 116]
  |  |  |  |  ------------------
  |  |  |  |  169|     74|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     74|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     74|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     74|		return _ret; \
  |  |  |  |  172|     74|	} \
  |  |  |  |  173|    190|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 116]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  294|       |
  295|    116|	rv = authentic_get_tagged_data(ctx, blob, blob_len, AUTHENTIC_TAG_CREDENTIAL_TRYLIMIT, &data, &data_len);
  ------------------
  |  |   95|    116|#define AUTHENTIC_TAG_CREDENTIAL_TRYLIMIT		0x91
  ------------------
  296|    116|	LOG_TEST_RET(ctx, rv, "cannot get try limit");
  ------------------
  |  |  174|    116|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    116|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    116|	int _ret = (r); \
  |  |  |  |  168|    116|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 7, False: 109]
  |  |  |  |  ------------------
  |  |  |  |  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|    116|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 109]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  297|    109|	pin_cmd->pin1.max_tries = *data;
  298|       |
  299|    109|	rv = authentic_get_tagged_data(ctx, blob, blob_len, AUTHENTIC_TAG_DOCP_MECH, &data, &data_len);
  ------------------
  |  |   73|    109|#define AUTHENTIC_TAG_DOCP_MECH			0x80
  ------------------
  300|    109|	LOG_TEST_RET(ctx, rv, "cannot get PIN type");
  ------------------
  |  |  174|    109|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    109|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    109|	int _ret = (r); \
  |  |  |  |  168|    109|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 106]
  |  |  |  |  ------------------
  |  |  |  |  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|    109|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 106]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  301|    106|	if (data_len > 0 && *data == 0)
  ------------------
  |  Branch (301:6): [True: 105, False: 1]
  |  Branch (301:22): [True: 47, False: 58]
  ------------------
  302|     47|		pin_cmd->pin_type = SC_AC_CHV;
  ------------------
  |  |  151|     47|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  303|     59|	else if (data_len > 0 && *data >= 2 && *data <= 7)
  ------------------
  |  Branch (303:11): [True: 58, False: 1]
  |  Branch (303:27): [True: 57, False: 1]
  |  Branch (303:41): [True: 56, False: 1]
  ------------------
  304|     56|		pin_cmd->pin_type = SC_AC_AUT;
  ------------------
  |  |  154|     56|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  305|      3|	else
  306|      3|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "unsupported Credential type");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  307|       |
  308|       |	/* Parse optional ACLs when requested */
  309|    103|	if (acls) {
  ------------------
  |  Branch (309:6): [True: 0, False: 103]
  ------------------
  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:%zu", data_len);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  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|    103|	rv = authentic_get_tagged_data(ctx, blob, blob_len, AUTHENTIC_TAG_CREDENTIAL_PINPOLICY, &data, &data_len);
  ------------------
  |  |   96|    103|#define AUTHENTIC_TAG_CREDENTIAL_PINPOLICY		0xA1
  ------------------
  341|    103|	if (!rv)   {
  ------------------
  |  Branch (341:6): [True: 3, False: 100]
  ------------------
  342|      3|		blob = data;
  343|      3|		blob_len = data_len;
  344|       |
  345|      3|		rv = authentic_get_tagged_data(ctx, blob, blob_len, AUTHENTIC_TAG_CREDENTIAL_PINPOLICY_MAXLENGTH, &data, &data_len);
  ------------------
  |  |   97|      3|#define AUTHENTIC_TAG_CREDENTIAL_PINPOLICY_MAXLENGTH	0x83
  ------------------
  346|      3|		LOG_TEST_RET(ctx, rv, "failed to get PIN max.length value");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  347|      2|		pin_cmd->pin1.max_length = *data;
  348|       |
  349|      2|		rv = authentic_get_tagged_data(ctx, blob, blob_len, AUTHENTIC_TAG_CREDENTIAL_PINPOLICY_MINLENGTH, &data, &data_len);
  ------------------
  |  |   98|      2|#define AUTHENTIC_TAG_CREDENTIAL_PINPOLICY_MINLENGTH	0x84
  ------------------
  350|      2|		LOG_TEST_RET(ctx, rv, "failed to get PIN min.length value");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  351|      1|		pin_cmd->pin1.min_length = *data;
  352|      1|	}
  353|       |
  354|    101|	return SC_SUCCESS;
  ------------------
  |  |   28|    101|#define SC_SUCCESS				0
  ------------------
  355|    103|}
card-authentic.c:authentic_card_reader_lock_obtained:
 1865|  2.36k|{
 1866|  2.36k|	int r = SC_SUCCESS;
  ------------------
  |  |   28|  2.36k|#define SC_SUCCESS				0
  ------------------
 1867|       |
 1868|  2.36k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  2.36k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  2.36k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  2.36k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 2.36k]
  |  |  ------------------
  ------------------
 1869|       |
 1870|  2.36k|	if (was_reset > 0
  ------------------
  |  Branch (1870:6): [True: 0, False: 2.36k]
  ------------------
 1871|      0|			&& card->type == SC_CARD_TYPE_OBERTHUR_AUTHENTIC_3_2) {
  ------------------
  |  Branch (1871:7): [True: 0, False: 0]
  ------------------
 1872|      0|		r = iso7816_select_aid(card, aid_AuthentIC_3_2, sizeof(aid_AuthentIC_3_2), NULL, NULL);
 1873|      0|	}
 1874|       |
 1875|  2.36k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  2.36k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  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: 2.36k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.36k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 2.36k]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.36k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.36k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|  2.36k|	return _ret; \
  |  |  |  |  163|  2.36k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1876|  2.36k|}

sc_get_belpic_driver:
  446|  16.3k|{
  447|  16.3k|	return sc_get_driver();
  448|  16.3k|}
card-belpic.c:sc_get_driver:
  423|  16.3k|{
  424|  16.3k|	if (iso_ops == NULL)
  ------------------
  |  Branch (424:6): [True: 1, False: 16.3k]
  ------------------
  425|      1|		iso_ops = sc_get_iso7816_driver()->ops;
  426|       |
  427|  16.3k|	belpic_ops.match_card = belpic_match_card;
  428|  16.3k|	belpic_ops.init = belpic_init;
  429|       |
  430|  16.3k|	belpic_ops.update_binary = iso_ops->update_binary;
  431|  16.3k|	belpic_ops.select_file = belpic_select_file;
  432|  16.3k|	belpic_ops.read_binary = belpic_read_binary;
  433|  16.3k|	belpic_ops.pin_cmd = belpic_pin_cmd;
  434|  16.3k|	belpic_ops.set_security_env = belpic_set_security_env;
  435|       |
  436|  16.3k|	belpic_ops.compute_signature = iso_ops->compute_signature;
  437|  16.3k|	belpic_ops.get_challenge = iso_ops->get_challenge;
  438|  16.3k|	belpic_ops.get_response = iso_ops->get_response;
  439|  16.3k|	belpic_ops.check_sw = iso_ops->check_sw;
  440|       |
  441|  16.3k|	return &belpic_drv;
  442|  16.3k|}
card-belpic.c:belpic_match_card:
  208|  12.0k|{
  209|  12.0k|	int i;
  210|       |
  211|  12.0k|	i = _sc_match_atr(card, belpic_atrs, &card->type);
  212|  12.0k|	if (i < 0)
  ------------------
  |  Branch (212:6): [True: 12.0k, False: 21]
  ------------------
  213|  12.0k|		return 0;
  214|     21|	return 1;
  215|  12.0k|}
card-belpic.c:belpic_init:
  218|     21|{
  219|     21|	int key_size = 1024;
  220|     21|	unsigned long flags = 0;
  221|       |
  222|     21|	sc_log(card->ctx,  "Belpic V%s\n", BELPIC_VERSION);
  ------------------
  |  |   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__
  |  |  ------------------
  |  |               #define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |  222|     21|	sc_log(card->ctx,  "Belpic V%s\n", BELPIC_VERSION);
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|     21|#define BELPIC_VERSION			"1.4"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  223|       |
  224|     21|	if (card->type < 0)
  ------------------
  |  Branch (224:6): [True: 0, False: 21]
  ------------------
  225|      0|		card->type = SC_CARD_TYPE_BELPIC_EID;	/* Unknown card: assume it's the Belpic Card */
  226|       |
  227|     21|	card->cla = 0x00;
  228|     21|	if (card->type == SC_CARD_TYPE_BELPIC_EID) {
  ------------------
  |  Branch (228:6): [True: 21, False: 0]
  ------------------
  229|     21|		u8 carddata[BELPIC_CARDDATA_RESP_LEN];
  230|     21|		memset(carddata, 0, sizeof(carddata));
  231|       |
  232|     21|		if(get_carddata(card, carddata, sizeof(carddata)) < 0) {
  ------------------
  |  Branch (232:6): [True: 12, False: 9]
  ------------------
  233|     12|			return SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|     12|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  234|     12|		}
  235|      9|		if (carddata[BELPIC_CARDDATA_OFF_APPLETVERS] >= 0x18) {
  ------------------
  |  |  131|      9|#define BELPIC_CARDDATA_OFF_APPLETVERS 21
  ------------------
  |  Branch (235:7): [True: 3, False: 6]
  ------------------
  236|      3|			flags = SC_ALGORITHM_ECDSA_HASH_NONE | SC_ALGORITHM_ECDSA_RAW;
  ------------------
  |  |  175|      3|#define SC_ALGORITHM_ECDSA_HASH_NONE		SC_ALGORITHM_RSA_HASH_NONE
  |  |  ------------------
  |  |  |  |  133|      3|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  ------------------
              			flags = SC_ALGORITHM_ECDSA_HASH_NONE | SC_ALGORITHM_ECDSA_RAW;
  ------------------
  |  |  174|      3|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
  237|      3|			_sc_card_add_ec_alg(card, 256, flags, 0, NULL);
  238|      3|			_sc_card_add_ec_alg(card, 384, flags, 0, NULL);
  239|      3|			_sc_card_add_ec_alg(card, 512, flags, 0, NULL);
  240|      3|			_sc_card_add_ec_alg(card, 521, flags, 0, NULL);
  241|      6|		} else {
  242|      6|			if (carddata[BELPIC_CARDDATA_OFF_APPLETVERS] >= 0x17) {
  ------------------
  |  |  131|      6|#define BELPIC_CARDDATA_OFF_APPLETVERS 21
  ------------------
  |  Branch (242:8): [True: 1, False: 5]
  ------------------
  243|      1|				key_size = 2048;
  244|      1|			}
  245|      6|			_sc_card_add_rsa_alg(card, key_size,
  246|      6|					SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_NONE, 0);
  ------------------
  |  |  111|      6|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|      6|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|      6|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
              					SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_NONE, 0);
  ------------------
  |  |  133|      6|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  247|      6|		}
  248|      9|	}
  249|       |
  250|       |	/* State that we have an RNG */
  251|      9|	card->caps |= SC_CARD_CAP_RNG;
  ------------------
  |  |  550|      9|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  252|       |
  253|      9|	card->max_pin_len = BELPIC_MAX_USER_PIN_LEN;
  ------------------
  |  |  106|      9|#define BELPIC_MAX_USER_PIN_LEN		12
  ------------------
  254|       |
  255|      9|	return 0;
  256|     21|}
card-belpic.c:get_carddata:
  170|     21|{
  171|     21|	sc_apdu_t apdu;
  172|     21|	u8 carddata_cmd[] = { 0x80, 0xE4, 0x00, 0x00, 0x1C };
  173|     21|	int r;
  174|       |
  175|     21|	if (carddataloc_len != BELPIC_CARDDATA_RESP_LEN)
  ------------------
  |  |  143|     21|#define BELPIC_CARDDATA_RESP_LEN 28
  ------------------
  |  Branch (175:6): [True: 0, False: 21]
  ------------------
  176|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  177|       |
  178|     21|	r = sc_bytes2apdu(card->ctx, carddata_cmd, sizeof(carddata_cmd), &apdu);
  179|     21|	if(r) {
  ------------------
  |  Branch (179:5): [True: 0, False: 21]
  ------------------
  180|      0|		sc_log(card->ctx,  "bytes to APDU conversion failed: %d\n", r);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  181|      0|		return r;
  182|      0|	}
  183|       |
  184|     21|	apdu.resp = carddata_loc;
  185|     21|	apdu.resplen = carddataloc_len;
  186|       |
  187|     21|	r = sc_transmit_apdu(card, &apdu);
  188|     21|	if(r) {
  ------------------
  |  Branch (188:5): [True: 4, False: 17]
  ------------------
  189|      4|		sc_log(card->ctx,  "GetCardData command failed: %d\n", r);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  190|      4|		return r;
  191|      4|	}
  192|       |
  193|     17|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  194|     17|	if(r) {
  ------------------
  |  Branch (194:5): [True: 5, False: 12]
  ------------------
  195|      5|		sc_log(card->ctx,  "GetCardData: card returned %d\n", r);
  ------------------
  |  |   71|      5|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  196|      5|		return r;
  197|      5|	}
  198|     12|	if(apdu.resplen < carddataloc_len) {
  ------------------
  |  Branch (198:5): [True: 3, False: 9]
  ------------------
  199|      3|		sc_log(card->ctx, "GetCardData: card returned %zu bytes rather than expected %d",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  200|      3|				apdu.resplen, carddataloc_len);
  201|      3|		return SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|      3|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
  202|      3|	}
  203|       |
  204|      9|	return 0;
  205|     12|}

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

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

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

sc_get_cardos_driver:
 1566|  16.3k|{
 1567|  16.3k|	return sc_get_driver();
 1568|  16.3k|}
card-cardos.c:sc_get_driver:
 1541|  16.3k|{
 1542|  16.3k|	if (iso_ops == NULL)
  ------------------
  |  Branch (1542:6): [True: 1, False: 16.3k]
  ------------------
 1543|      1|		iso_ops = sc_get_iso7816_driver()->ops;
 1544|  16.3k|	cardos_ops = *iso_ops;
 1545|  16.3k|	cardos_ops.match_card = cardos_match_card;
 1546|  16.3k|	cardos_ops.init = cardos_init;
 1547|  16.3k|	cardos_ops.finish = cardos_finish;
 1548|  16.3k|	cardos_ops.select_file = cardos_select_file;
 1549|  16.3k|	cardos_ops.create_file = cardos_create_file;
 1550|  16.3k|	cardos_ops.set_security_env = cardos_set_security_env;
 1551|  16.3k|	cardos_ops.restore_security_env = cardos_restore_security_env;
 1552|  16.3k|	cardos_ops.compute_signature = cardos_compute_signature;
 1553|  16.3k|	cardos_ops.decipher = cardos_decipher;
 1554|       |
 1555|  16.3k|	cardos_ops.list_files = cardos_list_files;
 1556|  16.3k|	cardos_ops.check_sw = cardos_check_sw;
 1557|  16.3k|	cardos_ops.card_ctl = cardos_card_ctl;
 1558|  16.3k|	cardos_ops.pin_cmd = cardos_pin_cmd;
 1559|  16.3k|	cardos_ops.logout  = cardos_logout;
 1560|       |
 1561|  16.3k|	return &cardos_drv;
 1562|  16.3k|}
card-cardos.c:cardos_match_card:
   76|  15.8k|{
   77|  15.8k|	unsigned char atr[SC_MAX_ATR_SIZE] = {0};
   78|  15.8k|	int i;
   79|       |
   80|  15.8k|	i = _sc_match_atr(card, cardos_atrs, &card->type);
   81|  15.8k|	if (i < 0)
  ------------------
  |  Branch (81:6): [True: 15.1k, False: 694]
  ------------------
   82|  15.1k|		return 0;
   83|       |
   84|    694|	memcpy(atr, card->atr.value, card->atr.len);
   85|       |
   86|       |	/* Do not change card type for CIE! */
   87|    694|	if (card->type == SC_CARD_TYPE_CARDOS_CIE_V1)
  ------------------
  |  Branch (87:6): [True: 0, False: 694]
  ------------------
   88|      0|		return 1;
   89|    694|	if (card->type == SC_CARD_TYPE_CARDOS_M4_4)
  ------------------
  |  Branch (89:6): [True: 0, False: 694]
  ------------------
   90|      0|		return 1;
   91|    694|	if (card->type == SC_CARD_TYPE_CARDOS_V5_0)
  ------------------
  |  Branch (91:6): [True: 19, False: 675]
  ------------------
   92|     19|		return 1;
   93|    675|	if (card->type == SC_CARD_TYPE_CARDOS_V5_3)
  ------------------
  |  Branch (93:6): [True: 404, False: 271]
  ------------------
   94|    404|		return 1;
   95|    271|	if (card->type == SC_CARD_TYPE_CARDOS_M4_2) {
  ------------------
  |  Branch (95:6): [True: 271, False: 0]
  ------------------
   96|    271|		int rv;
   97|    271|		sc_apdu_t apdu = {0};
   98|    271|		u8 rbuf[SC_MAX_APDU_BUFFER_SIZE] = {0};
   99|       |		/* first check some additional ATR bytes */
  100|    271|		if ((atr[4] != 0xff && atr[4] != 0x02) ||
  ------------------
  |  Branch (100:8): [True: 12, False: 259]
  |  Branch (100:26): [True: 10, False: 2]
  ------------------
  101|    261|		    (atr[6] != 0x10 && atr[6] != 0x0a) ||
  ------------------
  |  Branch (101:8): [True: 258, False: 3]
  |  Branch (101:26): [True: 6, False: 252]
  ------------------
  102|    255|		    (atr[9] != 0x55 && atr[9] != 0x58))
  ------------------
  |  Branch (102:8): [True: 11, False: 244]
  |  Branch (102:26): [True: 9, False: 2]
  ------------------
  103|     25|			return 0;
  104|       |		/* get the os version using GET DATA and compare it with
  105|       |		 * version in the ATR */
  106|    246|		sc_log(card->ctx,  "checking cardos version ...");
  ------------------
  |  |   71|    246|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  107|    246|		sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, 0x82);
  ------------------
  |  |  292|    246|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  108|    246|		apdu.resp = rbuf;
  109|    246|		apdu.resplen = sizeof(rbuf);
  110|    246|		apdu.le = 256;
  111|    246|		apdu.lc = 0;
  112|    246|		rv = sc_transmit_apdu(card, &apdu);
  113|    246|		LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|    246|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    246|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    246|	int _ret = (r); \
  |  |  |  |  168|    246|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 243]
  |  |  |  |  ------------------
  |  |  |  |  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|    246|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 243]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  114|    243|		if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00 || apdu.resplen < 2)
  ------------------
  |  Branch (114:7): [True: 10, False: 233]
  |  Branch (114:27): [True: 1, False: 232]
  |  Branch (114:47): [True: 2, False: 230]
  ------------------
  115|     13|			return 0;
  116|    230|		if (apdu.resp[0] != atr[10] ||
  ------------------
  |  Branch (116:7): [True: 5, False: 225]
  ------------------
  117|    225|		    apdu.resp[1] != atr[11])
  ------------------
  |  Branch (117:7): [True: 6, False: 219]
  ------------------
  118|       |			/* version mismatch */
  119|     11|			return 0;
  120|    219|		if (atr[11] <= 0x04) {
  ------------------
  |  Branch (120:7): [True: 172, False: 47]
  ------------------
  121|    172|			sc_log(card->ctx,  "found cardos m4.01");
  ------------------
  |  |   71|    172|#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|    172|			card->type = SC_CARD_TYPE_CARDOS_M4_01;
  123|    172|		} else if (atr[11] == 0x08) {
  ------------------
  |  Branch (123:14): [True: 1, False: 46]
  ------------------
  124|      1|			sc_log(card->ctx,  "found cardos v4.3b");
  ------------------
  |  |   71|      1|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  125|      1|			card->type = SC_CARD_TYPE_CARDOS_M4_3;
  126|     46|		} else if (atr[11] == 0x09) {
  ------------------
  |  Branch (126:14): [True: 1, False: 45]
  ------------------
  127|      1|			sc_log(card->ctx,  "found cardos v4.2b");
  ------------------
  |  |   71|      1|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  128|      1|			card->type = SC_CARD_TYPE_CARDOS_M4_2B;
  129|     45|		} else if (atr[11] >= 0x0B) {
  ------------------
  |  Branch (129:14): [True: 33, False: 12]
  ------------------
  130|     33|			sc_log(card->ctx,  "found cardos v4.2c or higher");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  131|     33|			card->type = SC_CARD_TYPE_CARDOS_M4_2C;
  132|     33|		} else {
  133|     12|			sc_log(card->ctx,  "found cardos m4.2");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  134|     12|		}
  135|    219|	}
  136|    219|	return 1;
  137|    271|}
card-cardos.c:cardos_init:
  212|    642|{
  213|    642|	cardos_data_t * priv = NULL;
  214|    642|	unsigned long flags = 0;
  215|    642|	size_t data_field_length;
  216|    642|	sc_apdu_t apdu;
  217|    642|	u8 rbuf[2];
  218|    642|	int r;
  219|       |
  220|    642|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    642|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    642|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    642|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 642]
  |  |  ------------------
  ------------------
  221|       |
  222|    642|	priv = calloc(1, sizeof(cardos_data_t));
  223|    642|	if (!priv)
  ------------------
  |  Branch (223:6): [True: 0, False: 642]
  ------------------
  224|    642|		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|    642|	card->drv_data = priv;
  226|       |
  227|    642|	card->name = "Atos CardOS";
  228|    642|	card->cla = 0x00;
  229|       |
  230|       |	/* let user override flags and type from opensc.conf */
  231|       |	/* user can override card->type too.*/
  232|    642|	if (card->flags) {
  ------------------
  |  Branch (232:6): [True: 0, False: 642]
  ------------------
  233|      0|	    flags = card->flags;
  234|    642|	} else {
  235|       |
  236|       |		/* Set up algorithm info. */
  237|    642|		flags = 0;
  238|    642|		if (card->type == SC_CARD_TYPE_CARDOS_V5_0) {
  ------------------
  |  Branch (238:7): [True: 19, False: 623]
  ------------------
  239|     19|			flags |= SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |  111|     19|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|     19|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|     19|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  240|    623|		} else if(card->type == SC_CARD_TYPE_CARDOS_V5_3) {
  ------------------
  |  Branch (240:13): [True: 404, False: 219]
  ------------------
  241|    404|			flags |= SC_ALGORITHM_RSA_RAW
  ------------------
  |  |  102|    404|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
  242|    404|				| SC_ALGORITHM_RSA_HASH_NONE
  ------------------
  |  |  133|    404|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  243|    404|				| SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|    404|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  244|    404|		} else {
  245|    219|			flags |= SC_ALGORITHM_RSA_RAW
  ------------------
  |  |  102|    219|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
  246|    219|				| SC_ALGORITHM_RSA_HASH_NONE
  ------------------
  |  |  133|    219|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  247|    219|				| SC_ALGORITHM_NEED_USAGE
  ------------------
  |  |   95|    219|#define SC_ALGORITHM_NEED_USAGE		0x40000000
  ------------------
  248|    219|				| SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|    219|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  249|    219|		}
  250|    642|	}
  251|       |
  252|    642|	priv->flags = flags;
  253|       |
  254|    642|	if (card->type == SC_CARD_TYPE_CARDOS_M4_2) {
  ------------------
  |  Branch (254:6): [True: 12, False: 630]
  ------------------
  255|     12|		r = cardos_have_2048bit_package(card);
  256|     12|		if (r < 0) {
  ------------------
  |  Branch (256:7): [True: 2, False: 10]
  ------------------
  257|      2|			r = SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|      2|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  258|      2|			goto err;
  259|      2|		}
  260|     10|		if (r == 1)
  ------------------
  |  Branch (260:7): [True: 1, False: 9]
  ------------------
  261|      1|			priv->rsa_2048 = 1;
  262|     10|		card->caps |= SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  547|     10|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  263|    630|	} else if (card->type == SC_CARD_TYPE_CARDOS_M4_3
  ------------------
  |  Branch (263:13): [True: 1, False: 629]
  ------------------
  264|    629|		|| card->type == SC_CARD_TYPE_CARDOS_M4_2B
  ------------------
  |  Branch (264:6): [True: 1, False: 628]
  ------------------
  265|    628|		|| card->type == SC_CARD_TYPE_CARDOS_M4_2C
  ------------------
  |  Branch (265:6): [True: 33, False: 595]
  ------------------
  266|    595|		|| card->type == SC_CARD_TYPE_CARDOS_M4_4
  ------------------
  |  Branch (266:6): [True: 0, False: 595]
  ------------------
  267|    595|		|| card->type == SC_CARD_TYPE_CARDOS_V5_0
  ------------------
  |  Branch (267:6): [True: 19, False: 576]
  ------------------
  268|    576|		|| card->type == SC_CARD_TYPE_CARDOS_V5_3) {
  ------------------
  |  Branch (268:6): [True: 404, False: 172]
  ------------------
  269|    458|		priv->rsa_2048 = 1;
  270|    458|		card->caps |= SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  547|    458|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  271|       |		/* TODO check this. EC only if in supported_algo */
  272|    458|		priv->ext_flags = SC_ALGORITHM_EXT_EC_NAMEDCURVE | SC_ALGORITHM_EXT_EC_UNCOMPRESES;
  ------------------
  |  |  201|    458|#define SC_ALGORITHM_EXT_EC_NAMEDCURVE   0x00000008
  ------------------
              		priv->ext_flags = SC_ALGORITHM_EXT_EC_NAMEDCURVE | SC_ALGORITHM_EXT_EC_UNCOMPRESES;
  ------------------
  |  |  202|    458|#define SC_ALGORITHM_EXT_EC_UNCOMPRESES  0x00000010
  ------------------
  273|    458|	}
  274|       |
  275|       |	/* probe DATA FIELD LENGTH with GET DATA */
  276|    640|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, 0x8D);
  ------------------
  |  |  292|    640|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  277|    640|	apdu.le = sizeof rbuf;
  278|    640|	apdu.resp = rbuf;
  279|    640|	apdu.resplen = sizeof(rbuf);
  280|       |
  281|    640|	r = sc_transmit_apdu(card, &apdu);
  282|    640|	if (r < 0)
  ------------------
  |  Branch (282:6): [True: 6, False: 634]
  ------------------
  283|    640|		LOG_TEST_GOTO_ERR(card->ctx,
  ------------------
  |  |  184|      6|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      6|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      6|	int _ret = (r); \
  |  |  |  |  178|      6|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      6|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|      6|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      6|		goto err; \
  |  |  |  |  182|      6|	} \
  |  |  |  |  183|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  284|    634|				SC_ERROR_INVALID_CARD,
  285|    634|				"APDU transmit failed");
  286|    634|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  287|    634|	if (r < 0)
  ------------------
  |  Branch (287:6): [True: 86, False: 548]
  ------------------
  288|    634|		LOG_TEST_GOTO_ERR(card->ctx,
  ------------------
  |  |  184|     86|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     86|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     86|	int _ret = (r); \
  |  |  |  |  178|     86|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 86, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|     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
  |  |  |  |  ------------------
  |  |  |  |  180|     86|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     86|		goto err; \
  |  |  |  |  182|     86|	} \
  |  |  |  |  183|     86|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  289|    548|				SC_ERROR_INVALID_CARD,
  290|    548|				"GET DATA command returned error");
  291|    548|	if (apdu.resplen != 2) {
  ------------------
  |  Branch (291:6): [True: 5, False: 543]
  ------------------
  292|      5|		r = SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|      5|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  293|      5|		goto err;
  294|      5|	}
  295|    543|	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|    543|	if (card->type == SC_CARD_TYPE_CARDOS_V5_0 || card->type == SC_CARD_TYPE_CARDOS_V5_3) {
  ------------------
  |  Branch (301:6): [True: 11, False: 532]
  |  Branch (301:48): [True: 334, False: 198]
  ------------------
  302|    345|		sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
  ------------------
  |  |   70|    345|#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|    345|				data_field_length, card->reader->max_send_size, card->reader->max_recv_size,
  |  |  |  |  306|    345|				(card->caps & SC_CARD_CAP_APDU_EXT) ? "SC_CARD_CAP_APDU_EXT" : " ");
  |  |  |  |  ------------------
  |  |  |  |  |  |  547|    345|#define SC_CARD_CAP_APDU_EXT		0x00000001
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  303|    345|				"data_field_length:%zu card->reader->max_send_size:%zu "
  304|    345|				"card->reader->max_recv_size:%zu %s",
  305|    345|				data_field_length, card->reader->max_send_size, card->reader->max_recv_size,
  306|    345|				(card->caps & SC_CARD_CAP_APDU_EXT) ? "SC_CARD_CAP_APDU_EXT" : " ");
  307|       |
  308|    345|		if (card->caps & SC_CARD_CAP_APDU_EXT) {
  ------------------
  |  |  547|    345|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (308:7): [True: 345, False: 0]
  ------------------
  309|    345|			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|    345|		} else
  323|      0|			card->max_send_size = data_field_length - 3;
  324|       |
  325|    345|		card->max_send_size = sc_get_max_send_size(card); /* include reader sizes and protocol */
  326|    345|		card->max_recv_size = data_field_length - 2;
  327|    345|		card->max_recv_size = sc_get_max_recv_size(card);
  328|    345|	} else {
  329|       |		/* old way, disregards reader capabilities */
  330|    198|		if (card->caps & SC_CARD_CAP_APDU_EXT)
  ------------------
  |  |  547|    198|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (330:7): [True: 28, False: 170]
  ------------------
  331|     28|			card->max_send_size = data_field_length - 6;
  332|    170|		else
  333|    170|			card->max_send_size = data_field_length - 3;
  334|       |		/* strip the length of SW bytes */
  335|    198|		card->max_recv_size = data_field_length - 2;
  336|    198|	}
  337|       |
  338|       |	/*for new cards, wait till after sc_pkcs15_bind_internal reads tokeninfo */
  339|    543|	if (card->type != SC_CARD_TYPE_CARDOS_V5_0 && card->type != SC_CARD_TYPE_CARDOS_V5_3) {
  ------------------
  |  Branch (339:6): [True: 532, False: 11]
  |  Branch (339:48): [True: 198, False: 334]
  ------------------
  340|    198|		r = cardos_add_algs(card, flags, 0, 0);
  341|    198|	}
  342|       |
  343|    642|err:
  344|    642|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|    642|#define SC_SUCCESS				0
  ------------------
  |  Branch (344:6): [True: 99, False: 543]
  ------------------
  345|     99|		free(priv);
  346|     99|		card->drv_data = NULL;
  347|     99|	}
  348|       |
  349|    642|	return r;
  350|    543|}
card-cardos.c:cardos_have_2048bit_package:
  140|     12|{
  141|     12|	sc_apdu_t apdu;
  142|     12|        u8        rbuf[SC_MAX_APDU_BUFFER_SIZE];
  143|     12|        int       r;
  144|     12|	const u8  *p = rbuf, *q, *pp;
  145|     12|	size_t    len, tlen = 0, ilen = 0;
  146|       |
  147|     12|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, 0x88);
  ------------------
  |  |  292|     12|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  148|     12|	apdu.resp    = rbuf;
  149|     12|	apdu.resplen = sizeof(rbuf);
  150|     12|	apdu.lc = 0;
  151|     12|	apdu.le = 256;
  152|     12|	r = sc_transmit_apdu(card, &apdu);
  153|     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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  154|       |
  155|     10|	if ((len = apdu.resplen) == 0)
  ------------------
  |  Branch (155:6): [True: 1, False: 9]
  ------------------
  156|       |		/* looks like no package has been installed  */
  157|      1|		return 0;
  158|       |
  159|     22|	while (len != 0) {
  ------------------
  |  Branch (159:9): [True: 21, False: 1]
  ------------------
  160|     21|		pp = sc_asn1_find_tag(card->ctx, p, len, 0xe1, &tlen);
  161|     21|		if (pp == NULL)
  ------------------
  |  Branch (161:7): [True: 5, False: 16]
  ------------------
  162|      5|			return 0;
  163|     16|		q = sc_asn1_find_tag(card->ctx, pp, tlen, 0x01, &ilen);
  164|     16|		if (q == NULL || ilen != 4)
  ------------------
  |  Branch (164:7): [True: 1, False: 15]
  |  Branch (164:20): [True: 1, False: 14]
  ------------------
  165|      2|			return 0;
  166|     14|		if (q[0] == 0x1c)
  ------------------
  |  Branch (166:7): [True: 1, False: 13]
  ------------------
  167|      1|			return 1;
  168|     13|		p   += tlen;
  169|     13|		len -= tlen + 2;
  170|     13|	}
  171|       |
  172|      1|	return 0;
  173|      9|}
card-cardos.c:cardos_add_algs:
  179|    216|{
  180|       |
  181|    216|	cardos_data_t * priv = (cardos_data_t *)card->drv_data;
  182|       |
  183|    216|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    216|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    216|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    216|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 216]
  |  |  ------------------
  ------------------
  184|       |
  185|    216|	_sc_card_add_rsa_alg(card,  512, flags, 0);
  186|    216|	_sc_card_add_rsa_alg(card,  768, flags, 0);
  187|    216|	_sc_card_add_rsa_alg(card, 1024, flags, 0);
  188|    216|	if (priv->rsa_2048 == 1) {
  ------------------
  |  Branch (188:6): [True: 46, False: 170]
  ------------------
  189|     46|		_sc_card_add_rsa_alg(card, 1280, flags, 0);
  190|     46|		_sc_card_add_rsa_alg(card, 1536, flags, 0);
  191|     46|		_sc_card_add_rsa_alg(card, 1792, flags, 0);
  192|     46|		_sc_card_add_rsa_alg(card, 2048, flags, 0);
  193|     46|	}
  194|       |
  195|    216|	if (card->type == SC_CARD_TYPE_CARDOS_V5_0 || card->type == SC_CARD_TYPE_CARDOS_V5_3) {
  ------------------
  |  Branch (195:6): [True: 0, False: 216]
  |  Branch (195:48): [True: 18, False: 198]
  ------------------
  196|       |		/* Starting with CardOS 5, the card supports PIN query commands */
  197|     18|		card->caps |= SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  553|     18|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
  198|     18|		_sc_card_add_rsa_alg(card, 3072, flags, 0);
  199|     18|		_sc_card_add_rsa_alg(card, 4096, flags, 0);
  200|     18|	}
  201|       |
  202|       |	/* TODO need to get sizes from supported_algos too */
  203|    216|	if (ec_flags != 0) {
  ------------------
  |  Branch (203:6): [True: 0, False: 216]
  ------------------
  204|      0|		 _sc_card_add_ec_alg(card, 256, ec_flags, priv->ext_flags, NULL);
  205|      0|		 _sc_card_add_ec_alg(card, 384, ec_flags, priv->ext_flags, NULL);
  206|      0|	}
  207|       |
  208|    216|	return 0;
  209|    216|}
card-cardos.c:cardos_finish:
  377|    543|{
  378|    543|	int r = 0;
  379|       |
  380|    543|	if (card == NULL )
  ------------------
  |  Branch (380:6): [True: 0, False: 543]
  ------------------
  381|      0|		return 0;
  382|       |
  383|    543|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    543|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    543|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    543|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 543]
  |  |  ------------------
  ------------------
  384|       |
  385|       |	/* free priv data */
  386|    543|	if (card->drv_data) { /* priv */
  ------------------
  |  Branch (386:6): [True: 543, False: 0]
  ------------------
  387|    543|		free(card->drv_data);
  388|    543|		card->drv_data = NULL;
  389|    543|	}
  390|       |
  391|    543|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|    543|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    543|	int _ret = r; \
  |  |  155|    543|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 543, False: 0]
  |  |  ------------------
  |  |  156|    543|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 543]
  |  |  ------------------
  |  |  157|    543|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    543|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|    543|	return _ret; \
  |  |  163|    543|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  392|    543|}
card-cardos.c:cardos_select_file:
  634|  26.3k|{
  635|  26.3k|	int r;
  636|       |
  637|  26.3k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  26.3k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  26.3k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  26.3k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 26.3k]
  |  |  ------------------
  ------------------
  638|  26.3k|	r = iso_ops->select_file(card, in_path, file);
  639|  26.3k|	if (r >= 0 && file)
  ------------------
  |  Branch (639:6): [True: 2.77k, False: 23.6k]
  |  Branch (639:16): [True: 2.16k, False: 605]
  ------------------
  640|  2.16k|		parse_sec_attr((*file), (*file)->sec_attr, (*file)->sec_attr_len);
  641|  26.3k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  26.3k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  26.3k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  26.3k|	int _ret = r; \
  |  |  |  |  155|  26.3k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 26.3k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  26.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|  23.6k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 23.6k, False: 2.77k]
  |  |  |  |  ------------------
  |  |  |  |  157|  26.3k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  26.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|  26.3k|	return _ret; \
  |  |  |  |  163|  26.3k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  642|  26.3k|}
card-cardos.c:parse_sec_attr:
  619|  2.16k|{
  620|  2.16k|	size_t i;
  621|  2.16k|	const int *idx;
  622|       |
  623|  2.16k|	idx = (file->type == SC_FILE_TYPE_DF) ?  df_acl : ef_acl;
  ------------------
  |  |  214|  2.16k|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (623:8): [True: 387, False: 1.78k]
  ------------------
  624|       |
  625|       |	/* acl defaults to 0xFF if unspecified */
  626|  21.6k|	for (i = 0; i < 9; i++)
  ------------------
  |  Branch (626:14): [True: 19.5k, False: 2.16k]
  ------------------
  627|  19.5k|		if (idx[i] != -1)
  ------------------
  |  Branch (627:7): [True: 14.7k, False: 4.72k]
  ------------------
  628|  14.7k|			add_acl_entry(file, idx[i], (u8)((i < len) ? buf[i] : 0xFF));
  ------------------
  |  Branch (628:37): [True: 1.98k, False: 12.8k]
  ------------------
  629|  2.16k|}
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|    181|	case 0x00:
  ------------------
  |  Branch (550:2): [True: 181, False: 14.6k]
  ------------------
  551|    181|		method = SC_AC_NONE;
  ------------------
  |  |  150|    181|#define SC_AC_NONE			0x00000000
  ------------------
  552|    181|		break;
  553|  13.0k|	case 0xFF:
  ------------------
  |  Branch (553:2): [True: 13.0k, False: 1.69k]
  ------------------
  554|  13.0k|		method = SC_AC_NEVER;
  ------------------
  |  |  163|  13.0k|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  555|  13.0k|		break;
  556|  1.51k|	default:
  ------------------
  |  Branch (556:2): [True: 1.51k, False: 13.2k]
  ------------------
  557|  1.51k|		if (byte > 0x7F) {
  ------------------
  |  Branch (557:7): [True: 423, False: 1.09k]
  ------------------
  558|    423|			method = SC_AC_UNKNOWN;
  ------------------
  |  |  162|    423|#define SC_AC_UNKNOWN			0xFFFFFFFE
  ------------------
  559|  1.09k|		} else {
  560|  1.09k|			method = SC_AC_CHV;
  ------------------
  |  |  151|  1.09k|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  561|  1.09k|			key_ref = byte;
  562|  1.09k|		}
  563|  1.51k|		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|     82|{
  849|     82|	int       r;
  850|       |
  851|     82|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     82|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     82|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     82|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 82]
  |  |  ------------------
  ------------------
  852|       |
  853|     82|	if (card->type == SC_CARD_TYPE_CARDOS_GENERIC ||
  ------------------
  |  Branch (853:6): [True: 0, False: 82]
  ------------------
  854|     82|	    card->type == SC_CARD_TYPE_CARDOS_M4_01) {
  ------------------
  |  Branch (854:6): [True: 58, False: 24]
  ------------------
  855|     58|		r = cardos_set_file_attributes(card, file);
  856|     58|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|     58|#define SC_SUCCESS				0
  ------------------
  |  Branch (856:7): [True: 1, False: 57]
  ------------------
  857|      1|			return r;
  858|     57|		return iso_ops->create_file(card, file);
  859|     58|	} else if (card->type == SC_CARD_TYPE_CARDOS_M4_2 ||
  ------------------
  |  Branch (859:13): [True: 0, False: 24]
  ------------------
  860|     24|	           card->type == SC_CARD_TYPE_CARDOS_M4_3 ||
  ------------------
  |  Branch (860:13): [True: 0, False: 24]
  ------------------
  861|     24|		   card->type == SC_CARD_TYPE_CARDOS_M4_2B ||
  ------------------
  |  Branch (861:6): [True: 0, False: 24]
  ------------------
  862|     24|	           card->type == SC_CARD_TYPE_CARDOS_M4_2C ||
  ------------------
  |  Branch (862:13): [True: 23, False: 1]
  ------------------
  863|     23|		   card->type == SC_CARD_TYPE_CARDOS_M4_4) {
  ------------------
  |  Branch (863:6): [True: 0, False: 1]
  ------------------
  864|     23|		u8        sbuf[SC_MAX_APDU_BUFFER_SIZE];
  865|     23|		size_t    len = sizeof(sbuf);
  866|     23|		sc_apdu_t apdu;
  867|       |
  868|     23|		r = cardos_construct_fcp(card, file, sbuf, &len);
  869|     23|		if (r < 0) {
  ------------------
  |  Branch (869:7): [True: 18, False: 5]
  ------------------
  870|     18|			sc_log(card->ctx,  "unable to create FCP");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  871|     18|			return r;
  872|     18|		}
  873|       |
  874|      5|		sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE0, 0x00, 0x00);
  ------------------
  |  |  293|      5|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  875|      5|		apdu.lc      = len;
  876|      5|		apdu.datalen = len;
  877|      5|		apdu.data    = sbuf;
  878|       |
  879|      5|		r = sc_transmit_apdu(card, &apdu);
  880|      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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  881|       |
  882|      3|		return sc_check_sw(card, apdu.sw1, apdu.sw2);
  883|      5|	} else
  884|      1|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      1|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  885|     82|}
card-cardos.c:cardos_set_file_attributes:
  671|     58|{
  672|     58|	int r;
  673|       |
  674|     58|	if (file->type_attr_len == 0) {
  ------------------
  |  Branch (674:6): [True: 58, False: 0]
  ------------------
  675|     58|		u8 type[3];
  676|       |
  677|     58|		memset(type, 0, sizeof(type));
  678|     58|		type[0] = 0x00;
  679|     58|		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: 57]
  ------------------
  681|      1|			break;
  682|     56|		case SC_FILE_TYPE_DF:
  ------------------
  |  |  214|     56|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (682:3): [True: 56, False: 2]
  ------------------
  683|     56|			type[0] = 0x38;
  684|     56|			break;
  685|      1|		default:
  ------------------
  |  Branch (685:3): [True: 1, False: 57]
  ------------------
  686|      1|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      1|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  687|     58|		}
  688|     57|		if (file->type != SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|     57|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (688:7): [True: 1, False: 56]
  ------------------
  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|     57|		r = sc_file_set_type_attr(file, type, sizeof(type));
  706|     57|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|     57|#define SC_SUCCESS				0
  ------------------
  |  Branch (706:7): [True: 0, False: 57]
  ------------------
  707|      0|			return r;
  708|     57|	}
  709|     57|	if (file->prop_attr_len == 0) {
  ------------------
  |  Branch (709:6): [True: 57, False: 0]
  ------------------
  710|     57|		u8 status[3];
  711|       |
  712|     57|		status[0] = 0x01;
  713|     57|		if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|     57|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (713:7): [True: 56, False: 1]
  ------------------
  714|     56|			status[1] = (file->size >> 8) & 0xFF;
  715|     56|			status[2] = file->size & 0xFF;
  716|     56|		} else {
  717|      1|			status[1] = status[2] = 0x00; /* not used */
  718|      1|		}
  719|     57|		r = sc_file_set_prop_attr(file, status, sizeof(status));
  720|     57|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|     57|#define SC_SUCCESS				0
  ------------------
  |  Branch (720:7): [True: 0, False: 57]
  ------------------
  721|      0|			return r;
  722|     57|	}
  723|     57|	if (file->sec_attr_len == 0) {
  ------------------
  |  Branch (723:6): [True: 57, False: 0]
  ------------------
  724|     57|		u8     acl[9];
  725|     57|		size_t blen = sizeof(acl);
  726|       |
  727|     57|		r = cardos_acl_to_bytes(card, file, acl, &blen);
  728|     57|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|     57|#define SC_SUCCESS				0
  ------------------
  |  Branch (728:7): [True: 0, False: 57]
  ------------------
  729|      0|			return r;
  730|     57|		r = sc_file_set_sec_attr(file, acl, blen);
  731|     57|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|     57|#define SC_SUCCESS				0
  ------------------
  |  Branch (731:7): [True: 0, False: 57]
  ------------------
  732|      0|			return r;
  733|     57|	}
  734|     57|	return SC_SUCCESS;
  ------------------
  |  |   28|     57|#define SC_SUCCESS				0
  ------------------
  735|     57|}
card-cardos.c:cardos_acl_to_bytes:
  646|     62|{
  647|     62|	int       i, byte;
  648|     62|	const int *idx;
  649|       |
  650|     62|	if (buf == NULL || *outlen < 9)
  ------------------
  |  Branch (650:6): [True: 0, False: 62]
  |  Branch (650:21): [True: 0, False: 62]
  ------------------
  651|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  652|       |
  653|     62|	idx = (file->type == SC_FILE_TYPE_DF) ?  df_acl : ef_acl;
  ------------------
  |  |  214|     62|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (653:8): [True: 61, False: 1]
  ------------------
  654|    620|	for (i = 0; i < 9; i++) {
  ------------------
  |  Branch (654:14): [True: 558, False: 62]
  ------------------
  655|    558|		if (idx[i] < 0)
  ------------------
  |  Branch (655:7): [True: 185, False: 373]
  ------------------
  656|    185|			byte = 0x00;
  657|    373|		else
  658|    373|			byte = acl_to_byte(sc_file_get_acl_entry(file, idx[i]));
  659|    558|		if (byte < 0) {
  ------------------
  |  Branch (659:7): [True: 0, False: 558]
  ------------------
  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|    558|		buf[i] = byte;
  664|    558|	}
  665|     62|	*outlen = 9;
  666|       |
  667|     62|	return SC_SUCCESS;
  ------------------
  |  |   28|     62|#define SC_SUCCESS				0
  ------------------
  668|     62|}
card-cardos.c:acl_to_byte:
  569|    373|{
  570|    373|	if (e != NULL) {
  ------------------
  |  Branch (570:6): [True: 373, False: 0]
  ------------------
  571|    373|		switch (e->method) {
  ------------------
  |  Branch (571:11): [True: 231, False: 142]
  ------------------
  572|    197|		case SC_AC_NONE:
  ------------------
  |  |  150|    197|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (572:3): [True: 197, False: 176]
  ------------------
  573|    197|			return 0x00;
  574|      5|		case SC_AC_NEVER:
  ------------------
  |  |  163|      5|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (574:3): [True: 5, False: 368]
  ------------------
  575|      5|			return 0xFF;
  576|     11|		case SC_AC_CHV:
  ------------------
  |  |  151|     11|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (576:3): [True: 11, False: 362]
  ------------------
  577|     20|		case SC_AC_TERM:
  ------------------
  |  |  152|     20|#define SC_AC_TERM			0x00000002 /* Terminal auth. */
  ------------------
  |  Branch (577:3): [True: 9, False: 364]
  ------------------
  578|     29|		case SC_AC_AUT:
  ------------------
  |  |  154|     29|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  |  Branch (578:3): [True: 9, False: 364]
  ------------------
  579|     29|			if (e->key_ref == SC_AC_KEY_REF_NONE)
  ------------------
  |  |  204|     29|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  |  Branch (579:8): [True: 0, False: 29]
  ------------------
  580|      0|				return -1;
  581|     29|			if (e->key_ref > 0x7F)
  ------------------
  |  Branch (581:8): [True: 0, False: 29]
  ------------------
  582|      0|				return -1;
  583|     29|			return e->key_ref;
  584|    373|		}
  585|    373|	}
  586|    142|        return 0x00;
  587|    373|}
card-cardos.c:cardos_construct_fcp:
  740|     23|{
  741|     23|	u8     buf[64], *p = out;
  742|     23|	size_t inlen = *outlen, len;
  743|     23|	int    r;
  744|       |
  745|     23|	LOG_FUNC_CALLED(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  746|       |
  747|     23|	if (out == NULL || inlen < 64)
  ------------------
  |  Branch (747:6): [True: 0, False: 23]
  |  Branch (747:21): [True: 0, False: 23]
  ------------------
  748|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  749|       |	/* add FCP tag */
  750|     23|	*p++ = 0x62;
  751|       |	/* we will add the length later  */
  752|     23|	p++;
  753|       |
  754|     23|	memset(buf, 0, sizeof(buf));
  755|       |
  756|       |	/* set the length */
  757|     23|	buf[0] = (file->size >> 8) & 0xff;
  758|     23|	buf[1] = file->size        & 0xff;
  759|     23|	if (file->type == SC_FILE_TYPE_DF)
  ------------------
  |  |  214|     23|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (759:6): [True: 5, False: 18]
  ------------------
  760|      5|		r = sc_asn1_put_tag(0x81, buf, 2, p, 4, &p);
  761|     18|	else
  762|     18|		r = sc_asn1_put_tag(0x80, buf, 2, p, 4, &p);
  763|     23|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|     23|#define SC_SUCCESS				0
  ------------------
  |  Branch (763:6): [True: 0, False: 23]
  ------------------
  764|      0|		return r;
  765|       |	/* set file type  */
  766|     23|	if (file->shareable != 0)
  ------------------
  |  Branch (766:6): [True: 0, False: 23]
  ------------------
  767|      0|		buf[0] = 0x40;
  768|     23|	else
  769|     23|		buf[0] = 0x00;
  770|     23|	if (file->type == SC_FILE_TYPE_WORKING_EF) {
  ------------------
  |  |  216|     23|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (770:6): [True: 1, False: 22]
  ------------------
  771|      1|		switch (file->ef_structure) {
  772|      0|		case SC_FILE_EF_TRANSPARENT:
  ------------------
  |  |  221|      0|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (772:3): [True: 0, False: 1]
  ------------------
  773|      0|			buf[0] |= 0x01;
  774|      0|			break;
  775|      0|		case SC_FILE_EF_LINEAR_VARIABLE_TLV:
  ------------------
  |  |  225|      0|#define SC_FILE_EF_LINEAR_VARIABLE_TLV	0x05
  ------------------
  |  Branch (775:3): [True: 0, False: 1]
  ------------------
  776|      0|			buf[0] |= 0x05;
  777|      0|			break;
  778|      0|		case SC_FILE_EF_LINEAR_FIXED:
  ------------------
  |  |  222|      0|#define SC_FILE_EF_LINEAR_FIXED		0x02
  ------------------
  |  Branch (778:3): [True: 0, False: 1]
  ------------------
  779|      0|			buf[0] |= 0x02;
  780|      0|			buf[1] |= 0x21;
  781|      0|			buf[2] |= 0x00;
  782|      0|			buf[3] |= (u8) file->record_length;
  783|      0|			buf[4] |= (u8) file->record_count;
  784|      0|			break;
  785|      0|		case SC_FILE_EF_CYCLIC:
  ------------------
  |  |  226|      0|#define SC_FILE_EF_CYCLIC		0x06
  ------------------
  |  Branch (785:3): [True: 0, False: 1]
  ------------------
  786|      0|			buf[0] |= 0x06;
  787|      0|			buf[1] |= 0x21;
  788|      0|			buf[2] |= 0x00;
  789|      0|			buf[3] |= (u8) file->record_length;
  790|      0|			buf[4] |= (u8) file->record_count;
  791|      0|			break;
  792|      1|		default:
  ------------------
  |  Branch (792:3): [True: 1, False: 0]
  ------------------
  793|      1|			sc_log(card->ctx,  "unknown EF type: %u", file->type);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  794|      1|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      1|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  795|      1|		}
  796|      0|		if (file->ef_structure == SC_FILE_EF_CYCLIC ||
  ------------------
  |  |  226|      0|#define SC_FILE_EF_CYCLIC		0x06
  ------------------
  |  Branch (796:7): [True: 0, False: 0]
  ------------------
  797|      0|		    file->ef_structure == SC_FILE_EF_LINEAR_FIXED)
  ------------------
  |  |  222|      0|#define SC_FILE_EF_LINEAR_FIXED		0x02
  ------------------
  |  Branch (797:7): [True: 0, False: 0]
  ------------------
  798|      0|		r = sc_asn1_put_tag(0x82, buf, 5, p, 8, &p);
  799|      0|	else
  800|      0|		r = sc_asn1_put_tag(0x82, buf, 1, p, 8, &p);
  801|     22|	} else if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|     22|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (801:13): [True: 5, False: 17]
  ------------------
  802|      5|		buf[0] |= 0x38;
  803|      5|		r = sc_asn1_put_tag(0x82, buf, 1, p, 8, &p);
  804|      5|	} else
  805|     17|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|     17|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  806|      5|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|      5|#define SC_SUCCESS				0
  ------------------
  |  Branch (806:6): [True: 0, False: 5]
  ------------------
  807|      0|		return r;
  808|       |	/* set file id */
  809|      5|	buf[0] = (file->id >> 8) & 0xff;
  810|      5|	buf[1] = file->id        & 0xff;
  811|      5|	r = sc_asn1_put_tag(0x83, buf, 2, p, 8, &p);
  812|      5|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|      5|#define SC_SUCCESS				0
  ------------------
  |  Branch (812:6): [True: 0, False: 5]
  ------------------
  813|      0|		return r;
  814|       |	/* set aid (for DF only) */
  815|      5|	if (file->type == SC_FILE_TYPE_DF && file->namelen != 0) {
  ------------------
  |  |  214|     10|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (815:6): [True: 5, False: 0]
  |  Branch (815:39): [True: 1, False: 4]
  ------------------
  816|      1|		r = sc_asn1_put_tag(0x84, file->name, file->namelen, p, 20, &p);
  817|      1|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
  |  Branch (817:7): [True: 0, False: 1]
  ------------------
  818|      0|			return r;
  819|      1|	}
  820|       |	/* set proprietary file attributes */
  821|      5|	buf[0] = 0x00;		/* use default values */
  822|      5|	if (file->type == SC_FILE_TYPE_DF)
  ------------------
  |  |  214|      5|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (822:6): [True: 5, False: 0]
  ------------------
  823|      5|		r = sc_asn1_put_tag(0x85, buf, 1, p, 8, &p);
  824|      0|	else {
  825|      0|		buf[1] = 0x00;
  826|      0|		buf[2] = 0x00;
  827|      0|		r = sc_asn1_put_tag(0x85, buf, 1, p, 8, &p);
  828|      0|	}
  829|      5|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|      5|#define SC_SUCCESS				0
  ------------------
  |  Branch (829:6): [True: 0, False: 5]
  ------------------
  830|      0|		return r;
  831|       |	/* set ACs  */
  832|      5|	len = 9;
  833|      5|	r = cardos_acl_to_bytes(card, file, buf, &len);
  834|      5|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|      5|#define SC_SUCCESS				0
  ------------------
  |  Branch (834:6): [True: 0, False: 5]
  ------------------
  835|      0|		return r;
  836|      5|	r = sc_asn1_put_tag(0x86, buf, len, p, 18, &p);
  837|      5|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|      5|#define SC_SUCCESS				0
  ------------------
  |  Branch (837:6): [True: 0, False: 5]
  ------------------
  838|      0|		return r;
  839|       |	/* finally set the length of the FCP */
  840|      5|	out[1] = p - out - 2;
  841|       |
  842|      5|	*outlen = p - out;
  843|       |
  844|      5|	return SC_SUCCESS;
  ------------------
  |  |   28|      5|#define SC_SUCCESS				0
  ------------------
  845|      5|}
card-cardos.c:cardos_list_files:
  476|     23|{
  477|     23|	sc_apdu_t apdu;
  478|     23|	u8        rbuf[256], offset = 0;
  479|     23|	const u8  *p, *q, *tag;
  480|     23|	int       r;
  481|     23|	size_t    fids = 0, len;
  482|       |
  483|     23|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  484|       |
  485|       |	/* 0x16: DIRECTORY */
  486|       |	/* 0x02: list both DF and EF */
  487|       |
  488|     30|get_next_part:
  489|     30|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0x16, 0x02, offset);
  ------------------
  |  |  292|     30|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  490|     30|	apdu.cla = 0x80;
  491|     30|	apdu.le = 256;
  492|     30|	apdu.resplen = 256;
  493|     30|	apdu.resp = rbuf;
  494|       |
  495|     30|	r = sc_transmit_apdu(card, &apdu);
  496|     30|	LOG_TEST_RET(card->ctx, r, "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: 1, False: 29]
  |  |  |  |  ------------------
  |  |  |  |  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|     30|} 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: 7, False: 22]
  |  |  |  |  ------------------
  |  |  |  |  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|     29|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  499|       |
  500|     22|	if (apdu.resplen > 256) {
  ------------------
  |  Branch (500:6): [True: 0, False: 22]
  ------------------
  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|     22|	p = rbuf;
  505|     22|	len = apdu.resplen;
  506|     24|	while (len != 0) {
  ------------------
  |  Branch (506:9): [True: 16, False: 8]
  ------------------
  507|     16|		size_t   tlen = 0, ilen = 0;
  508|       |		/* is there a file information block (0x6f) ? */
  509|     16|		tag = sc_asn1_find_tag(card->ctx, p, len, 0x6f, &tlen);
  510|     16|		if (tag == NULL) {
  ------------------
  |  Branch (510:7): [True: 2, False: 14]
  ------------------
  511|      2|			sc_log(card->ctx,  "directory tag missing");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  512|      2|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      2|#define SC_ERROR_INTERNAL			-1400
  ------------------
  513|      2|		}
  514|     14|		len = len - tlen - (tag - p);
  515|     14|		p = tag + tlen;
  516|     14|		if (tlen == 0)
  ------------------
  |  Branch (516:7): [True: 2, False: 12]
  ------------------
  517|       |			/* empty directory */
  518|      2|			break;
  519|     12|		q = sc_asn1_find_tag(card->ctx, tag, tlen, 0x86, &ilen);
  520|     12|		if (q == NULL || ilen != 2) {
  ------------------
  |  Branch (520:7): [True: 2, False: 10]
  |  Branch (520:20): [True: 1, False: 9]
  ------------------
  521|      3|			sc_log(card->ctx,  "error parsing file id TLV object");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  522|      3|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      3|#define SC_ERROR_INTERNAL			-1400
  ------------------
  523|      3|		}
  524|       |		/* put file id in buf */
  525|      9|		if (buflen >= 2) {
  ------------------
  |  Branch (525:7): [True: 9, False: 0]
  ------------------
  526|      9|			buf[fids++] = q[0];
  527|      9|			buf[fids++] = q[1];
  528|      9|			buflen -= 2;
  529|      9|		} else
  530|       |			/* not enough space left in buffer => break */
  531|      0|			break;
  532|       |		/* extract next offset */
  533|      9|		q = sc_asn1_find_tag(card->ctx, tag, tlen, 0x8a, &ilen);
  534|      9|		if (q != NULL && ilen == 1) {
  ------------------
  |  Branch (534:7): [True: 8, False: 1]
  |  Branch (534:20): [True: 7, False: 1]
  ------------------
  535|      7|			offset = (u8)ilen;
  536|      7|			goto get_next_part;
  537|      7|		}
  538|      9|	}
  539|       |
  540|     10|	r = (int)fids;
  541|       |
  542|     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: 7, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  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|      3|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      3|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      3|	} \
  |  |  |  |  162|     10|	return _ret; \
  |  |  |  |  163|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  543|     10|}
card-cardos.c:cardos_check_sw:
  458|  30.3k|{
  459|  30.3k|	const int err_count = sizeof(cardos_errors)/sizeof(cardos_errors[0]);
  460|  30.3k|	int i;
  461|       |
  462|   567k|	for (i = 0; i < err_count; i++) {
  ------------------
  |  Branch (462:14): [True: 564k, False: 2.78k]
  ------------------
  463|   564k|		if (cardos_errors[i].SWs == ((sw1 << 8) | sw2)) {
  ------------------
  |  Branch (463:7): [True: 27.5k, False: 537k]
  ------------------
  464|  27.5k|			if ( cardos_errors[i].errorstr )
  ------------------
  |  Branch (464:9): [True: 20.3k, False: 7.22k]
  ------------------
  465|  20.3k|				sc_log(card->ctx,  "%s\n",
  ------------------
  |  |   71|  20.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__
  |  |  ------------------
  ------------------
  466|  27.5k|				 	cardos_errors[i].errorstr);
  467|  27.5k|			return cardos_errors[i].errorno;
  468|  27.5k|		}
  469|   564k|	}
  470|       |
  471|  2.78k|        sc_log(card->ctx,  "Unknown SWs; SW1=%02X, SW2=%02X\n", sw1, sw2);
  ------------------
  |  |   71|  2.78k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  472|  2.78k|	return SC_ERROR_CARD_CMD_FAILED;
  ------------------
  |  |   50|  2.78k|#define SC_ERROR_CARD_CMD_FAILED		-1200
  ------------------
  473|  30.3k|}
card-cardos.c:cardos_card_ctl:
 1447|    975|{
 1448|    975|	switch (cmd) {
  ------------------
  |  Branch (1448:10): [True: 975, False: 0]
  ------------------
 1449|      0|	case SC_CARDCTL_CARDOS_PUT_DATA_FCI:
  ------------------
  |  Branch (1449:2): [True: 0, False: 975]
  ------------------
 1450|      0|		break;
 1451|     30|	case SC_CARDCTL_CARDOS_PUT_DATA_OCI:
  ------------------
  |  Branch (1451:2): [True: 30, False: 945]
  ------------------
 1452|     30|		return cardos_put_data_oci(card,
 1453|     30|			(struct sc_cardctl_cardos_obj_info *) ptr);
 1454|      0|		break;
 1455|     17|	case SC_CARDCTL_CARDOS_PUT_DATA_SECI:
  ------------------
  |  Branch (1455:2): [True: 17, False: 958]
  ------------------
 1456|     17|		return cardos_put_data_seci(card,
 1457|     17|			(struct sc_cardctl_cardos_obj_info *) ptr);
 1458|      0|		break;
 1459|      0|	case SC_CARDCTL_CARDOS_GENERATE_KEY:
  ------------------
  |  Branch (1459:2): [True: 0, False: 975]
  ------------------
 1460|      0|		return cardos_generate_key(card,
 1461|      0|			(struct sc_cardctl_cardos_genkey_info *) ptr);
 1462|     36|	case  SC_CARDCTL_CARDOS_PASS_ALGO_FLAGS:
  ------------------
  |  Branch (1462:2): [True: 36, False: 939]
  ------------------
 1463|     36|		return cardos_pass_algo_flags(card,
 1464|     36|			(struct sc_cardctl_cardos_pass_algo_flags *) ptr);
 1465|      0|	case SC_CARDCTL_LIFECYCLE_GET:
  ------------------
  |  Branch (1465:2): [True: 0, False: 975]
  ------------------
 1466|      0|		return cardos_lifecycle_get(card, (int *) ptr);
 1467|    777|	case SC_CARDCTL_LIFECYCLE_SET:
  ------------------
  |  Branch (1467:2): [True: 777, False: 198]
  ------------------
 1468|    777|		return cardos_lifecycle_set(card, (int *) ptr);
 1469|    115|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (1469:2): [True: 115, False: 860]
  ------------------
 1470|    115|		return cardos_get_serialnr(card, (sc_serial_number_t *)ptr);
 1471|    975|	}
 1472|      0|	return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1473|    975|}
card-cardos.c:cardos_put_data_oci:
 1328|     30|{
 1329|     30|	sc_apdu_t	apdu;
 1330|     30|	int		r;
 1331|       |
 1332|     30|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1333|       |
 1334|     30|	memset(&apdu, 0, sizeof(apdu));
 1335|     30|	apdu.cse = SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|     30|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1336|     30|	apdu.cla = 0x00;
 1337|     30|	apdu.ins = 0xda;
 1338|     30|	apdu.p1  = 0x01;
 1339|     30|	apdu.p2  = 0x6e;
 1340|     30|	apdu.lc  = args->len;
 1341|     30|	apdu.data = args->data;
 1342|     30|	apdu.datalen = args->len;
 1343|       |
 1344|     30|	r = sc_transmit_apdu(card, &apdu);
 1345|     30|	LOG_TEST_RET(card->ctx, r, "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: 1, False: 29]
  |  |  |  |  ------------------
  |  |  |  |  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|     30|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 29]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1346|       |
 1347|     29|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1348|     29|	LOG_TEST_RET(card->ctx, r, "Card 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: 8, False: 21]
  |  |  |  |  ------------------
  |  |  |  |  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|     29|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 21]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1349|       |
 1350|     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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 21]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1351|     21|}
card-cardos.c:cardos_put_data_seci:
 1356|     17|{
 1357|     17|	sc_apdu_t	apdu;
 1358|     17|	int		r;
 1359|       |
 1360|     17|	memset(&apdu, 0, sizeof(apdu));
 1361|     17|	apdu.cse = SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|     17|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1362|     17|	apdu.cla = 0x00;
 1363|     17|	apdu.ins = 0xda;
 1364|     17|	apdu.p1  = 0x01;
 1365|     17|	apdu.p2  = 0x6d;
 1366|     17|	apdu.lc  = args->len;
 1367|     17|	apdu.data = args->data;
 1368|     17|	apdu.datalen = args->len;
 1369|       |
 1370|     17|	r = sc_transmit_apdu(card, &apdu);
 1371|     17|	LOG_TEST_RET(card->ctx, r, "APDU transmit 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: 1, False: 16]
  |  |  |  |  ------------------
  |  |  |  |  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|     17|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 16]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1372|       |
 1373|     16|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1374|     16|	LOG_TEST_RET(card->ctx, r, "Card returned error");
  ------------------
  |  |  174|     16|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     16|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     16|	int _ret = (r); \
  |  |  |  |  168|     16|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 14]
  |  |  |  |  ------------------
  |  |  |  |  169|      2|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      2|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      2|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      2|		return _ret; \
  |  |  |  |  172|      2|	} \
  |  |  |  |  173|     16|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1375|       |
 1376|     14|	return r;
 1377|     16|}
card-cardos.c:cardos_pass_algo_flags:
  353|     36|{
  354|     36|	cardos_data_t * priv = (cardos_data_t *)card->drv_data;
  355|     36|	int r = 0;
  356|       |
  357|     36|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     36|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     36|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     36|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 36]
  |  |  ------------------
  ------------------
  358|     36|	switch (ptr->pass) {
  359|     18|		case 1:
  ------------------
  |  Branch (359:3): [True: 18, False: 18]
  ------------------
  360|     18|			ptr->card_flags = card->flags;
  361|     18|			ptr->used_flags = priv->flags;
  362|     18|			ptr->ec_flags = priv->ec_flags;
  363|     18|			ptr->ext_flags = priv->ext_flags;
  364|     18|			break;
  365|     18|		case 2:
  ------------------
  |  Branch (365:3): [True: 18, False: 18]
  ------------------
  366|     18|			r = cardos_add_algs(card,ptr->new_flags, ptr->ec_flags, ptr->ext_flags);
  367|     18|			break;
  368|      0|		default:
  ------------------
  |  Branch (368:3): [True: 0, False: 36]
  ------------------
  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|     36|	}
  372|     36|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     36|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     36|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     36|	int _ret = r; \
  |  |  |  |  155|     36|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  373|     36|}
card-cardos.c:cardos_lifecycle_get:
 1247|    777|{
 1248|    777|	sc_apdu_t	apdu;
 1249|    777|	u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
 1250|    777|	int		r;
 1251|       |
 1252|    777|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    777|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    777|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    777|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 777]
  |  |  ------------------
  ------------------
 1253|       |
 1254|    777|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, 0x83);
  ------------------
  |  |  292|    777|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1255|    777|	apdu.cla = 0x00;
 1256|    777|	apdu.le = 256;
 1257|    777|	apdu.resplen = sizeof(rbuf);
 1258|    777|	apdu.resp = rbuf;
 1259|       |
 1260|    777|	r = sc_transmit_apdu(card, &apdu);
 1261|    777|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    777|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    777|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    777|	int _ret = (r); \
  |  |  |  |  168|    777|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 45, False: 732]
  |  |  |  |  ------------------
  |  |  |  |  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|    777|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 732]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1262|       |
 1263|    732|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1264|    732|	LOG_TEST_RET(card->ctx, r, "Card returned error");
  ------------------
  |  |  174|    732|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    732|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    732|	int _ret = (r); \
  |  |  |  |  168|    732|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 188, False: 544]
  |  |  |  |  ------------------
  |  |  |  |  169|    188|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    188|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    188|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    188|		return _ret; \
  |  |  |  |  172|    188|	} \
  |  |  |  |  173|    732|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 544]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1265|       |
 1266|    544|	if (apdu.resplen < 1) {
  ------------------
  |  Branch (1266:6): [True: 15, False: 529]
  ------------------
 1267|     15|		LOG_TEST_RET(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Lifecycle byte not in response");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1268|     15|	}
 1269|       |
 1270|    529|	r = SC_SUCCESS;
  ------------------
  |  |   28|    529|#define SC_SUCCESS				0
  ------------------
 1271|    529|	switch (rbuf[0]) {
 1272|    313|	case 0x10:
  ------------------
  |  Branch (1272:2): [True: 313, False: 216]
  ------------------
 1273|    313|		*mode = SC_CARDCTRL_LIFECYCLE_USER;
 1274|    313|		break;
 1275|    157|	case 0x20:
  ------------------
  |  Branch (1275:2): [True: 157, False: 372]
  ------------------
 1276|    157|		*mode = SC_CARDCTRL_LIFECYCLE_ADMIN;
 1277|    157|		break;
 1278|     34|	case 0x34: /* MANUFACTURING */
  ------------------
  |  Branch (1278:2): [True: 34, False: 495]
  ------------------
 1279|     34|		*mode = SC_CARDCTRL_LIFECYCLE_OTHER;
 1280|     34|		break;
 1281|     25|	default:
  ------------------
  |  Branch (1281:2): [True: 25, False: 504]
  ------------------
 1282|     25|		sc_log(card->ctx,  "Unknown lifecycle byte %d", rbuf[0]);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1283|     25|		r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     25|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1284|    529|	}
 1285|       |
 1286|    529|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    529|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    529|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    529|	int _ret = r; \
  |  |  |  |  155|    529|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 529, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    529|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     25|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 25, False: 504]
  |  |  |  |  ------------------
  |  |  |  |  157|    529|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    529|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    529|	return _ret; \
  |  |  |  |  163|    529|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1287|    529|}
card-cardos.c:cardos_lifecycle_set:
 1291|    777|{
 1292|    777|	sc_apdu_t	apdu;
 1293|    777|	int		r;
 1294|       |
 1295|    777|	int current;
 1296|    777|	int target;
 1297|       |
 1298|    777|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    777|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    777|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    777|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 777]
  |  |  ------------------
  ------------------
 1299|       |
 1300|    777|	target = *mode;
 1301|       |
 1302|    777|	r = cardos_lifecycle_get(card, &current);
 1303|       |
 1304|    777|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|    777|#define SC_SUCCESS				0
  ------------------
  |  Branch (1304:6): [True: 273, False: 504]
  ------------------
 1305|    273|		return r;
 1306|       |
 1307|    504|	if (current == target || current == SC_CARDCTRL_LIFECYCLE_OTHER)
  ------------------
  |  Branch (1307:6): [True: 157, False: 347]
  |  Branch (1307:27): [True: 34, False: 313]
  ------------------
 1308|    191|		return SC_SUCCESS;
  ------------------
  |  |   28|    191|#define SC_SUCCESS				0
  ------------------
 1309|       |
 1310|    313|	sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x10, 0, 0);
  ------------------
  |  |  291|    313|#define SC_APDU_CASE_1			0x01
  ------------------
 1311|    313|	apdu.cla = 0x80;
 1312|    313|	apdu.le = 0;
 1313|    313|	apdu.resplen = 0;
 1314|    313|	apdu.resp = NULL;
 1315|       |
 1316|    313|	r = sc_transmit_apdu(card, &apdu);
 1317|    313|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    313|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    313|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    313|	int _ret = (r); \
  |  |  |  |  168|    313|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 312]
  |  |  |  |  ------------------
  |  |  |  |  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|    313|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 312]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1318|       |
 1319|    312|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1320|    312|	LOG_TEST_RET(card->ctx, r, "Card returned error");
  ------------------
  |  |  174|    312|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    312|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    312|	int _ret = (r); \
  |  |  |  |  168|    312|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 4, False: 308]
  |  |  |  |  ------------------
  |  |  |  |  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|    312|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 308]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1321|       |
 1322|    308|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    308|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    308|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    308|	int _ret = r; \
  |  |  |  |  155|    308|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 308, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    308|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      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|    308|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    308|	return _ret; \
  |  |  |  |  163|    308|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1323|    308|}
card-cardos.c:cardos_get_serialnr:
 1414|    115|{
 1415|    115|	int r;
 1416|    115|	sc_apdu_t apdu;
 1417|    115|	u8  rbuf[SC_MAX_APDU_BUFFER_SIZE];
 1418|       |
 1419|    115|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, 0x81);
  ------------------
  |  |  292|    115|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1420|    115|	apdu.resp = rbuf;
 1421|    115|	apdu.resplen = sizeof(rbuf);
 1422|    115|	apdu.le   = 256;
 1423|    115|	r = sc_transmit_apdu(card, &apdu);
 1424|    115|	LOG_TEST_RET(card->ctx, r,  "APDU transmit failed");
  ------------------
  |  |  174|    115|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    115|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    115|	int _ret = (r); \
  |  |  |  |  168|    115|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 5, False: 110]
  |  |  |  |  ------------------
  |  |  |  |  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|    115|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 110]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1425|    110|	if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00)
  ------------------
  |  Branch (1425:6): [True: 38, False: 72]
  |  Branch (1425:26): [True: 10, False: 62]
  ------------------
 1426|     48|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     48|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1427|     62|	if ((apdu.resplen == 8) && (card->type == SC_CARD_TYPE_CARDOS_V5_0 || card->type == SC_CARD_TYPE_CARDOS_V5_3)) {
  ------------------
  |  Branch (1427:6): [True: 7, False: 55]
  |  Branch (1427:30): [True: 0, False: 7]
  |  Branch (1427:72): [True: 3, False: 4]
  ------------------
 1428|       |		/* cache serial number */
 1429|      3|		memcpy(card->serialnr.value, rbuf, 8);
 1430|      3|		card->serialnr.len = 8;
 1431|     59|	} else if (apdu.resplen == 32) {
  ------------------
  |  Branch (1431:13): [True: 1, False: 58]
  ------------------
 1432|       |		/* cache serial number */
 1433|      1|		memcpy(card->serialnr.value, &rbuf[10], 6);
 1434|      1|		card->serialnr.len = 6;
 1435|     58|	} else {
 1436|     58|		sc_log(card->ctx,  "unexpected response to GET DATA serial"
  ------------------
  |  |   71|     58|#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|     58|				" number\n");
 1438|     58|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     58|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1439|     58|	}
 1440|       |	/* copy and return serial number */
 1441|      4|	memcpy(serial, &card->serialnr, sizeof(*serial));
 1442|      4|	return SC_SUCCESS;
  ------------------
  |  |   28|      4|#define SC_SUCCESS				0
  ------------------
 1443|     62|}
card-cardos.c:cardos_pin_cmd:
 1482|    111|{
 1483|    111|	struct sc_context *ctx = card->ctx;
 1484|    111|	int rv;
 1485|       |
 1486|    111|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    111|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    111|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    111|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    111|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 111]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1487|       |
 1488|    111|	data->flags |= SC_PIN_CMD_NEED_PADDING;
  ------------------
  |  |  422|    111|#define SC_PIN_CMD_NEED_PADDING		0x0002
  ------------------
 1489|    111|	data->pin_reference |= 0x80;
 1490|       |
 1491|    111|	sc_log(ctx, "PIN_CMD(cmd:%i, ref:%i)", data->cmd, data->pin_reference);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1492|    111|	sc_log(ctx, "PIN1(max:%zu, min:%zu)", data->pin1.max_length, data->pin1.min_length);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1493|    111|	sc_log(ctx, "PIN2(max:%zu, min:%zu)", data->pin2.max_length, data->pin2.min_length);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1494|       |
 1495|       |	/* FIXME: the following values depend on what pin length was
 1496|       |	 * used when creating the BS objects */
 1497|    111|	if (data->pin1.max_length == 0)
  ------------------
  |  Branch (1497:6): [True: 111, False: 0]
  ------------------
 1498|    111|		data->pin1.max_length = 8;
 1499|    111|	if (data->pin2.max_length == 0)
  ------------------
  |  Branch (1499:6): [True: 111, False: 0]
  ------------------
 1500|    111|		data->pin2.max_length = 8;
 1501|       |
 1502|    111|	rv = iso_ops->pin_cmd(card, data);
 1503|    111|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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|    110|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 110, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1504|    111|}

sc_get_cedulauy_driver:
  292|  16.3k|{
  293|  16.3k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
  294|       |
  295|  16.3k|	if (iso_ops == NULL)
  ------------------
  |  Branch (295:6): [True: 1, False: 16.3k]
  ------------------
  296|      1|		iso_ops = iso_drv->ops;
  297|       |
  298|  16.3k|	cedulauy_ops = *iso_ops;
  299|  16.3k|	cedulauy_ops.match_card = cedulauy_match_card;
  300|  16.3k|	cedulauy_ops.init = cedulauy_init;
  301|  16.3k|	cedulauy_ops.select_file = cedulauy_select_file;
  302|  16.3k|	cedulauy_ops.set_security_env = cedulauy_set_security_env;
  303|  16.3k|	cedulauy_ops.compute_signature = cedulauy_compute_signature;
  304|  16.3k|	cedulauy_ops.decipher = NULL; /* the signing key is sign-only */
  305|  16.3k|	cedulauy_ops.get_challenge = cedulauy_get_challenge;
  306|  16.3k|	cedulauy_ops.logout = cedulauy_logout;
  307|  16.3k|	cedulauy_ops.card_reader_lock_obtained = cedulauy_card_reader_lock_obtained;
  308|       |
  309|  16.3k|	return &cedulauy_drv;
  310|  16.3k|}
card-cedulauy.c:cedulauy_match_card:
  112|  9.16k|{
  113|  9.16k|	int i = _sc_match_atr(card, cedulauy_atrs, &card->type);
  114|       |
  115|  9.16k|	if (i < 0)
  ------------------
  |  Branch (115:6): [True: 9.15k, False: 11]
  ------------------
  116|  9.15k|		return 0;
  117|     11|	card->name = cedulauy_atrs[i].name;
  118|     11|	return 1;
  119|  9.16k|}
card-cedulauy.c:cedulauy_init:
  123|     11|{
  124|     11|	unsigned long flags;
  125|     11|	int r;
  126|       |
  127|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  128|       |
  129|     11|	card->caps = SC_CARD_CAP_RNG;
  ------------------
  |  |  550|     11|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  130|       |
  131|     11|	r = cedulauy_select_app(card);
  132|     11|	LOG_TEST_RET(card->ctx, r, "Cannot select the eID application");
  ------------------
  |  |  174|     11|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     11|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     11|	int _ret = (r); \
  |  |  |  |  168|     11|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 10, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  169|     10|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     10|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     10|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     10|		return _ret; \
  |  |  |  |  172|     10|	} \
  |  |  |  |  173|     11|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  133|       |
  134|       |	/* The card builds the DigestInfo on-card only for SHA-256 (algorithm
  135|       |	 * reference 0x42).  Everything else is signed as raw PKCS#1 v1.5 over
  136|       |	 * a DigestInfo built in software (algorithm reference 0x02). */
  137|      1|	flags = SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_HASH_SHA256;
  ------------------
  |  |  111|      1|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|      1|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|      1|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
              	flags = SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_HASH_SHA256;
  ------------------
  |  |  133|      1|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
              	flags = SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_HASH_SHA256;
  ------------------
  |  |  138|      1|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  ------------------
  138|      1|	r = _sc_card_add_rsa_alg(card, 2048, flags, 0);
  139|       |
  140|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  141|      1|}
card-cedulauy.c:cedulauy_select_app:
   97|     11|{
   98|     11|	struct sc_apdu apdu;
   99|     11|	unsigned char resp[SC_MAX_APDU_RESP_SIZE];
  100|       |
  101|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  102|       |
  103|     11|	sc_format_apdu_ex(&apdu, card->cla, 0xA4, 0x04, 0x00,
  104|     11|			cedulauy_aid, sizeof cedulauy_aid, resp, sizeof resp);
  105|     11|	SC_TRANSMIT_TEST_RET(card, apdu, "Cannot select the eID application");
  ------------------
  |  |   90|     11|	do { \
  |  |   91|     11|		LOG_TEST_RET(card->ctx, sc_transmit_apdu(card, &apdu), "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]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   92|     11|		LOG_TEST_RET(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2), text); \
  |  |  ------------------
  |  |  |  |  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: 9, False: 1]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  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|     10|} while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (173:9): [Folded, False: 1]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   93|     10|	} while (0)
  |  |  ------------------
  |  |  |  Branch (93:11): [Folded, False: 1]
  |  |  ------------------
  ------------------
  106|       |
  107|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  108|      1|}
card-cedulauy.c:cedulauy_card_reader_lock_obtained:
  145|     11|{
  146|     11|	if (was_reset)
  ------------------
  |  Branch (146:6): [True: 0, False: 11]
  ------------------
  147|     11|		LOG_FUNC_RETURN(card->ctx, cedulauy_select_app(card));
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  148|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  149|     11|}

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

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

dnie_match_card:
  738|  18.6k|{
  739|  18.6k|	int result = 0;
  740|  18.6k|	int matched = -1;
  741|  18.6k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  18.6k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  18.6k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  18.6k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  18.6k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 18.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  742|  18.6k|	matched = _sc_match_atr(card, dnie_atrs, &card->type);
  743|  18.6k|	result = (matched >= 0) ? 1 : 0;
  ------------------
  |  Branch (743:11): [True: 37, False: 18.6k]
  ------------------
  744|  18.6k|	LOG_FUNC_RETURN(card->ctx, result);
  ------------------
  |  |  164|  18.6k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  18.6k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  18.6k|	int _ret = r; \
  |  |  |  |  155|  18.6k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 18.6k, False: 37]
  |  |  |  |  ------------------
  |  |  |  |  156|  18.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: 18.6k]
  |  |  |  |  ------------------
  |  |  |  |  157|  18.6k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  18.6k|	} else { \
  |  |  |  |  159|     37|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     37|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     37|	} \
  |  |  |  |  162|  18.6k|	return _ret; \
  |  |  |  |  163|  18.6k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  745|  18.6k|}
sc_get_dnie_driver:
 2301|  16.3k|{
 2302|  16.3k|	return get_dnie_driver();
 2303|  16.3k|}
card-dnie.c:get_dnie_driver:
 2238|  16.3k|{
 2239|  16.3k|	sc_card_driver_t *iso_drv = sc_get_iso7816_driver();
 2240|       |
 2241|       |	/* memcpy() from standard iso7816 declared operations */
 2242|  16.3k|	if (iso_ops == NULL)
  ------------------
  |  Branch (2242:6): [True: 1, False: 16.3k]
  ------------------
 2243|      1|		iso_ops = iso_drv->ops;
 2244|  16.3k|	dnie_ops = *iso_drv->ops;
 2245|       |
 2246|       |	/* fill card specific function pointers */
 2247|       |	/* NULL means that function is not supported neither by DNIe nor iso7816.c */
 2248|       |	/* if pointer is omitted, default ISO7816 function will be used */
 2249|       |
 2250|       |	/* initialization */
 2251|  16.3k|	dnie_ops.match_card	= dnie_match_card;
 2252|  16.3k|	dnie_ops.init		= dnie_init;
 2253|  16.3k|	dnie_ops.finish		= dnie_finish;
 2254|       |
 2255|       |	/* iso7816-4 functions */
 2256|  16.3k|	dnie_ops.read_binary	= dnie_read_binary;
 2257|  16.3k|	dnie_ops.write_binary	= NULL;
 2258|  16.3k|	dnie_ops.update_binary	= NULL;
 2259|  16.3k|	dnie_ops.erase_binary	= NULL;
 2260|  16.3k|	dnie_ops.read_record	= NULL;
 2261|  16.3k|	dnie_ops.write_record	= NULL;
 2262|  16.3k|	dnie_ops.append_record	= NULL;
 2263|  16.3k|	dnie_ops.update_record	= NULL;
 2264|  16.3k|	dnie_ops.select_file	= dnie_select_file;
 2265|  16.3k|	dnie_ops.get_challenge	= dnie_get_challenge;
 2266|       |
 2267|       |	/* iso7816-8 functions */
 2268|  16.3k|	dnie_ops.verify		= NULL;
 2269|  16.3k|	dnie_ops.logout		= dnie_logout;
 2270|       |	/* dnie_ops.restore_security_env */
 2271|  16.3k|	dnie_ops.set_security_env = dnie_set_security_env;
 2272|  16.3k|	dnie_ops.decipher	= dnie_decipher;
 2273|  16.3k|	dnie_ops.compute_signature = dnie_compute_signature;
 2274|  16.3k|	dnie_ops.change_reference_data = NULL;
 2275|  16.3k|	dnie_ops.reset_retry_counter = NULL;
 2276|       |
 2277|       |	/* iso7816-9 functions */
 2278|  16.3k|	dnie_ops.create_file	= NULL;
 2279|  16.3k|	dnie_ops.delete_file	= NULL;
 2280|  16.3k|	dnie_ops.list_files	= dnie_list_files;
 2281|  16.3k|	dnie_ops.check_sw	= dnie_check_sw;
 2282|  16.3k|	dnie_ops.card_ctl	= dnie_card_ctl;
 2283|  16.3k|	dnie_ops.process_fci	= dnie_process_fci;
 2284|       |	/* dnie_ops.construct_fci */
 2285|  16.3k|	dnie_ops.pin_cmd	= dnie_pin_cmd;
 2286|  16.3k|	dnie_ops.get_data	= NULL;
 2287|  16.3k|	dnie_ops.put_data	= NULL;
 2288|  16.3k|	dnie_ops.delete_record	= NULL;
 2289|       |
 2290|  16.3k|	return &dnie_driver;
 2291|  16.3k|}
card-dnie.c:dnie_init:
  829|     36|{
  830|     36|	int res = SC_SUCCESS;
  ------------------
  |  |   28|     36|#define SC_SUCCESS				0
  ------------------
  831|     36|	sc_context_t *ctx = card->ctx;
  832|     36|	cwa_provider_t *provider = NULL;
  833|       |
  834|     36|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     36|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     36|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     36|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     36|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 36]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  835|       |
  836|       |	/* if recognized as terminated DNIe card, return error */
  837|     36|	if (card->type == SC_CARD_TYPE_DNIE_TERMINATED)
  ------------------
  |  Branch (837:6): [True: 2, False: 34]
  ------------------
  838|     36|	    LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_CARD, "DNIe card is terminated.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  839|       |
  840|       |	/* create and initialize cwa-dnie provider*/
  841|     34|	provider = dnie_get_cwa_provider(card);
  842|     34|	if (!provider)
  ------------------
  |  Branch (842:6): [True: 0, False: 34]
  ------------------
  843|     34|	    LOG_TEST_RET(card->ctx, SC_ERROR_INTERNAL, "Error initializing cwa-dnie provider");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  844|       |
  845|       |	/** Secure messaging initialization section **/
  846|     34|	memset(&(card->sm_ctx), 0, sizeof(sm_context_t));
  847|     34|	card->sm_ctx.ops.get_sm_apdu = dnie_sm_get_wrapped_apdu;
  848|     34|	card->sm_ctx.ops.free_sm_apdu = dnie_sm_free_wrapped_apdu;
  849|     34|	card->sm_ctx.sm_mode = SM_MODE_NONE;
  ------------------
  |  |   43|     34|#define SM_MODE_NONE		0x0
  ------------------
  850|       |
  851|     34|	res = cwa_create_secure_channel(card, provider, CWA_SM_OFF);
  ------------------
  |  |   31|     34|#define CWA_SM_OFF        0x00	/** Disable SM channel */
  ------------------
  852|     34|	if (res < 0)
  ------------------
  |  Branch (852:6): [True: 23, False: 11]
  ------------------
  853|     23|		free(provider);
  854|     34|	LOG_TEST_RET(card->ctx, res, "Failure resetting CWA secure channel.");
  ------------------
  |  |  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: 23, False: 11]
  |  |  |  |  ------------------
  |  |  |  |  169|     23|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     23|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     23|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     23|		return _ret; \
  |  |  |  |  172|     23|	} \
  |  |  |  |  173|     34|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 11]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  855|       |
  856|       |	/* initialize private data */
  857|     11|	card->drv_data = calloc(1, sizeof(dnie_private_data_t));
  858|     11|	if (card->drv_data == NULL) {
  ------------------
  |  Branch (858:6): [True: 0, False: 11]
  ------------------
  859|      0|		free(provider);
  860|      0|	    LOG_TEST_RET(card->ctx, SC_ERROR_OUT_OF_MEMORY, "Could not allocate DNIe private data.");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  861|      0|	}
  862|       |
  863|       |#ifdef ENABLE_DNIE_UI
  864|       |	/* read environment from configuration file */
  865|       |	res = dnie_get_environment(card, &(GET_DNIE_UI_CTX(card)));
  866|       |	if (res != SC_SUCCESS) {
  867|       |		free(card->drv_data);
  868|       |		free(provider);
  869|       |		LOG_TEST_RET(card->ctx, res, "Failure reading DNIe environment.");
  870|       |	}
  871|       |#endif
  872|       |
  873|     11|	init_flags(card);
  874|       |
  875|     11|	GET_DNIE_PRIV_DATA(card)->cwa_provider = provider;
  ------------------
  |  |   97|     11|#define GET_DNIE_PRIV_DATA(card) ((dnie_private_data_t *) ((card)->drv_data))
  ------------------
  876|       |
  877|     11|	LOG_FUNC_RETURN(card->ctx, res);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  878|     11|}
card-dnie.c:init_flags:
  705|     11|{
  706|     11|	unsigned long algoflags;
  707|       |	/* set up flags according documentation */
  708|     11|	card->name = DNIE_CHIP_SHORTNAME;
  ------------------
  |  |   68|     11|#define DNIE_CHIP_SHORTNAME "dnie"
  ------------------
  709|     11|	card->cla = 0x00;	/* default APDU class (interindustry) */
  710|     11|	card->caps |= SC_CARD_CAP_RNG;	/* we have a random number generator */
  ------------------
  |  |  550|     11|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  711|     11|	card->max_send_size = (255 - 12);	/* manual says 255, but we need 12 extra bytes when encoding */
  712|     11|	card->max_recv_size = 255;
  713|       |
  714|       |	/* RSA Support with PKCS1.5 padding */
  715|     11|	algoflags = SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |  133|     11|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
              	algoflags = SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |  111|     11|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|     11|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|     11|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  716|     11|	_sc_card_add_rsa_alg(card, 1024, algoflags, 0);
  717|     11|	_sc_card_add_rsa_alg(card, 1920, algoflags, 0);
  718|     11|	_sc_card_add_rsa_alg(card, 2048, algoflags, 0);
  719|     11|}
card-dnie.c:dnie_finish:
  890|     11|{
  891|     11|	int result = SC_SUCCESS;
  ------------------
  |  |   28|     11|#define SC_SUCCESS				0
  ------------------
  892|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  893|     11|	dnie_clear_cache(GET_DNIE_PRIV_DATA(card));
  ------------------
  |  |   97|     11|#define GET_DNIE_PRIV_DATA(card) ((dnie_private_data_t *) ((card)->drv_data))
  ------------------
  894|       |	/* disable sm channel if established */
  895|     11|	result = cwa_create_secure_channel(card, GET_DNIE_PRIV_DATA(card)->cwa_provider, CWA_SM_OFF);
  ------------------
  |  |   97|     11|#define GET_DNIE_PRIV_DATA(card) ((dnie_private_data_t *) ((card)->drv_data))
  ------------------
              	result = cwa_create_secure_channel(card, GET_DNIE_PRIV_DATA(card)->cwa_provider, CWA_SM_OFF);
  ------------------
  |  |   31|     11|#define CWA_SM_OFF        0x00	/** Disable SM channel */
  ------------------
  896|     11|	free(GET_DNIE_PRIV_DATA(card)->cwa_provider);
  ------------------
  |  |   97|     11|#define GET_DNIE_PRIV_DATA(card) ((dnie_private_data_t *) ((card)->drv_data))
  ------------------
  897|     11|	free(card->drv_data);
  898|     11|	LOG_FUNC_RETURN(card->ctx, result);
  ------------------
  |  |  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|      7|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 7, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  899|     11|}
card-dnie.c:dnie_clear_cache:
  689|     20|{
  690|     20|	if (data == NULL) return;
  ------------------
  |  Branch (690:6): [True: 7, False: 13]
  ------------------
  691|     13|	if (data->cache != NULL)
  ------------------
  |  Branch (691:6): [True: 0, False: 13]
  ------------------
  692|      0|		free(data->cache);
  693|       |	data->cache = NULL;
  694|     13|	data->cachelen = 0;
  695|     13|}
card-dnie.c:dnie_select_file:
 1215|     45|{
 1216|     45|	int res = SC_SUCCESS;
  ------------------
  |  |   28|     45|#define SC_SUCCESS				0
  ------------------
 1217|     45|	sc_context_t *ctx = NULL;
 1218|     45|	unsigned char tmp_path[sizeof(DNIE_MF_NAME)];
 1219|     45|	size_t reminder = 0;
 1220|       |
 1221|     45|	if (!card || !card->ctx || !in_path)
  ------------------
  |  Branch (1221:6): [True: 0, False: 45]
  |  Branch (1221:15): [True: 0, False: 45]
  |  Branch (1221:29): [True: 0, False: 45]
  ------------------
 1222|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1223|     45|	ctx = card->ctx;
 1224|       |
 1225|     45|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     45|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1226|       |
 1227|     45|	switch (in_path->type) {
 1228|      0|	case SC_PATH_TYPE_FILE_ID:
  ------------------
  |  |  117|      0|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (1228:2): [True: 0, False: 45]
  ------------------
 1229|       |		/* pathlen must be of len=2 */
 1230|       |		/*
 1231|       |		 * gscriptor shows that DNIe also handles
 1232|       |		 * Select child DF (p1=1) and Select EF (p1=2),
 1233|       |		 * but we'll use P1=0 as general solution for all cases
 1234|       |		 *
 1235|       |		 * According iso7816-4 sect 7.1.1  pathlen==0 implies
 1236|       |		 * select MF, but this case is not supported by DNIe
 1237|       |		 */
 1238|      0|		if (in_path->len != 2)
  ------------------
  |  Branch (1238:7): [True: 0, False: 0]
  ------------------
 1239|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1240|      0|		sc_log_hex(ctx, "select_file(ID)", in_path->value, in_path->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__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1241|      0|		res = dnie_compose_and_send_apdu(card, in_path->value, in_path->len, 0, file_out);
 1242|      0|		break;
 1243|      0|	case SC_PATH_TYPE_DF_NAME:
  ------------------
  |  |  118|      0|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (1243:2): [True: 0, False: 45]
  ------------------
 1244|      0|		sc_log_hex(ctx, "select_file(NAME)", in_path->value, in_path->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__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1245|      0|		res = dnie_compose_and_send_apdu(card, in_path->value, in_path->len, 4, file_out);
 1246|      0|		break;
 1247|     45|	case SC_PATH_TYPE_PATH:
  ------------------
  |  |  119|     45|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (1247:2): [True: 45, False: 0]
  ------------------
 1248|     45|		if ((in_path->len == 0) || ((in_path->len & 1) != 0)) /* not divisible by 2 */
  ------------------
  |  Branch (1248:7): [True: 0, False: 45]
  |  Branch (1248:30): [True: 0, False: 45]
  ------------------
 1249|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1250|       |
 1251|     45|		sc_log_hex(ctx, "select_file(PATH): requested", in_path->value, in_path->len);
  ------------------
  |  |  129|     45|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|     45|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1252|       |
 1253|       |		/* convert to SC_PATH_TYPE_FILE_ID */
 1254|     45|		res = sc_lock(card); /* lock to ensure path traversal */
 1255|     45|		LOG_TEST_RET(ctx, res, "sc_lock() 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: 0, False: 45]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|     45|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 45]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1256|     45|		if (memcmp(in_path->value, "\x3F\x00", 2) == 0) {
  ------------------
  |  Branch (1256:7): [True: 45, False: 0]
  ------------------
 1257|       |			/* if MF, use the name as path */
 1258|     45|			strcpy((char *)tmp_path, DNIE_MF_NAME);
  ------------------
  |  |   69|     45|#define DNIE_MF_NAME "Master.File"
  ------------------
 1259|     45|			sc_log_hex(ctx, "select_file(NAME): requested", tmp_path, sizeof(DNIE_MF_NAME) - 1);
  ------------------
  |  |  129|     45|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|     45|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1260|     45|			res = dnie_compose_and_send_apdu(card, tmp_path, sizeof(DNIE_MF_NAME) - 1, 4, file_out);
  ------------------
  |  |   69|     45|#define DNIE_MF_NAME "Master.File"
  ------------------
 1261|     45|			if (res != SC_SUCCESS) {
  ------------------
  |  |   28|     45|#define SC_SUCCESS				0
  ------------------
  |  Branch (1261:8): [True: 36, False: 9]
  ------------------
 1262|     36|				sc_unlock(card);
 1263|     36|				LOG_TEST_RET(ctx, res, "select_file(NAME) failed");
  ------------------
  |  |  174|     36|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     36|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     36|	int _ret = (r); \
  |  |  |  |  168|     36|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 36, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|     36|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1264|     36|			}
 1265|      9|			tmp_path[2] = 0;
 1266|      9|			reminder = in_path->len - 2;
 1267|      9|		} else {
 1268|      0|			tmp_path[2] = 0;
 1269|      0|			reminder = in_path->len;
 1270|      0|		}
 1271|      9|		while (reminder > 0) {
  ------------------
  |  Branch (1271:10): [True: 0, False: 9]
  ------------------
 1272|      0|			tmp_path[0] = in_path->value[in_path->len - reminder];
 1273|      0|			tmp_path[1] = in_path->value[1 + in_path->len - reminder];
 1274|      0|			sc_log(ctx, "select_file(PATH): requested:%s ", sc_dump_hex(tmp_path, 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__
  |  |  ------------------
  ------------------
 1275|      0|			res = dnie_compose_and_send_apdu(card, tmp_path, 2, 0, file_out);
 1276|      0|			if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1276:8): [True: 0, False: 0]
  ------------------
 1277|      0|				sc_unlock(card);
 1278|      0|				LOG_TEST_RET(ctx, res, "select_file(PATH) 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1279|      0|			}
 1280|      0|			reminder -= 2;
 1281|      0|		}
 1282|      9|		sc_unlock(card);
 1283|      9|		break;
 1284|      0|	case SC_PATH_TYPE_FROM_CURRENT:
  ------------------
  |  |  122|      0|#define SC_PATH_TYPE_FROM_CURRENT	4
  ------------------
  |  Branch (1284:2): [True: 0, False: 45]
  ------------------
 1285|      0|		LOG_FUNC_RETURN(ctx, SC_ERROR_NO_CARD_SUPPORT);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1286|      0|		break;
 1287|      0|	case SC_PATH_TYPE_PARENT:
  ------------------
  |  |  123|      0|#define SC_PATH_TYPE_PARENT		5
  ------------------
  |  Branch (1287:2): [True: 0, False: 45]
  ------------------
 1288|       |		/* Hey!! Manual doesn't says anything on this, but
 1289|       |		 * gscriptor shows that this type is supported
 1290|       |		 */
 1291|      0|		sc_log(ctx, "select_file(PARENT)");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1292|       |		/* according iso7816-4 sect 7.1.1 shouldn't have any parameters */
 1293|      0|		if (in_path->len != 0)
  ------------------
  |  Branch (1293:7): [True: 0, False: 0]
  ------------------
 1294|      0|			LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1295|      0|		res = dnie_compose_and_send_apdu(card, NULL, 0, 3, file_out);
 1296|      0|		break;
 1297|      0|	default:
  ------------------
  |  Branch (1297:2): [True: 0, False: 45]
  ------------------
 1298|      0|		LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1299|      0|		break;
 1300|     45|	}
 1301|       |
 1302|       |	/* as last step clear data cache and return */
 1303|      9|	dnie_clear_cache(GET_DNIE_PRIV_DATA(card));
  ------------------
  |  |   97|      9|#define GET_DNIE_PRIV_DATA(card) ((dnie_private_data_t *) ((card)->drv_data))
  ------------------
 1304|      9|	LOG_FUNC_RETURN(ctx, res);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1305|      9|}
card-dnie.c:dnie_compose_and_send_apdu:
 1129|     45|{
 1130|     45|	int res = 0;
 1131|     45|	sc_apdu_t apdu;
 1132|     45|	u8 rbuf[MAX_RESP_BUFFER_SIZE];
 1133|     45|	sc_context_t *ctx = NULL;
 1134|       |
 1135|     45|	if (!card || !card->ctx)
  ------------------
  |  Branch (1135:6): [True: 0, False: 45]
  |  Branch (1135:15): [True: 0, False: 45]
  ------------------
 1136|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1137|     45|	ctx = card->ctx;
 1138|       |
 1139|     45|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     45|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1140|       |
 1141|     45|	dnie_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, p1, 0,
  ------------------
  |  |  294|     45|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
 1142|     45|					sc_get_max_recv_size(card), pathlen,
 1143|     45|					rbuf, sizeof(rbuf), path, pathlen);
 1144|     45|	if (p1 == 3)
  ------------------
  |  Branch (1144:6): [True: 0, False: 45]
  ------------------
 1145|      0|		apdu.cse= SC_APDU_CASE_1;
  ------------------
  |  |  291|      0|#define SC_APDU_CASE_1			0x01
  ------------------
 1146|       |
 1147|     45|	if (file_out == NULL)
  ------------------
  |  Branch (1147:6): [True: 45, False: 0]
  ------------------
 1148|     45|		apdu.cse = SC_APDU_CASE_4_SHORT;
  ------------------
  |  |  294|     45|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
 1149|       |
 1150|     45|	res = sc_transmit_apdu(card, &apdu);
 1151|     45|	if ((res != SC_SUCCESS) || (file_out == NULL))
  ------------------
  |  |   28|     45|#define SC_SUCCESS				0
  ------------------
  |  Branch (1151:6): [True: 11, False: 34]
  |  Branch (1151:29): [True: 34, False: 0]
  ------------------
 1152|     45|		LOG_TEST_RET(ctx, res, "SelectFile() APDU transmit 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: 11, False: 34]
  |  |  |  |  ------------------
  |  |  |  |  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|     45|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 34]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1153|     34|	if (file_out == NULL) {
  ------------------
  |  Branch (1153:6): [True: 34, False: 0]
  ------------------
 1154|     34|		if (apdu.sw1 == 0x61)
  ------------------
  |  Branch (1154:7): [True: 0, False: 34]
  ------------------
 1155|      0|			SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, 0);
  ------------------
  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      0|	int _ret = r; \
  |  |  155|      0|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  ------------------
  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      0|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|      0|	return _ret; \
  |  |  163|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1156|     34|		SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |  153|     34|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|     34|	int _ret = r; \
  |  |  155|     34|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 34, False: 0]
  |  |  ------------------
  |  |  156|     34|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|     25|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 25, False: 9]
  |  |  ------------------
  |  |  157|     34|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|     34|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|     34|	return _ret; \
  |  |  163|     34|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1157|     34|			       sc_check_sw(card, apdu.sw1, apdu.sw2));
 1158|     34|	}
 1159|       |
 1160|       |	/* analyze response. if FCI, try to parse */
 1161|      0|	res = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1162|      0|	if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1162:6): [True: 0, False: 0]
  ------------------
 1163|      0|		LOG_TEST_RET(ctx, res, "SelectFile() check_sw 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1164|      0|	}
 1165|      0|	if ((apdu.resplen < 2) || (apdu.resp[0] == 0x00)) {
  ------------------
  |  Branch (1165:6): [True: 0, False: 0]
  |  Branch (1165:28): [True: 0, False: 0]
  ------------------
 1166|      0|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1167|      0|	}
 1168|       |
 1169|      0|	if (file_out) {
  ------------------
  |  Branch (1169:6): [True: 0, False: 0]
  ------------------
 1170|       |		/* finally process FCI response */
 1171|      0|		size_t len = apdu.resp[1];
 1172|      0|		sc_file_free(*file_out);
 1173|      0|		*file_out = sc_file_new();
 1174|      0|		if (*file_out == NULL) {
  ------------------
  |  Branch (1174:7): [True: 0, False: 0]
  ------------------
 1175|      0|			LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1176|      0|		}
 1177|      0|		if (apdu.resplen - 2 < len || len < 1) {
  ------------------
  |  Branch (1177:7): [True: 0, False: 0]
  |  Branch (1177:33): [True: 0, False: 0]
  ------------------
 1178|      0|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1179|      0|		}
 1180|      0|		res = card->ops->process_fci(card, *file_out, apdu.resp + 2, len);
 1181|      0|	}
 1182|      0|	LOG_FUNC_RETURN(ctx, res);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1183|      0|}
card-dnie.c:dnie_check_sw:
 1750|     49|{
 1751|     49|	int res = SC_SUCCESS;
  ------------------
  |  |   28|     49|#define SC_SUCCESS				0
  ------------------
 1752|     49|	int n = 0;
 1753|     49|	if (!card || !card->ctx)
  ------------------
  |  Branch (1753:6): [True: 0, False: 49]
  |  Branch (1753:15): [True: 0, False: 49]
  ------------------
 1754|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1755|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1756|       |
 1757|       |	/* check specific dnie errors */
 1758|    183|	for (n = 0; dnie_errors[n].SWs != 0; n++) {
  ------------------
  |  Branch (1758:14): [True: 140, False: 43]
  ------------------
 1759|    140|		if (dnie_errors[n].SWs == ((sw1 << 8) | sw2)) {
  ------------------
  |  Branch (1759:7): [True: 6, False: 134]
  ------------------
 1760|      6|			sc_log(card->ctx, "%s", dnie_errors[n].errorstr);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1761|      6|			return dnie_errors[n].errorno;
 1762|      6|		}
 1763|    140|	}
 1764|       |
 1765|       |	/* arriving here means check for supported iso error codes */
 1766|     43|	res = iso_ops->check_sw(card, sw1, sw2);
 1767|     43|	LOG_FUNC_RETURN(card->ctx, res);
  ------------------
  |  |  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|     30|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 30, False: 13]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1768|     43|}
card-dnie.c:dnie_card_ctl:
 1787|     11|{
 1788|     11|	int result = SC_SUCCESS;
  ------------------
  |  |   28|     11|#define SC_SUCCESS				0
  ------------------
 1789|     11|	if ((card == NULL) || (card->ctx == NULL))
  ------------------
  |  Branch (1789:6): [True: 0, False: 11]
  |  Branch (1789:24): [True: 0, False: 11]
  ------------------
 1790|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1791|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1792|     11|	if (data == NULL) {
  ------------------
  |  Branch (1792:6): [True: 0, False: 11]
  ------------------
 1793|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1794|      0|	}
 1795|     11|	switch (request) {
 1796|       |		/* obtain lifecycle status by reading card->type */
 1797|      0|	case SC_CARDCTL_LIFECYCLE_GET:
  ------------------
  |  Branch (1797:2): [True: 0, False: 11]
  ------------------
 1798|      0|		switch (card->type) {
  ------------------
  |  Branch (1798:11): [True: 0, False: 0]
  ------------------
 1799|      0|		case SC_CARD_TYPE_DNIE_ADMIN:
  ------------------
  |  Branch (1799:3): [True: 0, False: 0]
  ------------------
 1800|      0|			result = SC_CARDCTRL_LIFECYCLE_ADMIN;
 1801|      0|			break;
 1802|      0|		case SC_CARD_TYPE_DNIE_USER:
  ------------------
  |  Branch (1802:3): [True: 0, False: 0]
  ------------------
 1803|      0|			result = SC_CARDCTRL_LIFECYCLE_USER;
 1804|      0|			break;
 1805|      0|		case SC_CARD_TYPE_DNIE_BLANK:
  ------------------
  |  Branch (1805:3): [True: 0, False: 0]
  ------------------
 1806|      0|		case SC_CARD_TYPE_DNIE_TERMINATED:
  ------------------
  |  Branch (1806:3): [True: 0, False: 0]
  ------------------
 1807|      0|			result = SC_CARDCTRL_LIFECYCLE_OTHER;
 1808|      0|			break;
 1809|      0|		}
 1810|      0|		*(int *)data = result;
 1811|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1812|       |		/* call card to obtain serial number */
 1813|      0|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (1813:2): [True: 0, False: 11]
  ------------------
 1814|      0|		result = dnie_get_serialnr(card, (sc_serial_number_t *) data);
 1815|      0|		LOG_FUNC_RETURN(card->ctx, result);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1816|      0|	case SC_CARDCTL_DNIE_GENERATE_KEY:
  ------------------
  |  Branch (1816:2): [True: 0, False: 11]
  ------------------
 1817|       |		/* some reports says that this card supports genkey */
 1818|      0|		result = dnie_generate_key(card, data);
 1819|      0|		LOG_FUNC_RETURN(card->ctx, result);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1820|      0|	case SC_CARDCTL_DNIE_GET_INFO:
  ------------------
  |  Branch (1820:2): [True: 0, False: 11]
  ------------------
 1821|       |		/* retrieve name, surname and eid number */
 1822|      0|		result = dnie_get_info(card, data);
 1823|      0|		LOG_FUNC_RETURN(card->ctx, result);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1824|     11|	default:
  ------------------
  |  Branch (1824:2): [True: 11, False: 0]
  ------------------
 1825|       |		/* default: unsupported function */
 1826|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1827|     11|	}
 1828|     11|}

sc_get_dtrust_driver:
 1056|  16.3k|{
 1057|  16.3k|	if (iso_ops == NULL)
  ------------------
  |  Branch (1057:6): [True: 1, False: 16.3k]
  ------------------
 1058|      1|		iso_ops = sc_get_iso7816_driver()->ops;
 1059|       |
 1060|  16.3k|	dtrust_ops = *iso_ops;
 1061|  16.3k|	dtrust_ops.match_card = dtrust_match_card;
 1062|  16.3k|	dtrust_ops.init = dtrust_init;
 1063|  16.3k|	dtrust_ops.finish = dtrust_finish;
 1064|  16.3k|	dtrust_ops.pin_cmd = dtrust_pin_cmd;
 1065|  16.3k|	dtrust_ops.set_security_env = dtrust_set_security_env;
 1066|  16.3k|	dtrust_ops.compute_signature = dtrust_compute_signature;
 1067|  16.3k|	dtrust_ops.decipher = dtrust_decipher;
 1068|  16.3k|	dtrust_ops.logout = dtrust_logout;
 1069|       |
 1070|  16.3k|	return &dtrust_drv;
 1071|  16.3k|}
card-dtrust.c:dtrust_match_card:
  234|  15.8k|{
  235|  15.8k|	if (_sc_match_atr(card, dtrust_atrs, &card->type) < 0)
  ------------------
  |  Branch (235:6): [True: 15.4k, False: 404]
  ------------------
  236|  15.4k|		return 0;
  237|       |
  238|    404|	if (_dtrust_match_cardos(card) != SC_SUCCESS)
  ------------------
  |  |   28|    404|#define SC_SUCCESS				0
  ------------------
  |  Branch (238:6): [True: 403, False: 1]
  ------------------
  239|    403|		return 0;
  240|       |
  241|      1|	if (_dtrust_match_profile(card) != SC_SUCCESS)
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
  |  Branch (241:6): [True: 1, False: 0]
  ------------------
  242|      1|		return 0;
  243|       |
  244|      0|	sc_log(card->ctx, "D-Trust Signature Card");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  245|       |
  246|      0|	return 1;
  247|      1|}
card-dtrust.c:_dtrust_match_cardos:
  114|    404|{
  115|    404|	int r;
  116|    404|	size_t prodlen;
  117|    404|	u8 buf[32];
  118|       |
  119|       |	/* check OS version */
  120|    404|	r = sc_get_data(card, 0x0182, buf, 32);
  121|    404|	LOG_TEST_RET(card->ctx, r, "OS version check failed");
  ------------------
  |  |  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: 372, False: 32]
  |  |  |  |  ------------------
  |  |  |  |  169|    372|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    372|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    372|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    372|		return _ret; \
  |  |  |  |  172|    372|	} \
  |  |  |  |  173|    404|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 32]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  122|       |
  123|     32|	if (card->type == SC_CARD_TYPE_DTRUST_V4_1_STD) {
  ------------------
  |  Branch (123:6): [True: 32, False: 0]
  ------------------
  124|     32|		if (r != 2 || buf[0] != 0xc9 || buf[1] != 0x04)
  ------------------
  |  Branch (124:7): [True: 13, False: 19]
  |  Branch (124:17): [True: 7, False: 12]
  |  Branch (124:35): [True: 2, False: 10]
  ------------------
  125|     22|			return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|     22|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  126|     32|	} 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|     10|	r = sc_get_data(card, 0x0180, buf, 32);
  133|     10|	LOG_TEST_RET(card->ctx, r, "Product name check 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: 2, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  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|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  134|       |
  135|      8|	prodlen = (size_t)r;
  136|      8|	if (card->type == SC_CARD_TYPE_DTRUST_V4_1_STD) {
  ------------------
  |  Branch (136:6): [True: 8, False: 0]
  ------------------
  137|      8|		if (prodlen != strlen("CardOS V5.4     2019") + 1 || memcmp(buf, "CardOS V5.4     2019", prodlen))
  ------------------
  |  Branch (137:7): [True: 1, False: 7]
  |  Branch (137:56): [True: 6, False: 1]
  ------------------
  138|      7|			return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|      7|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  139|      8|	} 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|      1|	return SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
  145|      8|}
card-dtrust.c:_dtrust_match_profile:
  149|      1|{
  150|      1|	sc_path_t cia_path;
  151|      1|	int r;
  152|      1|	u8 buf[SC_MAX_APDU_BUFFER_SIZE];
  153|      1|	size_t slen, plen;
  154|      1|	const u8 *sp, *pp;
  155|      1|	char *name;
  156|       |
  157|      1|	sc_format_path("5032", &cia_path);
  158|      1|	cia_path.aid.len = sizeof(cia_path.aid.value);
  159|      1|	r = sc_hex_to_bin("E8:28:BD:08:0F:A0:00:00:01:67:45:53:49:47:4E", (u8 *)&cia_path.aid.value, &cia_path.aid.len);
  160|      1|	LOG_TEST_RET(card->ctx, r, "Formatting AID 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  161|       |
  162|      1|	r = sc_select_file(card, &cia_path, NULL);
  163|      1|	LOG_TEST_RET(card->ctx, r, "Selecting CIA path 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  164|       |
  165|      0|	r = sc_read_binary(card, 0, buf, SC_MAX_APDU_BUFFER_SIZE, NULL);
  ------------------
  |  |   34|      0|#define SC_MAX_APDU_BUFFER_SIZE		261 /* takes account of: CLA INS P1 P2 Lc [255 byte of data] Le */
  ------------------
  166|      0|	LOG_TEST_RET(card->ctx, r, "Reading CIA information 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  167|       |
  168|      0|	sp = sc_asn1_find_tag(card->ctx, buf, r, 0x30, &slen);
  169|      0|	if (sp == NULL)
  ------------------
  |  Branch (169:6): [True: 0, False: 0]
  ------------------
  170|      0|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|      0|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  171|       |
  172|       |	/* check vendor */
  173|      0|	pp = sc_asn1_find_tag(card->ctx, sp, slen, 0x0c, &plen);
  174|      0|	if (pp == NULL)
  ------------------
  |  Branch (174:6): [True: 0, False: 0]
  ------------------
  175|      0|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|      0|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  176|       |
  177|      0|	if (plen != 16 || memcmp(pp, "D-TRUST GmbH (C)", 16))
  ------------------
  |  Branch (177:6): [True: 0, False: 0]
  |  Branch (177:20): [True: 0, False: 0]
  ------------------
  178|      0|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|      0|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  179|       |
  180|       |	/* check profile */
  181|      0|	pp = sc_asn1_find_tag(card->ctx, sp, slen, 0x80, &plen);
  182|      0|	if (pp == NULL)
  ------------------
  |  Branch (182:6): [True: 0, False: 0]
  ------------------
  183|      0|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|      0|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  184|       |
  185|       |	/*
  186|       |	 * The profile string contains (two) additional characters. They depend
  187|       |	 * on the production process, but aren't relevant for determining the
  188|       |	 * card profile.
  189|       |	 */
  190|      0|	if (card->type == SC_CARD_TYPE_DTRUST_V4_1_STD) {
  ------------------
  |  Branch (190:6): [True: 0, False: 0]
  ------------------
  191|      0|		if (plen >= 27 && !memcmp(pp, "D-TRUST Card 4.1 Std. RSA 2", 27))
  ------------------
  |  Branch (191:7): [True: 0, False: 0]
  |  Branch (191:21): [True: 0, False: 0]
  ------------------
  192|      0|			card->type = SC_CARD_TYPE_DTRUST_V4_1_STD;
  193|      0|		else if (plen >= 28 && !memcmp(pp, "D-TRUST Card 4.1 Multi ECC 2", 28))
  ------------------
  |  Branch (193:12): [True: 0, False: 0]
  |  Branch (193:26): [True: 0, False: 0]
  ------------------
  194|      0|			card->type = SC_CARD_TYPE_DTRUST_V4_1_MULTI;
  195|      0|		else if (plen >= 27 && !memcmp(pp, "D-TRUST Card 4.1 M100 ECC 2", 27))
  ------------------
  |  Branch (195:12): [True: 0, False: 0]
  |  Branch (195:26): [True: 0, False: 0]
  ------------------
  196|      0|			card->type = SC_CARD_TYPE_DTRUST_V4_1_M100;
  197|      0|		else if (plen >= 27 && !memcmp(pp, "D-TRUST Card 4.4 Std. RSA 2", 27))
  ------------------
  |  Branch (197:12): [True: 0, False: 0]
  |  Branch (197:26): [True: 0, False: 0]
  ------------------
  198|      0|			card->type = SC_CARD_TYPE_DTRUST_V4_4_STD;
  199|      0|		else if (plen >= 28 && !memcmp(pp, "D-TRUST Card 4.4 Multi ECC 2", 28))
  ------------------
  |  Branch (199:12): [True: 0, False: 0]
  |  Branch (199:26): [True: 0, False: 0]
  ------------------
  200|      0|			card->type = SC_CARD_TYPE_DTRUST_V4_4_MULTI;
  201|      0|		else
  202|      0|			return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|      0|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  203|      0|	} else if (card->type == SC_CARD_TYPE_DTRUST_V5_1_STD) {
  ------------------
  |  Branch (203:13): [True: 0, False: 0]
  ------------------
  204|      0|		if (plen >= 27 && !memcmp(pp, "D-TRUST Card 5.1 Std. RSA 2", 27))
  ------------------
  |  Branch (204:7): [True: 0, False: 0]
  |  Branch (204:21): [True: 0, False: 0]
  ------------------
  205|      0|			card->type = SC_CARD_TYPE_DTRUST_V5_1_STD;
  206|      0|		else if (plen >= 28 && !memcmp(pp, "D-TRUST Card 5.1 Multi ECC 2", 28))
  ------------------
  |  Branch (206:12): [True: 0, False: 0]
  |  Branch (206:26): [True: 0, False: 0]
  ------------------
  207|      0|			card->type = SC_CARD_TYPE_DTRUST_V5_1_MULTI;
  208|      0|		else if (plen >= 27 && !memcmp(pp, "D-TRUST Card 5.1 M100 ECC 2", 27))
  ------------------
  |  Branch (208:12): [True: 0, False: 0]
  |  Branch (208:26): [True: 0, False: 0]
  ------------------
  209|      0|			card->type = SC_CARD_TYPE_DTRUST_V5_1_M100;
  210|      0|		else if (plen >= 27 && !memcmp(pp, "D-TRUST Card 5.4 Std. RSA 2", 27))
  ------------------
  |  Branch (210:12): [True: 0, False: 0]
  |  Branch (210:26): [True: 0, False: 0]
  ------------------
  211|      0|			card->type = SC_CARD_TYPE_DTRUST_V5_4_STD;
  212|      0|		else if (plen >= 28 && !memcmp(pp, "D-TRUST Card 5.4 Multi ECC 2", 28))
  ------------------
  |  Branch (212:12): [True: 0, False: 0]
  |  Branch (212:26): [True: 0, False: 0]
  ------------------
  213|      0|			card->type = SC_CARD_TYPE_DTRUST_V5_4_MULTI;
  214|      0|		else
  215|      0|			return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|      0|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  216|      0|	}
  217|       |
  218|      0|	name = malloc(plen + 1);
  219|      0|	if (name == NULL)
  ------------------
  |  Branch (219:6): [True: 0, False: 0]
  ------------------
  220|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  221|      0|	memcpy(name, pp, plen);
  222|      0|	name[plen] = '\0';
  223|      0|	card->name = name;
  224|       |
  225|      0|	sc_log(card->ctx, "found %s", card->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__
  |  |  ------------------
  ------------------
  226|       |
  227|      0|	return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  228|      0|}

sc_get_edo_driver:
  306|  16.3k|struct sc_card_driver* sc_get_edo_driver(void) {
  307|  16.3k|	edo_ops = *sc_get_iso7816_driver()->ops;
  308|  16.3k|	edo_ops.match_card = edo_match_card;
  309|  16.3k|	edo_ops.init = edo_init;
  310|  16.3k|	edo_ops.select_file = edo_select_file;
  311|  16.3k|	edo_ops.set_security_env = edo_set_security_env;
  312|  16.3k|	edo_ops.compute_signature = edo_compute_signature;
  313|  16.3k|	edo_ops.logout = edo_logout;
  314|       |
  315|  16.3k|	return &edo_drv;
  316|  16.3k|}
card-edo.c:edo_match_card:
   62|  9.15k|static int edo_match_card(sc_card_t* card) {
   63|  9.15k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
   64|  9.15k|	if (_sc_match_atr(card, edo_atrs, &card->type) >= 0) {
  ------------------
  |  Branch (64:6): [True: 0, False: 9.15k]
  ------------------
   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|  9.15k|	LOG_FUNC_RETURN(card->ctx, 0);
  ------------------
  |  |  164|  9.15k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  9.15k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  9.15k|	int _ret = r; \
  |  |  |  |  155|  9.15k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 9.15k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  9.15k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 9.15k]
  |  |  |  |  ------------------
  |  |  |  |  157|  9.15k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  9.15k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|  9.15k|	return _ret; \
  |  |  |  |  163|  9.15k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   69|  9.15k|}

sc_get_entersafe_driver:
 1579|  16.3k|{
 1580|  16.3k|	return sc_get_driver();
 1581|  16.3k|}
card-entersafe.c:sc_get_driver:
 1553|  16.3k|{
 1554|  16.3k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 1555|       |
 1556|  16.3k|	if (iso_ops == NULL)
  ------------------
  |  Branch (1556:6): [True: 1, False: 16.3k]
  ------------------
 1557|      1|		iso_ops = iso_drv->ops;
 1558|       |
 1559|  16.3k|	entersafe_ops = *iso_drv->ops;
 1560|  16.3k|	entersafe_ops.match_card = entersafe_match_card;
 1561|  16.3k|	entersafe_ops.init = entersafe_init;
 1562|  16.3k|	entersafe_ops.read_binary = entersafe_read_binary;
 1563|  16.3k|	entersafe_ops.write_binary = NULL;
 1564|  16.3k|	entersafe_ops.update_binary = entersafe_update_binary;
 1565|  16.3k|	entersafe_ops.select_file = entersafe_select_file;
 1566|  16.3k|	entersafe_ops.restore_security_env = entersafe_restore_security_env;
 1567|  16.3k|	entersafe_ops.set_security_env = entersafe_set_security_env;
 1568|  16.3k|	entersafe_ops.decipher = entersafe_decipher;
 1569|  16.3k|	entersafe_ops.compute_signature = entersafe_compute_signature;
 1570|  16.3k|	entersafe_ops.create_file = entersafe_create_file;
 1571|       |	entersafe_ops.delete_file = NULL;
 1572|  16.3k|	entersafe_ops.pin_cmd = entersafe_pin_cmd;
 1573|  16.3k|	entersafe_ops.card_ctl = entersafe_card_ctl_2048;
 1574|  16.3k|	entersafe_ops.process_fci = entersafe_process_fci;
 1575|  16.3k|	return &entersafe_drv;
 1576|  16.3k|}
card-entersafe.c:entersafe_match_card:
  135|  12.0k|{
  136|  12.0k|	int i;
  137|  12.0k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  12.0k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  12.0k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  12.0k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 12.0k]
  |  |  ------------------
  ------------------
  138|       |
  139|  12.0k|	i = _sc_match_atr(card, entersafe_atrs, &card->type);
  140|  12.0k|	if (i < 0)
  ------------------
  |  Branch (140:6): [True: 11.8k, False: 253]
  ------------------
  141|  11.8k|		return 0;
  142|       |
  143|    253|	return 1;
  144|  12.0k|}
card-entersafe.c:entersafe_init:
  147|    253|{
  148|    253|	unsigned int flags;
  149|       |
  150|    253|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    253|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    253|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    253|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 253]
  |  |  ------------------
  ------------------
  151|       |
  152|    253|	card->name = "entersafe";
  153|    253|	card->cla  = 0x00;
  154|    253|	card->drv_data = NULL;
  155|       |
  156|    253|	flags = SC_ALGORITHM_ONBOARD_KEY_GEN | SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |   93|    253|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
              	flags = SC_ALGORITHM_ONBOARD_KEY_GEN | SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  102|    253|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
              	flags = SC_ALGORITHM_ONBOARD_KEY_GEN | SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  133|    253|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  157|       |
  158|    253|	_sc_card_add_rsa_alg(card, 512, flags, 0);
  159|    253|	_sc_card_add_rsa_alg(card, 768, flags, 0);
  160|    253|	_sc_card_add_rsa_alg(card, 1024, flags, 0);
  161|    253|	_sc_card_add_rsa_alg(card, 2048, flags, 0);
  162|       |
  163|    253|	card->caps = SC_CARD_CAP_RNG;
  ------------------
  |  |  550|    253|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  164|       |
  165|       |	/* we need read_binary&friends with max 224 bytes per read */
  166|    253|	card->max_send_size = 224;
  167|    253|	card->max_recv_size = 224;
  168|    253|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
  ------------------
  |  |  153|    253|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    253|	int _ret = r; \
  |  |  155|    253|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 253, False: 0]
  |  |  ------------------
  |  |  156|    253|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 253]
  |  |  ------------------
  |  |  157|    253|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    253|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|    253|	return _ret; \
  |  |  163|    253|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  169|    253|}
card-entersafe.c:entersafe_read_binary:
  427|    730|{
  428|    730|	sc_apdu_t apdu;
  429|    730|	u8 recvbuf[SC_MAX_APDU_BUFFER_SIZE];
  430|    730|	int r;
  431|       |
  432|    730|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    730|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    730|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    730|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 730]
  |  |  ------------------
  ------------------
  433|       |
  434|    730|	if (count > card->max_recv_size)
  ------------------
  |  Branch (434:6): [True: 0, False: 730]
  ------------------
  435|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  436|    730|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xB0, (idx >> 8) & 0xFF, idx & 0xFF);
  ------------------
  |  |  292|    730|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  437|       |
  438|    730|	apdu.cla = idx > 0x7fff ? 0x80 : 0x00;
  ------------------
  |  Branch (438:13): [True: 4, False: 726]
  ------------------
  439|    730|	apdu.le = count;
  440|    730|	apdu.resplen = count;
  441|    730|	apdu.resp = recvbuf;
  442|       |
  443|    730|	r = entersafe_transmit_apdu(card, &apdu, 0, 0, 0, 0);
  444|    730|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    730|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    730|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    730|	int _ret = (r); \
  |  |  |  |  168|    730|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 5, False: 725]
  |  |  |  |  ------------------
  |  |  |  |  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|    730|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 725]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  445|    725|	if (apdu.resplen == 0)
  ------------------
  |  Branch (445:6): [True: 25, False: 700]
  ------------------
  446|     25|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  153|     25|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|     25|	int _ret = r; \
  |  |  155|     25|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 25, False: 0]
  |  |  ------------------
  |  |  156|     25|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|     24|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 24, False: 1]
  |  |  ------------------
  |  |  157|     25|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|     25|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|     25|	return _ret; \
  |  |  163|     25|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  447|    700|	memcpy(buf, recvbuf, apdu.resplen);
  448|       |
  449|    700|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, (int)apdu.resplen);
  ------------------
  |  |  153|    700|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    700|	int _ret = r; \
  |  |  155|    700|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 700]
  |  |  ------------------
  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  ------------------
  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    700|	} else { \
  |  |  159|    700|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|    700|			"returning with: %d\n", _ret); \
  |  |  161|    700|	} \
  |  |  162|    700|	return _ret; \
  |  |  163|    700|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  450|    700|}
card-entersafe.c:entersafe_transmit_apdu:
  370|  2.49k|{
  371|  2.49k|	u8 *cipher_data = NULL, *mac_data = NULL;
  372|  2.49k|	size_t cipher_data_size, mac_data_size, blocks;
  373|  2.49k|	int r = SC_SUCCESS;
  ------------------
  |  |   28|  2.49k|#define SC_SUCCESS				0
  ------------------
  374|  2.49k|	u8 *sbuf = NULL;
  375|  2.49k|	size_t ssize = 0;
  376|       |
  377|  2.49k|	if (card == NULL || apdu == NULL)
  ------------------
  |  Branch (377:6): [True: 0, False: 2.49k]
  |  Branch (377:22): [True: 0, False: 2.49k]
  ------------------
  378|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  379|       |
  380|  2.49k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  2.49k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  2.49k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  2.49k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 2.49k]
  |  |  ------------------
  ------------------
  381|       |
  382|  2.49k|	if ((cipher || mac) && (!key || (keylen != 8 && keylen != 16)))
  ------------------
  |  Branch (382:7): [True: 111, False: 2.38k]
  |  Branch (382:17): [True: 147, False: 2.24k]
  |  Branch (382:26): [True: 0, False: 258]
  |  Branch (382:35): [True: 177, False: 81]
  |  Branch (382:50): [True: 0, False: 177]
  ------------------
  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|  2.49k|	r = sc_apdu_get_octets(card->ctx, apdu, &sbuf, &ssize, SC_PROTO_RAW);
  ------------------
  |  |  354|  2.49k|#define SC_PROTO_RAW		0x00001000
  ------------------
  386|  2.49k|	if (r == SC_SUCCESS)
  ------------------
  |  |   28|  2.49k|#define SC_SUCCESS				0
  ------------------
  |  Branch (386:6): [True: 2.49k, False: 0]
  ------------------
  387|  2.49k|		sc_apdu_log(card->ctx, sbuf, ssize, 1);
  ------------------
  |  |  292|  2.49k|	sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, is_outgoing != 0 ? "Outgoing APDU" : "Incoming APDU", data, len)
  |  |  ------------------
  |  |  |  |  127|  4.99k|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (127:65): [True: 2.49k, Folded]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  388|  2.49k|	if (sbuf)
  ------------------
  |  Branch (388:6): [True: 2.49k, False: 0]
  ------------------
  389|  2.49k|		free(sbuf);
  390|       |
  391|  2.49k|	if (cipher) {
  ------------------
  |  Branch (391:6): [True: 111, False: 2.38k]
  ------------------
  392|    111|		blocks = (apdu->lc + 2) / 8 + 1;
  393|    111|		cipher_data_size = blocks * 8;
  394|    111|		cipher_data = malloc(cipher_data_size);
  395|    111|		if (!cipher_data) {
  ------------------
  |  Branch (395:7): [True: 0, False: 111]
  ------------------
  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|    111|		if ((r = entersafe_cipher_apdu(card, apdu, key, keylen, cipher_data, cipher_data_size)) < 0)
  ------------------
  |  Branch (400:7): [True: 0, False: 111]
  ------------------
  401|      0|			goto out;
  402|    111|	}
  403|  2.49k|	if (mac) {
  ------------------
  |  Branch (403:6): [True: 258, False: 2.24k]
  ------------------
  404|    258|		mac_data_size = apdu->lc + 4;
  405|    258|		mac_data = malloc(mac_data_size);
  406|    258|		if (!mac_data) {
  ------------------
  |  Branch (406:7): [True: 0, False: 258]
  ------------------
  407|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  408|      0|			goto out;
  409|      0|		}
  410|    258|		r = entersafe_mac_apdu(card, apdu, key, keylen, mac_data, mac_data_size);
  411|    258|		if (r < 0)
  ------------------
  |  Branch (411:7): [True: 111, False: 147]
  ------------------
  412|    111|			goto out;
  413|    258|	}
  414|       |
  415|  2.38k|	r = sc_transmit_apdu(card, apdu);
  416|       |
  417|  2.49k|out:
  418|  2.49k|	free(cipher_data);
  419|  2.49k|	free(mac_data);
  420|       |
  421|  2.49k|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|  2.49k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  2.49k|	int _ret = r; \
  |  |  155|  2.49k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 2.49k, False: 0]
  |  |  ------------------
  |  |  156|  2.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|    131|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 131, False: 2.36k]
  |  |  ------------------
  |  |  157|  2.49k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|  2.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|  2.49k|	return _ret; \
  |  |  163|  2.49k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  422|  2.49k|}
card-entersafe.c:entersafe_cipher_apdu:
  197|    111|{
  198|    111|	EVP_CIPHER_CTX *ctx = NULL;
  199|    111|	EVP_CIPHER *alg = NULL;
  200|       |
  201|    111|	u8 iv[8] = {0};
  202|    111|	int len;
  203|       |
  204|    111|	if (card == NULL || apdu == NULL || key == NULL || buff == NULL)
  ------------------
  |  Branch (204:6): [True: 0, False: 111]
  |  Branch (204:22): [True: 0, False: 111]
  |  Branch (204:38): [True: 0, False: 111]
  |  Branch (204:53): [True: 0, False: 111]
  ------------------
  205|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  206|       |
  207|    111|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    111|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    111|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    111|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 111]
  |  |  ------------------
  ------------------
  208|       |
  209|       |	/* padding as 0x80 0x00 0x00...... */
  210|    111|	memset(buff, 0, buffsize);
  211|    111|	buff[0] = apdu->lc;
  212|    111|	memcpy(buff + 1, apdu->data, apdu->lc);
  213|    111|	buff[apdu->lc + 1] = 0x80;
  214|       |
  215|    111|	ctx = EVP_CIPHER_CTX_new();
  216|    111|	if (ctx == NULL) {
  ------------------
  |  Branch (216:6): [True: 0, False: 111]
  ------------------
  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|    111|	EVP_CIPHER_CTX_set_padding(ctx, 0);
  221|       |
  222|    111|	if (keylen == 8) {
  ------------------
  |  Branch (222:6): [True: 0, False: 111]
  ------------------
  223|      0|		alg = sc_evp_cipher(card->ctx, "DES-ECB");
  224|    111|	} else if (keylen == 16) {
  ------------------
  |  Branch (224:13): [True: 111, False: 0]
  ------------------
  225|    111|		alg = sc_evp_cipher(card->ctx, "DES-EDE");
  226|    111|	} 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|    111|	if (EVP_EncryptInit_ex(ctx, alg, NULL, key, iv) != 1) {
  ------------------
  |  Branch (231:6): [True: 0, False: 111]
  ------------------
  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|    111|	len = (int)apdu->lc;
  240|    111|	if (!EVP_EncryptUpdate(ctx, buff, &len, buff, (int)buffsize)) {
  ------------------
  |  Branch (240:6): [True: 0, False: 111]
  ------------------
  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|    111|	apdu->lc = len;
  248|       |
  249|    111|	sc_evp_cipher_free(alg);
  250|    111|	EVP_CIPHER_CTX_free(ctx);
  251|       |
  252|    111|	if (apdu->lc != buffsize) {
  ------------------
  |  Branch (252:6): [True: 0, False: 111]
  ------------------
  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|    111|	apdu->data = buff;
  258|    111|	apdu->datalen = apdu->lc;
  259|       |
  260|    111|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  261|    111|}
card-entersafe.c:entersafe_mac_apdu:
  266|    258|{
  267|    258|	int r;
  268|    258|	u8 iv[8];
  269|    258|	u8 *tmp = NULL, *tmp_rounded = NULL;
  270|    258|	size_t tmpsize = 0, tmpsize_rounded = 0;
  271|    258|	int outl = 0;
  272|    258|	EVP_CIPHER_CTX *ctx = NULL;
  273|    258|	EVP_CIPHER *alg = NULL;
  274|       |
  275|    258|	if (card == NULL || apdu == NULL || key == NULL || buff == NULL)
  ------------------
  |  Branch (275:6): [True: 0, False: 258]
  |  Branch (275:22): [True: 0, False: 258]
  |  Branch (275:38): [True: 0, False: 258]
  |  Branch (275:53): [True: 0, False: 258]
  ------------------
  276|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  277|       |
  278|    258|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  279|       |
  280|    258|	if (apdu->cse != SC_APDU_CASE_3_SHORT)
  ------------------
  |  |  293|    258|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  |  Branch (280:6): [True: 0, False: 258]
  ------------------
  281|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  282|    258|	if (keylen != 8 && keylen != 16)
  ------------------
  |  Branch (282:6): [True: 177, False: 81]
  |  Branch (282:21): [True: 0, False: 177]
  ------------------
  283|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  284|       |
  285|    258|	r = entersafe_gen_random(card, iv, sizeof(iv));
  286|    258|	LOG_TEST_RET(card->ctx, r, "entersafe gen random 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: 111, False: 147]
  |  |  |  |  ------------------
  |  |  |  |  169|    111|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    111|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    111|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    111|		return _ret; \
  |  |  |  |  172|    111|	} \
  |  |  |  |  173|    258|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 147]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  287|       |
  288|       |	/* encode the APDU in the buffer */
  289|    147|	if ((r = sc_apdu_get_octets(card->ctx, apdu, &tmp, &tmpsize, SC_PROTO_RAW)) != SC_SUCCESS)
  ------------------
  |  |  354|    147|#define SC_PROTO_RAW		0x00001000
  ------------------
              	if ((r = sc_apdu_get_octets(card->ctx, apdu, &tmp, &tmpsize, SC_PROTO_RAW)) != SC_SUCCESS)
  ------------------
  |  |   28|    147|#define SC_SUCCESS				0
  ------------------
  |  Branch (289:6): [True: 0, False: 147]
  ------------------
  290|      0|		goto out;
  291|       |
  292|       |	/* round to 8 */
  293|    147|	tmpsize_rounded = (tmpsize / 8 + 1) * 8;
  294|       |
  295|    147|	tmp_rounded = malloc(tmpsize_rounded);
  296|    147|	if (tmp_rounded == NULL) {
  ------------------
  |  Branch (296:6): [True: 0, False: 147]
  ------------------
  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|    147|	memset(tmp_rounded, 0, tmpsize_rounded);
  303|    147|	memcpy(tmp_rounded, tmp, tmpsize);
  304|    147|	tmp_rounded[4] += 4;
  305|    147|	tmp_rounded[tmpsize] = 0x80;
  306|       |
  307|       |	/* block_size-1 blocks*/
  308|    147|	ctx = EVP_CIPHER_CTX_new();
  309|    147|	if (ctx == NULL) {
  ------------------
  |  Branch (309:6): [True: 0, False: 147]
  ------------------
  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|    147|	EVP_CIPHER_CTX_set_padding(ctx, 0);
  315|    147|	alg = sc_evp_cipher(card->ctx, "DES-CBC");
  316|    147|	if (!alg ||
  ------------------
  |  Branch (316:6): [True: 0, False: 147]
  ------------------
  317|    147|			EVP_EncryptInit_ex(ctx, alg, NULL, key, iv) != 1) {
  ------------------
  |  Branch (317:4): [True: 0, False: 147]
  ------------------
  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|    147|	if (tmpsize_rounded > 8) {
  ------------------
  |  Branch (323:6): [True: 143, False: 4]
  ------------------
  324|    143|		if (!EVP_EncryptUpdate(ctx, tmp_rounded, &outl, tmp_rounded, (int)tmpsize_rounded - 8)) {
  ------------------
  |  Branch (324:7): [True: 0, False: 143]
  ------------------
  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|    143|	}
  330|       |	/* last block */
  331|    147|	if (keylen == 8) {
  ------------------
  |  Branch (331:6): [True: 60, False: 87]
  ------------------
  332|     60|		if (!EVP_EncryptUpdate(ctx, tmp_rounded + outl, &outl, tmp_rounded + outl, 8)) {
  ------------------
  |  Branch (332:7): [True: 0, False: 60]
  ------------------
  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|     87|	} else {
  338|     87|		if (EVP_EncryptInit_ex(ctx, EVP_des_ede_cbc(), NULL, key, tmp_rounded + outl - 8) != 1 ||
  ------------------
  |  Branch (338:7): [True: 0, False: 87]
  ------------------
  339|     87|				!EVP_EncryptUpdate(ctx, tmp_rounded + outl, &outl, tmp_rounded + outl, 8)) {
  ------------------
  |  Branch (339:5): [True: 0, False: 87]
  ------------------
  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|     87|	}
  345|       |
  346|    147|	if (apdu->lc + 4 > buffsize) {
  ------------------
  |  Branch (346:6): [True: 0, False: 147]
  ------------------
  347|      0|		r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  348|      0|		goto out;
  349|      0|	}
  350|       |
  351|    147|	memcpy(buff, apdu->data, apdu->lc);
  352|       |	/* use first 4 bytes of last block as mac value */
  353|    147|	memcpy(buff + apdu->lc, tmp_rounded + tmpsize_rounded - 8, 4);
  354|    147|	apdu->data = buff;
  355|    147|	apdu->lc += 4;
  356|    147|	apdu->datalen = apdu->lc;
  357|       |
  358|    147|out:
  359|    147|	free(tmp);
  360|    147|	free(tmp_rounded);
  361|    147|	sc_evp_cipher_free(alg);
  362|    147|	EVP_CIPHER_CTX_free(ctx);
  363|       |
  364|    147|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|    147|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    147|	int _ret = r; \
  |  |  155|    147|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 147, False: 0]
  |  |  ------------------
  |  |  156|    147|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 147]
  |  |  ------------------
  |  |  157|    147|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    147|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|    147|	return _ret; \
  |  |  163|    147|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  365|    147|}
card-entersafe.c:entersafe_gen_random:
  172|    258|{
  173|    258|	int r = SC_SUCCESS;
  ------------------
  |  |   28|    258|#define SC_SUCCESS				0
  ------------------
  174|    258|	u8 rbuf[SC_MAX_APDU_BUFFER_SIZE] = {0};
  175|    258|	sc_apdu_t apdu;
  176|       |
  177|    258|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  178|       |
  179|    258|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0x84, 0x00, 0x00);
  ------------------
  |  |  292|    258|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  180|    258|	apdu.resp = rbuf;
  181|    258|	apdu.le = size;
  182|    258|	apdu.resplen = sizeof(rbuf);
  183|       |
  184|    258|	r = sc_transmit_apdu(card, &apdu);
  185|    258|	LOG_TEST_RET(card->ctx, r, "entersafe gen random 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: 11, False: 247]
  |  |  |  |  ------------------
  |  |  |  |  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|    258|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 247]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  186|       |
  187|    247|	if (apdu.resplen != size)
  ------------------
  |  Branch (187:6): [True: 100, False: 147]
  ------------------
  188|    247|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  164|    100|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  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|    100|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 100, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  189|    147|	memcpy(buff, rbuf, size);
  190|       |
  191|    147|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    147|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    147|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    147|	int _ret = r; \
  |  |  |  |  155|    147|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 147, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    147|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 147]
  |  |  |  |  ------------------
  |  |  |  |  157|    147|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    147|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    147|	return _ret; \
  |  |  |  |  163|    147|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  192|    147|}
card-entersafe.c:entersafe_update_binary:
  455|  1.07k|{
  456|  1.07k|	sc_apdu_t apdu;
  457|  1.07k|	int r;
  458|       |
  459|  1.07k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  1.07k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  1.07k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  1.07k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 1.07k]
  |  |  ------------------
  ------------------
  460|       |
  461|  1.07k|	if (count > card->max_send_size)
  ------------------
  |  Branch (461:6): [True: 0, False: 1.07k]
  ------------------
  462|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  463|       |
  464|  1.07k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xD6, (idx >> 8) & 0xFF, idx & 0xFF);
  ------------------
  |  |  293|  1.07k|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  465|  1.07k|	apdu.cla = idx > 0x7fff ? 0x80 : 0x00;
  ------------------
  |  Branch (465:13): [True: 4, False: 1.06k]
  ------------------
  466|  1.07k|	apdu.lc = count;
  467|  1.07k|	apdu.datalen = count;
  468|  1.07k|	apdu.data = buf;
  469|       |
  470|  1.07k|	r = entersafe_transmit_apdu(card, &apdu, 0, 0, 0, 0);
  471|  1.07k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  1.07k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.07k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.07k|	int _ret = (r); \
  |  |  |  |  168|  1.07k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 1.06k]
  |  |  |  |  ------------------
  |  |  |  |  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.07k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.06k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  472|  1.06k|	LOG_TEST_RET(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2),
  ------------------
  |  |  174|  1.06k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.06k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.06k|	int _ret = (r); \
  |  |  |  |  168|  1.06k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 36, False: 1.03k]
  |  |  |  |  ------------------
  |  |  |  |  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|  1.06k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.03k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  473|  1.03k|		    "Card returned error");
  474|  1.03k|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, (int)count);
  ------------------
  |  |  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: 0, False: 1.03k]
  |  |  ------------------
  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define 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.03k|	} else { \
  |  |  159|  1.03k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|  1.03k|			"returning with: %d\n", _ret); \
  |  |  161|  1.03k|	} \
  |  |  162|  1.03k|	return _ret; \
  |  |  163|  1.03k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  475|  1.03k|}
card-entersafe.c:entersafe_select_file:
  590|  1.79k|{
  591|  1.79k|	if (card == NULL || in_path == NULL)
  ------------------
  |  Branch (591:6): [True: 0, False: 1.79k]
  |  Branch (591:22): [True: 0, False: 1.79k]
  ------------------
  592|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  593|  1.79k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  1.79k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  1.79k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  1.79k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 1.79k]
  |  |  ------------------
  ------------------
  594|       |
  595|  1.79k|	switch (in_path->type) {
  596|      7|		case SC_PATH_TYPE_FILE_ID:
  ------------------
  |  |  117|      7|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (596:3): [True: 7, False: 1.78k]
  ------------------
  597|      7|			if (in_path->len != 2)
  ------------------
  |  Branch (597:8): [True: 5, False: 2]
  ------------------
  598|      5|				SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  599|      2|			return entersafe_select_fid(card,in_path->value[0], in_path->value[1], file_out);
  600|    570|		case SC_PATH_TYPE_DF_NAME:
  ------------------
  |  |  118|    570|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (600:3): [True: 570, False: 1.22k]
  ------------------
  601|    570|			return entersafe_select_aid(card, in_path, file_out);
  602|  1.21k|		case SC_PATH_TYPE_PATH:
  ------------------
  |  |  119|  1.21k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (602:3): [True: 1.21k, False: 577]
  ------------------
  603|  1.21k|			return entersafe_select_path(card, in_path->value, in_path->len, file_out);
  604|      0|		default:
  ------------------
  |  Branch (604:3): [True: 0, False: 1.79k]
  ------------------
  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|  1.79k|	}
  607|  1.79k|}
card-entersafe.c:entersafe_select_fid:
  503|  1.38k|{
  504|  1.38k|	int r;
  505|  1.38k|	sc_file_t *file = NULL;
  506|  1.38k|	sc_path_t path;
  507|       |
  508|  1.38k|	memset(&path, 0, sizeof(sc_path_t));
  509|       |
  510|  1.38k|	path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|  1.38k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  511|  1.38k|	path.value[0] = id_hi;
  512|  1.38k|	path.value[1] = id_lo;
  513|  1.38k|	path.len = 2;
  514|       |
  515|  1.38k|	r = iso_ops->select_file(card, &path, &file);
  516|  1.38k|	if (r < 0)
  ------------------
  |  Branch (516:6): [True: 1.10k, False: 277]
  ------------------
  517|  1.10k|		sc_file_free(file);
  518|  1.38k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  1.38k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.38k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.38k|	int _ret = (r); \
  |  |  |  |  168|  1.38k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.10k, False: 277]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.10k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.10k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.10k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.10k|		return _ret; \
  |  |  |  |  172|  1.10k|	} \
  |  |  |  |  173|  1.38k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 277]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  519|       |
  520|    277|	if (file_out)
  ------------------
  |  Branch (520:6): [True: 79, False: 198]
  ------------------
  521|     79|		*file_out = file;
  522|    198|	else
  523|    198|		sc_file_free(file);
  524|       |
  525|    277|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
  ------------------
  |  |  153|    277|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    277|	int _ret = r; \
  |  |  155|    277|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 277, False: 0]
  |  |  ------------------
  |  |  156|    277|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 277]
  |  |  ------------------
  |  |  157|    277|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    277|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|    277|	return _ret; \
  |  |  163|    277|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  526|    277|}
card-entersafe.c:entersafe_select_aid:
  531|    570|{
  532|    570|	int r;
  533|       |
  534|    570|	r = iso_ops->select_file(card, in_path, file_out);
  535|    570|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    570|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    570|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    570|	int _ret = (r); \
  |  |  |  |  168|    570|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 444, False: 126]
  |  |  |  |  ------------------
  |  |  |  |  169|    444|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    444|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    444|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    444|		return _ret; \
  |  |  |  |  172|    444|	} \
  |  |  |  |  173|    570|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 126]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  536|       |
  537|    126|	if (file_out) {
  ------------------
  |  Branch (537:6): [True: 7, False: 119]
  ------------------
  538|      7|		sc_file_t *file = *file_out;
  539|      7|		if (file == NULL)
  ------------------
  |  Branch (539:7): [True: 0, False: 7]
  ------------------
  540|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  541|       |
  542|      7|		file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|      7|#define SC_FILE_TYPE_DF			0x04
  ------------------
  543|      7|		file->ef_structure = SC_FILE_EF_UNKNOWN;
  ------------------
  |  |  220|      7|#define SC_FILE_EF_UNKNOWN		0x00
  ------------------
  544|      7|		file->path.len = 0;
  545|      7|		file->size = 0;
  546|       |		/* AID */
  547|      7|		memcpy(file->name, in_path->value, in_path->len);
  548|      7|		file->namelen = in_path->len;
  549|      7|		file->id = 0x0000;
  550|      7|	}
  551|    126|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, 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]
  |  |  ------------------
  ------------------
  552|    126|}
card-entersafe.c:entersafe_select_path:
  557|  1.21k|{
  558|  1.21k|	u8 n_pathbuf[SC_MAX_PATH_SIZE];
  559|  1.21k|	const u8 *path = pathbuf;
  560|  1.21k|	size_t pathlen = len;
  561|  1.21k|	unsigned int i;
  562|  1.21k|	int r;
  563|       |
  564|  1.21k|	if (pathlen % 2 != 0 || pathlen > 6 || pathlen <= 0)
  ------------------
  |  Branch (564:6): [True: 0, False: 1.21k]
  |  Branch (564:26): [True: 3, False: 1.21k]
  |  Branch (564:41): [True: 1, False: 1.21k]
  ------------------
  565|      4|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  566|       |
  567|       |	/* if pathlen == 6 then the first FID must be MF (== 3F00) */
  568|  1.21k|	if (pathlen == 6 && (path[0] != 0x3f || path[1] != 0x00))
  ------------------
  |  Branch (568:6): [True: 281, False: 930]
  |  Branch (568:23): [True: 3, False: 278]
  |  Branch (568:42): [True: 3, False: 275]
  ------------------
  569|      6|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  570|       |
  571|       |	/* unify path (the first FID should be MF) */
  572|  1.20k|	if (path[0] != 0x3f || path[1] != 0x00) {
  ------------------
  |  Branch (572:6): [True: 29, False: 1.17k]
  |  Branch (572:25): [True: 10, False: 1.16k]
  ------------------
  573|     39|		n_pathbuf[0] = 0x3f;
  574|     39|		n_pathbuf[1] = 0x00;
  575|     39|		memcpy(n_pathbuf + 2, path, pathlen);
  576|     39|		path = n_pathbuf;
  577|     39|		pathlen += 2;
  578|     39|	}
  579|       |
  580|  1.38k|	for (i = 0; i < pathlen - 2; i += 2) {
  ------------------
  |  Branch (580:14): [True: 1.16k, False: 213]
  ------------------
  581|  1.16k|		r = entersafe_select_fid(card, path[i], path[i + 1], NULL);
  582|  1.16k|		LOG_TEST_RET(card->ctx, r, "SELECT FILE (DF-ID) failed");
  ------------------
  |  |  174|  1.16k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.16k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.16k|	int _ret = (r); \
  |  |  |  |  168|  1.16k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 992, False: 175]
  |  |  |  |  ------------------
  |  |  |  |  169|    992|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    992|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    992|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    992|		return _ret; \
  |  |  |  |  172|    992|	} \
  |  |  |  |  173|  1.16k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 175]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  583|  1.16k|	}
  584|    213|	return entersafe_select_fid(card, path[pathlen - 2], path[pathlen - 1], file_out);
  585|  1.20k|}
card-entersafe.c:entersafe_create_file:
  701|      1|{
  702|      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]
  |  |  ------------------
  ------------------
  703|       |
  704|      1|	if (file->type == SC_FILE_TYPE_WORKING_EF) {
  ------------------
  |  |  216|      1|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (704:6): [True: 0, False: 1]
  ------------------
  705|      0|		sc_entersafe_create_data data;
  706|      0|		memset(&data, 0, sizeof(data));
  707|       |
  708|      0|		data.data.ef.file_id[0] = (file->id >> 8) & 0xFF;
  709|      0|		data.data.ef.file_id[1] = file->id & 0xFF;
  710|      0|		data.data.ef.size[0] = (file->size >> 8) & 0xFF;
  711|      0|		data.data.ef.size[1] = file->size & 0xFF;
  712|      0|		memset(data.data.ef.ac, ENTERSAFE_AC_ALWAYS, sizeof(data.data.ef.ac));
  ------------------
  |  |  678|      0|#define ENTERSAFE_AC_ALWAYS 0x10
  ------------------
  713|      0|		data.data.ef.ac[0] = process_acl_entry(file, SC_AC_OP_READ, ENTERSAFE_AC_ALWAYS);
  ------------------
  |  |  188|      0|#define SC_AC_OP_READ			22
  ------------------
              		data.data.ef.ac[0] = process_acl_entry(file, SC_AC_OP_READ, ENTERSAFE_AC_ALWAYS);
  ------------------
  |  |  678|      0|#define ENTERSAFE_AC_ALWAYS 0x10
  ------------------
  714|      0|		data.data.ef.ac[1] = process_acl_entry(file, SC_AC_OP_UPDATE, ENTERSAFE_AC_ALWAYS);
  ------------------
  |  |  189|      0|#define SC_AC_OP_UPDATE			23
  ------------------
              		data.data.ef.ac[1] = process_acl_entry(file, SC_AC_OP_UPDATE, ENTERSAFE_AC_ALWAYS);
  ------------------
  |  |  678|      0|#define ENTERSAFE_AC_ALWAYS 0x10
  ------------------
  715|       |
  716|      0|		return entersafe_create_ef(card, &data);
  717|      1|	} else {
  718|      1|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      1|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  719|      1|	}
  720|      1|}
card-entersafe.c:entersafe_create_ef:
  666|     53|{
  667|     53|	int r;
  668|     53|	sc_apdu_t apdu;
  669|       |
  670|     53|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  671|       |
  672|     53|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE0, 0x02, 0x00);
  ------------------
  |  |  293|     53|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  673|     53|	apdu.cla = 0x84;
  674|     53|	apdu.data = (u8*)&data->data.ef;
  675|     53|	apdu.lc = apdu.datalen = sizeof(data->data.ef);
  676|       |
  677|     53|	r = entersafe_transmit_apdu(card, &apdu, init_key, sizeof(init_key), 0, 1);
  678|     53|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     53|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     53|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     53|	int _ret = (r); \
  |  |  |  |  168|     53|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 52]
  |  |  |  |  ------------------
  |  |  |  |  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|     53|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 52]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  679|     52|	return sc_check_sw(card, apdu.sw1, apdu.sw2);
  680|     53|}
card-entersafe.c:entersafe_pin_cmd:
  880|     56|{
  881|     56|	int r;
  882|     56|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  883|     56|	entersafe_init_pin_info(&data->pin1, 0);
  884|     56|	entersafe_init_pin_info(&data->pin2, 1);
  885|     56|	data->flags |= SC_PIN_CMD_NEED_PADDING;
  ------------------
  |  |  422|     56|#define SC_PIN_CMD_NEED_PADDING		0x0002
  ------------------
  886|       |
  887|     56|	if (data->cmd != SC_PIN_CMD_UNBLOCK) {
  ------------------
  |  |  417|     56|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (887:6): [True: 56, False: 0]
  ------------------
  888|     56|		r = iso_ops->pin_cmd(card, data);
  889|     56|		sc_log(card->ctx, "Verify rv:%i", r);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  890|     56|	} else {
  891|      0|		{ /*verify*/
  892|      0|			sc_apdu_t apdu;
  893|      0|			u8 sbuf[0x10] = {0};
  894|       |
  895|      0|			if (data->pin1.len > sizeof(sbuf)) {
  ------------------
  |  Branch (895:8): [True: 0, False: 0]
  ------------------
  896|      0|				return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  897|      0|			}
  898|       |
  899|      0|			memcpy(sbuf, data->pin1.data, data->pin1.len);
  900|      0|			sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x20, 0x00, data->pin_reference + 1);
  ------------------
  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  901|      0|			apdu.lc = apdu.datalen = sizeof(sbuf);
  902|      0|			apdu.data = sbuf;
  903|       |
  904|      0|			r = entersafe_transmit_apdu(card, &apdu, 0, 0, 0, 0);
  905|      0|			LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  906|      0|		}
  907|       |
  908|      0|		{ /*change*/
  909|      0|			sc_apdu_t apdu;
  910|      0|			u8 sbuf[0x12] = {0};
  911|       |
  912|      0|			if (data->pin2.len + 2 > sizeof(sbuf)) {
  ------------------
  |  Branch (912:8): [True: 0, False: 0]
  ------------------
  913|      0|				return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  914|      0|			}
  915|       |
  916|      0|			sbuf[0] = 0x33;
  917|      0|			sbuf[1] = 0x00;
  918|      0|			memcpy(sbuf + 2, data->pin2.data, data->pin2.len);
  919|      0|			sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xF4, 0x0B, data->pin_reference);
  ------------------
  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  920|      0|			apdu.cla = 0x84;
  921|      0|			apdu.lc = apdu.datalen = sizeof(sbuf);
  922|      0|			apdu.data = sbuf;
  923|       |
  924|      0|			r = entersafe_transmit_apdu(card, &apdu, key_maintain, sizeof(key_maintain), 1, 1);
  925|      0|			LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  926|      0|		}
  927|      0|	}
  928|     56|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, 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|     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]
  |  |  ------------------
  ------------------
  929|     56|}
card-entersafe.c:entersafe_init_pin_info:
  870|    112|{
  871|    112|	pin->encoding   = SC_PIN_ENCODING_ASCII;
  ------------------
  |  |  425|    112|#define SC_PIN_ENCODING_ASCII	0
  ------------------
  872|    112|	pin->min_length = 4;
  873|    112|	pin->max_length = 16;
  874|    112|	pin->pad_length = 16;
  875|    112|	pin->offset     = 5 + num * 16;
  876|    112|	pin->pad_char   = 0x00;
  877|    112|}
card-entersafe.c:entersafe_card_ctl_2048:
 1522|    900|{
 1523|    900|	sc_entersafe_create_data *tmp = (sc_entersafe_create_data *)ptr;
 1524|       |
 1525|    900|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    900|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    900|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    900|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 900]
  |  |  ------------------
  ------------------
 1526|       |
 1527|    900|	switch (cmd) {
 1528|    140|		case SC_CARDCTL_ENTERSAFE_CREATE_FILE:
  ------------------
  |  Branch (1528:3): [True: 140, False: 760]
  ------------------
 1529|    140|			if (tmp->type == SC_ENTERSAFE_MF_DATA)
  ------------------
  |  |  665|    140|#define	SC_ENTERSAFE_MF_DATA	0x01
  ------------------
  |  Branch (1529:8): [True: 74, False: 66]
  ------------------
 1530|     74|				return entersafe_create_mf(card, tmp);
 1531|     66|			else if (tmp->type == SC_ENTERSAFE_DF_DATA)
  ------------------
  |  |  666|     66|#define SC_ENTERSAFE_DF_DATA	0x02
  ------------------
  |  Branch (1531:13): [True: 13, False: 53]
  ------------------
 1532|     13|				return entersafe_create_df(card, tmp);
 1533|     53|			else if (tmp->type == SC_ENTERSAFE_EF_DATA)
  ------------------
  |  |  667|     53|#define SC_ENTERSAFE_EF_DATA	0x04
  ------------------
  |  Branch (1533:13): [True: 53, False: 0]
  ------------------
 1534|     53|				return entersafe_create_ef(card, tmp);
 1535|      0|			else
 1536|      0|				return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1537|    111|		case SC_CARDCTL_ENTERSAFE_WRITE_KEY:
  ------------------
  |  Branch (1537:3): [True: 111, False: 789]
  ------------------
 1538|    111|			return entersafe_write_key(card, (sc_entersafe_wkey_data *)ptr);
 1539|     34|		case SC_CARDCTL_ENTERSAFE_GENERATE_KEY:
  ------------------
  |  Branch (1539:3): [True: 34, False: 866]
  ------------------
 1540|     34|			return entersafe_gen_key(card, (sc_entersafe_gen_key_data *)ptr);
 1541|      8|		case SC_CARDCTL_ERASE_CARD:
  ------------------
  |  Branch (1541:3): [True: 8, False: 892]
  ------------------
 1542|      8|			return entersafe_erase_card(card);
 1543|    351|		case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (1543:3): [True: 351, False: 549]
  ------------------
 1544|    351|			return entersafe_get_serialnr(card, (sc_serial_number_t *)ptr);
 1545|      0|		case SC_CARDCTL_ENTERSAFE_PREINSTALL_KEYS:
  ------------------
  |  Branch (1545:3): [True: 0, False: 900]
  ------------------
 1546|      0|			return entersafe_preinstall_keys(card, entersafe_preinstall_rsa_2048);
 1547|    256|		default:
  ------------------
  |  Branch (1547:3): [True: 256, False: 644]
  ------------------
 1548|    256|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    256|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1549|    900|	}
 1550|    900|}
card-entersafe.c:entersafe_create_mf:
  610|     74|{
  611|     74|	int r;
  612|     74|	sc_apdu_t apdu;
  613|       |
  614|     74|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     74|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     74|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     74|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 74]
  |  |  ------------------
  ------------------
  615|       |
  616|     74|	memcpy(data->data.df.init_key, init_key, sizeof(init_key));
  617|       |
  618|     74|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE0, 0x00, 0x00);
  ------------------
  |  |  293|     74|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  619|     74|	apdu.cla = 0x84;
  620|     74|	apdu.data = (u8 *)&data->data.df;
  621|     74|	apdu.datalen = apdu.lc = sizeof(data->data.df);
  622|       |
  623|     74|	switch(card->type) {
  624|      0|		case SC_CARD_TYPE_ENTERSAFE_3K:
  ------------------
  |  Branch (624:3): [True: 0, False: 74]
  ------------------
  625|      0|			r = entersafe_transmit_apdu(card, &apdu, trans_code_3k, sizeof(trans_code_3k), 0, 1);
  626|      0|			break;
  627|     29|		case SC_CARD_TYPE_ENTERSAFE_FTCOS_PK_01C:
  ------------------
  |  Branch (627:3): [True: 29, False: 45]
  ------------------
  628|     72|		case SC_CARD_TYPE_ENTERSAFE_EJAVA_PK_01C:
  ------------------
  |  Branch (628:3): [True: 43, False: 31]
  ------------------
  629|     73|		case SC_CARD_TYPE_ENTERSAFE_EJAVA_PK_01C_T0:
  ------------------
  |  Branch (629:3): [True: 1, False: 73]
  ------------------
  630|     73|		case SC_CARD_TYPE_ENTERSAFE_EJAVA_H10CR_PK_01C_T1:
  ------------------
  |  Branch (630:3): [True: 0, False: 74]
  ------------------
  631|     74|		case SC_CARD_TYPE_ENTERSAFE_EJAVA_D11CR_PK_01C_T1:
  ------------------
  |  Branch (631:3): [True: 1, False: 73]
  ------------------
  632|     74|		case SC_CARD_TYPE_ENTERSAFE_EJAVA_C21C_PK_01C_T1:
  ------------------
  |  Branch (632:3): [True: 0, False: 74]
  ------------------
  633|     74|		case SC_CARD_TYPE_ENTERSAFE_EJAVA_A22CR_PK_01C_T1:
  ------------------
  |  Branch (633:3): [True: 0, False: 74]
  ------------------
  634|     74|		case SC_CARD_TYPE_ENTERSAFE_EJAVA_A40CR_PK_01C_T1:
  ------------------
  |  Branch (634:3): [True: 0, False: 74]
  ------------------
  635|     74|			r = entersafe_transmit_apdu(card, &apdu, trans_code_ftcos_pk_01c, sizeof(trans_code_ftcos_pk_01c), 0, 1);
  636|     74|			break;
  637|      0|		default:
  ------------------
  |  Branch (637:3): [True: 0, False: 74]
  ------------------
  638|      0|			r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  639|      0|			break;
  640|     74|	}
  641|       |
  642|     74|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     74|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     74|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     74|	int _ret = (r); \
  |  |  |  |  168|     74|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 18, False: 56]
  |  |  |  |  ------------------
  |  |  |  |  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|     74|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 56]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  643|     56|	return sc_check_sw(card, apdu.sw1, apdu.sw2);
  644|     74|}
card-entersafe.c:entersafe_create_df:
  647|     13|{
  648|     13|	int r;
  649|     13|	sc_apdu_t apdu;
  650|       |
  651|     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]
  |  |  ------------------
  ------------------
  652|       |
  653|     13|	memcpy(data->data.df.init_key, init_key, sizeof(init_key));
  654|       |
  655|     13|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE0, 0x01, 0x00);
  ------------------
  |  |  293|     13|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  656|     13|	apdu.cla = 0x84;
  657|     13|	apdu.data = (u8 *)&data->data.df;
  658|     13|	apdu.lc = apdu.datalen = sizeof(data->data.df);
  659|       |
  660|     13|	r = entersafe_transmit_apdu(card, &apdu,init_key,sizeof(init_key),0,1);
  661|     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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  662|      5|	return sc_check_sw(card, apdu.sw1, apdu.sw2);
  663|     13|}
card-entersafe.c:entersafe_write_key:
 1227|    111|{
 1228|    111|	struct sc_pkcs15_prkey_rsa *rsa = data->key_data.rsa;
 1229|       |
 1230|    111|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    111|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    111|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    111|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 111]
  |  |  ------------------
  ------------------
 1231|       |
 1232|    111|	switch(data->usage) {
 1233|      0|		case 0x22:
  ------------------
  |  Branch (1233:3): [True: 0, False: 111]
  ------------------
 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: 111]
  ------------------
 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|    111|		default:
  ------------------
  |  Branch (1242:3): [True: 111, False: 0]
  ------------------
 1243|    111|			return entersafe_write_symmetric_key(card,data->key_id,data->usage,
 1244|    111|												data->key_data.symmetric.EC,
 1245|    111|												data->key_data.symmetric.ver,
 1246|    111|												data->key_data.symmetric.key_val,
 1247|    111|												data->key_data.symmetric.key_len);
 1248|      0|			break;
 1249|    111|	}
 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_reverse_buffer:
  116|      1|{
  117|      1|	u8 t;
  118|      1|	u8 *end = buff + size - 1;
  119|       |
  120|     65|	while (buff < end) {
  ------------------
  |  Branch (120:9): [True: 64, False: 1]
  ------------------
  121|     64|		t = *buff;
  122|     64|		*buff = *end;
  123|     64|		*end = t;
  124|     64|		++buff;
  125|     64|		--end;
  126|     64|	}
  127|      1|}
card-entersafe.c:entersafe_write_symmetric_key:
 1201|    111|{
 1202|    111|	sc_apdu_t apdu;
 1203|    111|	u8 sbuff[SC_MAX_APDU_BUFFER_SIZE] = {0};
 1204|    111|	int r;
 1205|       |
 1206|    111|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    111|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    111|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    111|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 111]
  |  |  ------------------
  ------------------
 1207|       |
 1208|    111|	if (len > 240)
  ------------------
  |  Branch (1208:6): [True: 0, False: 111]
  ------------------
 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|    111|	sbuff[0] = EC;
 1212|    111|	sbuff[1] = ver;
 1213|    111|	memcpy(&sbuff[2], data, len);
 1214|       |
 1215|    111|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xF4, usage, key_id);
  ------------------
  |  |  293|    111|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1216|    111|	apdu.cla = 0x84;
 1217|    111|	apdu.data = sbuff;
 1218|    111|	apdu.lc = apdu.datalen = len + 2;
 1219|       |
 1220|    111|	r = entersafe_transmit_apdu(card, &apdu, key_maintain, sizeof(key_maintain), 1, 1);
 1221|    111|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    111|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    111|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    111|	int _ret = (r); \
  |  |  |  |  168|    111|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 81, False: 30]
  |  |  |  |  ------------------
  |  |  |  |  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|    111|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 30]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1222|     30|	LOG_TEST_RET(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2), "Write prkey 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1223|     26|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, 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]
  |  |  ------------------
  ------------------
 1224|     26|}
card-entersafe.c:entersafe_gen_key:
 1254|     34|{
 1255|     34|	int	r;
 1256|     34|	size_t len = data->key_length >> 3;
 1257|     34|	sc_apdu_t apdu;
 1258|     34|	u8 rbuf[300] = {0};
 1259|     34|	u8 sbuf[4], *p;
 1260|     34|	size_t plen = 0;
 1261|       |
 1262|     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]
  |  |  ------------------
  ------------------
 1263|       |
 1264|       |	/* MSE */
 1265|     34|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x22, 0x01, 0xB8);
  ------------------
  |  |  293|     34|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1266|     34|	apdu.lc = 0x04;
 1267|     34|	sbuf[0] = 0x83;
 1268|     34|	sbuf[1] = 0x02;
 1269|     34|	sbuf[2] = data->key_id;
 1270|     34|	sbuf[3] = 0x2A;
 1271|     34|	apdu.data = sbuf;
 1272|     34|	apdu.datalen = 4;
 1273|     34|	apdu.lc = 4;
 1274|     34|	apdu.le = 0;
 1275|       |
 1276|     34|	r = entersafe_transmit_apdu(card, &apdu, 0, 0, 0, 0);
 1277|     34|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     34|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     34|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     34|	int _ret = (r); \
  |  |  |  |  168|     34|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 33]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|     34|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 33]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1278|     33|	LOG_TEST_RET(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2), "EnterSafe set MSE failed");
  ------------------
  |  |  174|     33|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     33|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     33|	int _ret = (r); \
  |  |  |  |  168|     33|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 8, False: 25]
  |  |  |  |  ------------------
  |  |  |  |  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|     33|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 25]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1279|       |
 1280|       |	/* generate key */
 1281|     25|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x46, 0x00, 0x00);
  ------------------
  |  |  293|     25|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1282|     25|	apdu.le = 0;
 1283|     25|	sbuf[0] = (u8)(data->key_length >> 8);
 1284|     25|	sbuf[1] = (u8)(data->key_length);
 1285|     25|	apdu.data = sbuf;
 1286|     25|	apdu.lc = 2;
 1287|     25|	apdu.datalen = 2;
 1288|       |
 1289|     25|	r = entersafe_transmit_apdu(card, &apdu, 0, 0, 0, 0);
 1290|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1291|     24|	LOG_TEST_RET(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2), "EnterSafe generate key pair failed");
  ------------------
  |  |  174|     24|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     24|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     24|	int _ret = (r); \
  |  |  |  |  168|     24|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 23]
  |  |  |  |  ------------------
  |  |  |  |  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|     24|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 23]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1292|       |
 1293|       |	/* read public key via READ PUBLIC KEY */
 1294|     23|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xE6, 0x2A, data->key_id);
  ------------------
  |  |  292|     23|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1295|     23|	apdu.cla     = 0x80;
 1296|     23|	apdu.resp    = rbuf;
 1297|     23|	apdu.resplen = sizeof(rbuf);
 1298|     23|	apdu.le      = 256;
 1299|     23|	r = entersafe_transmit_apdu(card, &apdu, 0, 0, 0, 0);
 1300|     23|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     23|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     23|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     23|	int _ret = (r); \
  |  |  |  |  168|     23|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 22]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|     23|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1301|     22|	LOG_TEST_RET(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2), "EnterSafe get pukey failed");
  ------------------
  |  |  174|     22|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     22|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     22|	int _ret = (r); \
  |  |  |  |  168|     22|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 20]
  |  |  |  |  ------------------
  |  |  |  |  169|      2|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      2|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      2|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      2|		return _ret; \
  |  |  |  |  172|      2|	} \
  |  |  |  |  173|     22|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1302|       |
 1303|     20|	p = rbuf;
 1304|     20|	plen = apdu.resplen;
 1305|     20|	if (*p != 'E') {
  ------------------
  |  Branch (1305:6): [True: 3, False: 17]
  ------------------
 1306|      3|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1307|      3|	}
 1308|     17|	if ((size_t)(p - rbuf) + 2 + p[1] >= plen) {
  ------------------
  |  Branch (1308:6): [True: 3, False: 14]
  ------------------
 1309|      3|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1310|      3|	}
 1311|     14|	p += 2 + p[1];
 1312|       |	/* N */
 1313|     14|	if (*p != 'N') {
  ------------------
  |  Branch (1313:6): [True: 1, False: 13]
  ------------------
 1314|      1|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1315|      1|	}
 1316|     13|	if ((size_t)(p - rbuf) + 2 >= plen) {
  ------------------
  |  Branch (1316:6): [True: 1, False: 12]
  ------------------
 1317|      1|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1318|      1|	}
 1319|     12|	++p;
 1320|     12|	if (*p++ > 0x80) {
  ------------------
  |  Branch (1320:6): [True: 6, False: 6]
  ------------------
 1321|      6|		u8 len_bytes = (*(p - 1)) & 0x0f;
 1322|      6|		size_t module_len = 0;
 1323|      6|		if ((size_t)(p - rbuf) + len_bytes >= plen) {
  ------------------
  |  Branch (1323:7): [True: 1, False: 5]
  ------------------
 1324|      1|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1325|      1|		}
 1326|     31|		while (len_bytes != 0) {
  ------------------
  |  Branch (1326:10): [True: 26, False: 5]
  ------------------
 1327|     26|			module_len = module_len << 8;
 1328|     26|			module_len += *p++;
 1329|     26|			--len_bytes;
 1330|     26|		}
 1331|      5|	}
 1332|       |
 1333|     11|	if ((p - rbuf) + len >= plen) {
  ------------------
  |  Branch (1333:6): [True: 10, False: 1]
  ------------------
 1334|     10|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1335|     10|	}
 1336|       |
 1337|      1|	data->modulus = malloc(len);
 1338|      1|	if (!data->modulus)
  ------------------
  |  Branch (1338:6): [True: 0, False: 1]
  ------------------
 1339|      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]
  |  |  ------------------
  ------------------
 1340|      1|	entersafe_reverse_buffer(p, len);
 1341|      1|	memcpy(data->modulus, p, len);
 1342|       |
 1343|      1|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
  ------------------
  |  |  153|      1|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      1|	int _ret = r; \
  |  |  155|      1|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 1, False: 0]
  |  |  ------------------
  |  |  156|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 1]
  |  |  ------------------
  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      1|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|      1|	return _ret; \
  |  |  163|      1|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1344|      1|}
card-entersafe.c:entersafe_erase_card:
  932|      8|{
  933|      8|	int r;
  934|      8|	u8  sbuf[2];
  935|      8|	sc_apdu_t apdu;
  936|       |
  937|      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]
  |  |  ------------------
  ------------------
  938|       |
  939|      8|	sbuf[0] = 0x3f;
  940|      8|	sbuf[1] = 0x00;
  941|      8|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xA4, 0x00, 0x00);
  ------------------
  |  |  293|      8|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  942|      8|	apdu.lc = 2;
  943|      8|	apdu.datalen = 2;
  944|      8|	apdu.data = sbuf;
  945|       |
  946|      8|	r = entersafe_transmit_apdu(card, &apdu, 0, 0, 0, 0);
  947|      8|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|      8|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      8|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      8|	int _ret = (r); \
  |  |  |  |  168|      8|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      8|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  948|       |
  949|      7|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xEE, 0x00, 0x00);
  ------------------
  |  |  293|      7|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  950|      7|	apdu.cla = 0x84;
  951|      7|	apdu.lc = 2;
  952|      7|	apdu.datalen = 2;
  953|      7|	apdu.data = sbuf;
  954|       |
  955|      7|	switch(card->type) {
  956|      0|		case SC_CARD_TYPE_ENTERSAFE_3K:
  ------------------
  |  Branch (956:3): [True: 0, False: 7]
  ------------------
  957|      0|			r = entersafe_transmit_apdu(card, &apdu, trans_code_3k, sizeof(trans_code_3k), 0, 1);
  958|      0|			break;
  959|      6|		case SC_CARD_TYPE_ENTERSAFE_FTCOS_PK_01C:
  ------------------
  |  Branch (959:3): [True: 6, False: 1]
  ------------------
  960|      7|		case SC_CARD_TYPE_ENTERSAFE_EJAVA_PK_01C:
  ------------------
  |  Branch (960:3): [True: 1, False: 6]
  ------------------
  961|      7|		case SC_CARD_TYPE_ENTERSAFE_EJAVA_PK_01C_T0:
  ------------------
  |  Branch (961:3): [True: 0, False: 7]
  ------------------
  962|      7|		case SC_CARD_TYPE_ENTERSAFE_EJAVA_H10CR_PK_01C_T1:
  ------------------
  |  Branch (962:3): [True: 0, False: 7]
  ------------------
  963|      7|		case SC_CARD_TYPE_ENTERSAFE_EJAVA_D11CR_PK_01C_T1:
  ------------------
  |  Branch (963:3): [True: 0, False: 7]
  ------------------
  964|      7|		case SC_CARD_TYPE_ENTERSAFE_EJAVA_C21C_PK_01C_T1:
  ------------------
  |  Branch (964:3): [True: 0, False: 7]
  ------------------
  965|      7|		case SC_CARD_TYPE_ENTERSAFE_EJAVA_A22CR_PK_01C_T1:
  ------------------
  |  Branch (965:3): [True: 0, False: 7]
  ------------------
  966|      7|		case SC_CARD_TYPE_ENTERSAFE_EJAVA_A40CR_PK_01C_T1:
  ------------------
  |  Branch (966:3): [True: 0, False: 7]
  ------------------
  967|      7|			r = entersafe_transmit_apdu(card, &apdu, trans_code_ftcos_pk_01c, sizeof(trans_code_ftcos_pk_01c), 0, 1);
  968|      7|			break;
  969|      0|		default:
  ------------------
  |  Branch (969:3): [True: 0, False: 7]
  ------------------
  970|      0|			r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  971|      0|			break;
  972|      7|	}
  973|       |
  974|      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: 3, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  169|      3|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      3|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      3|		return _ret; \
  |  |  |  |  172|      3|	} \
  |  |  |  |  173|      7|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  975|      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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 3, False: 1]
  |  |  ------------------
  |  |  157|      4|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      4|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|      4|	return _ret; \
  |  |  163|      4|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  976|      4|}
card-entersafe.c:entersafe_get_serialnr:
 1347|    351|{
 1348|    351|	int	r;
 1349|    351|	sc_apdu_t apdu;
 1350|    351|	u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
 1351|       |
 1352|    351|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    351|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    351|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    351|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 351]
  |  |  ------------------
  ------------------
 1353|    351|	if (serial == NULL)
  ------------------
  |  Branch (1353:6): [True: 0, False: 351]
  ------------------
 1354|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1355|       |
 1356|    351|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xEA, 0x00, 0x00);
  ------------------
  |  |  292|    351|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1357|    351|	apdu.cla = 0x80;
 1358|    351|	apdu.resp = rbuf;
 1359|    351|	apdu.resplen = sizeof(rbuf);
 1360|    351|	apdu.le = 0x08;
 1361|       |
 1362|    351|	r = entersafe_transmit_apdu(card, &apdu, 0, 0, 0, 0);
 1363|    351|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    351|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    351|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    351|	int _ret = (r); \
  |  |  |  |  168|    351|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 10, False: 341]
  |  |  |  |  ------------------
  |  |  |  |  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|    351|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 341]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1364|    341|	LOG_TEST_RET(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2), "EnterSafe get SN failed");
  ------------------
  |  |  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: 261, False: 80]
  |  |  |  |  ------------------
  |  |  |  |  169|    261|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    261|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    261|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    261|		return _ret; \
  |  |  |  |  172|    261|	} \
  |  |  |  |  173|    341|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 80]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1365|     80|	if (apdu.resplen != 8)
  ------------------
  |  Branch (1365:6): [True: 38, False: 42]
  ------------------
 1366|     80|		LOG_TEST_RET(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Invalid length of SN");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1367|       |
 1368|     42|	card->serialnr.len = serial->len = 8;
 1369|     42|	memcpy(card->serialnr.value, rbuf, 8);
 1370|     42|	memcpy(serial->value, rbuf, 8);
 1371|       |
 1372|     42|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1373|     42|}
card-entersafe.c:entersafe_process_fci:
  479|    230|{
  480|    230|	int r;
  481|       |
  482|    230|	if (file == NULL)
  ------------------
  |  Branch (482:6): [True: 0, False: 230]
  ------------------
  483|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  484|    230|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    230|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    230|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    230|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 230]
  |  |  ------------------
  ------------------
  485|       |
  486|    230|	r = iso_ops->process_fci(card, file, buf, buflen);
  487|    230|	LOG_TEST_RET(card->ctx, r, "Process fci failed");
  ------------------
  |  |  174|    230|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    230|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    230|	int _ret = (r); \
  |  |  |  |  168|    230|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 230]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|    230|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 230]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  488|       |
  489|    230|	if (file->namelen) {
  ------------------
  |  Branch (489:6): [True: 10, False: 220]
  ------------------
  490|     10|		file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|     10|#define SC_FILE_TYPE_DF			0x04
  ------------------
  491|     10|		file->ef_structure = SC_FILE_EF_UNKNOWN;
  ------------------
  |  |  220|     10|#define SC_FILE_EF_UNKNOWN		0x00
  ------------------
  492|    220|	} else {
  493|    220|		file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|    220|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  494|    220|		file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|    220|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  495|    220|	}
  496|       |
  497|    230|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|    230|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    230|	int _ret = r; \
  |  |  155|    230|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 230, False: 0]
  |  |  ------------------
  |  |  156|    230|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 230]
  |  |  ------------------
  |  |  157|    230|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    230|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|    230|	return _ret; \
  |  |  163|    230|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  498|    230|}

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

epass2003_refresh:
  926|  1.01k|{
  927|  1.01k|	int r = SC_SUCCESS;
  ------------------
  |  |   28|  1.01k|#define SC_SUCCESS				0
  ------------------
  928|  1.01k|	epass2003_exdata *exdata = NULL;
  929|       |
  930|  1.01k|	if (!card->drv_data)
  ------------------
  |  Branch (930:6): [True: 0, False: 1.01k]
  ------------------
  931|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  932|       |
  933|  1.01k|	exdata = (epass2003_exdata *)card->drv_data;
  934|       |
  935|  1.01k|	if (exdata->sm) {
  ------------------
  |  Branch (935:6): [True: 808, False: 206]
  ------------------
  936|    808|		card->sm_ctx.sm_mode = 0;
  937|    808|		r = mutual_auth(card, g_init_key_enc, g_init_key_mac);
  938|    808|		card->sm_ctx.sm_mode = SM_MODE_TRANSMIT;
  ------------------
  |  |   47|    808|#define SM_MODE_TRANSMIT	0x200
  ------------------
  939|    808|		LOG_TEST_RET(card->ctx, r, "mutual_auth failed");
  ------------------
  |  |  174|    808|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    808|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    808|	int _ret = (r); \
  |  |  |  |  168|    808|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 808, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    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
  |  |  |  |  ------------------
  |  |  |  |  170|    808|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    808|		return _ret; \
  |  |  |  |  172|    808|	} \
  |  |  |  |  173|    808|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  940|    808|	}
  941|       |
  942|    206|	return r;
  943|  1.01k|}
sec_attr_to_entry:
 2253|  3.50k|{
 2254|  3.50k|	int i;
 2255|  3.50k|	int found = 0;
 2256|       |
 2257|  3.50k|	unsigned int method;
 2258|  3.50k|	unsigned long  keyref;
 2259|       |
 2260|  3.50k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  3.50k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  3.50k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  3.50k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 3.50k]
  |  |  ------------------
  ------------------
 2261|       |
 2262|  3.50k|	switch (file->sec_attr[index]) {
 2263|  1.91k|	case (EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_EVERYONE):
  ------------------
  |  |  738|  1.91k|#define EPASS2003_AC_MAC_NOLESS		0x90
  ------------------
              	case (EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_EVERYONE):
  ------------------
  |  |  733|  1.91k|#define EPASS2003_AC_EVERYONE		0x00
  ------------------
  |  Branch (2263:2): [True: 1.91k, False: 1.58k]
  ------------------
 2264|  1.91k|		method = SC_AC_NONE;
  ------------------
  |  |  150|  1.91k|#define SC_AC_NONE			0x00000000
  ------------------
 2265|  1.91k|		keyref = SC_AC_KEY_REF_NONE;
  ------------------
  |  |  204|  1.91k|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
 2266|  1.91k|		break;
 2267|    226|	case (EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_USER):
  ------------------
  |  |  738|    226|#define EPASS2003_AC_MAC_NOLESS		0x90
  ------------------
              	case (EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_USER):
  ------------------
  |  |  734|    226|#define EPASS2003_AC_USER		0x06
  ------------------
  |  Branch (2267:2): [True: 226, False: 3.28k]
  ------------------
 2268|    226|		method = SC_AC_CHV;
  ------------------
  |  |  151|    226|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 2269|    226|		keyref = 1;
 2270|    226|		break;
 2271|  1.36k|	default:
  ------------------
  |  Branch (2271:2): [True: 1.36k, False: 2.14k]
  ------------------
 2272|  1.36k|		sc_log(card->ctx, "Unknown value 0x%2.2x in file->sec_attr[%d]", file->sec_attr[index], index);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2273|  1.36k|		method = SC_AC_NEVER;
  ------------------
  |  |  163|  1.36k|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
 2274|  1.36k|		keyref = SC_AC_KEY_REF_NONE;
  ------------------
  |  |  204|  1.36k|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
 2275|  1.36k|		break;
 2276|  3.50k|	}
 2277|       |
 2278|   119k|	for (i = 0; i < (int)(sizeof(sec_attr_to_acl_entry) / sizeof(sec_attr_to_acl_entries_t)); i++) {
  ------------------
  |  Branch (2278:14): [True: 115k, False: 3.50k]
  ------------------
 2279|   115k|		const sec_attr_to_acl_entries_t *e = &sec_attr_to_acl_entry[i];
 2280|       |
 2281|   115k|		if (index == e->index && file->type == e->file_type
  ------------------
  |  Branch (2281:7): [True: 17.1k, False: 98.5k]
  |  Branch (2281:28): [True: 7.49k, False: 9.69k]
  ------------------
 2282|  7.49k|				&& file->ef_structure == e->file_ef_structure) {
  ------------------
  |  Branch (2282:8): [True: 333, False: 7.16k]
  ------------------
 2283|       |				/* may add multiple entries */
 2284|    333|			sc_file_add_acl_entry(file, e->op, method, keyref);
 2285|    333|			found++;
 2286|    333|		}
 2287|   115k|	}
 2288|  3.50k|	if (found != 1) {
  ------------------
  |  Branch (2288:6): [True: 3.45k, False: 55]
  ------------------
 2289|  3.45k|		sc_log(card->ctx,"found %d entries ", found);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2290|  3.45k|	}
 2291|       |
 2292|  3.50k|	return 0;
 2293|  3.50k|}
sc_get_epass2003_driver:
 3322|  16.3k|{
 3323|  16.3k|	return sc_get_driver();
 3324|  16.3k|}
card-epass2003.c:mutual_auth:
  896|    808|{
  897|    808|	struct sc_context *ctx = card->ctx;
  898|    808|	int r;
  899|    808|	unsigned char result[256] = {0};
  900|    808|	unsigned char ran_key[8] = {0};
  901|    808|	epass2003_exdata *exdata = NULL;
  902|       |
  903|    808|	if (!card->drv_data)
  ------------------
  |  Branch (903:6): [True: 0, False: 808]
  ------------------
  904|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  905|    808|	exdata = (epass2003_exdata *)card->drv_data;
  906|       |
  907|    808|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    808|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    808|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    808|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    808|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 808]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  908|       |
  909|    808|	r = gen_init_key(card, key_enc, key_mac, result, exdata->smtype);
  910|    808|	LOG_TEST_RET(ctx, r, "gen_init_key failed");
  ------------------
  |  |  174|    808|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    808|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    808|	int _ret = (r); \
  |  |  |  |  168|    808|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 808, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    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
  |  |  |  |  ------------------
  |  |  |  |  170|    808|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    808|		return _ret; \
  |  |  |  |  172|    808|	} \
  |  |  |  |  173|    808|} 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|    808|{
  680|    808|	int r;
  681|    808|	struct sc_apdu apdu;
  682|    808|	unsigned char data[256] = {0};
  683|    808|	unsigned char tmp_sm;
  684|    808|	unsigned char isFips;
  685|    808|	unsigned long blocksize = 0;
  686|    808|	unsigned char cryptogram[256] = {0}; /* host cryptogram */
  687|    808|	unsigned char iv[16] = {0};
  688|    808|	epass2003_exdata *exdata = NULL;
  689|       |
  690|    808|	if (!card->drv_data)
  ------------------
  |  Branch (690:6): [True: 0, False: 808]
  ------------------
  691|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  692|       |
  693|    808|	exdata = (epass2003_exdata *)card->drv_data;
  694|    808|	isFips = exdata->bFipsCertification;
  695|       |
  696|    808|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    808|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    808|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    808|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    808|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 808]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  697|       |
  698|    808|	if (1 != RAND_bytes(g_random, sizeof(g_random)))
  ------------------
  |  Branch (698:6): [True: 0, False: 808]
  ------------------
  699|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  700|       |
  701|    808|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0x50, 0x00, 0x00);
  ------------------
  |  |  294|    808|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  702|    808|	apdu.cla = 0x80;
  703|    808|	apdu.lc = apdu.datalen = sizeof(g_random);
  704|    808|	apdu.data = g_random;	/* host random */
  705|    808|	if (isFips)
  ------------------
  |  Branch (705:6): [True: 2, False: 806]
  ------------------
  706|      2|		apdu.le = apdu.resplen = 29;
  707|    806|	else
  708|    806|		apdu.le = apdu.resplen = 28;
  709|       |
  710|    808|	apdu.resp = result;	/* card random is result[12~19] */
  711|       |
  712|    808|	tmp_sm = exdata->sm;
  713|    808|	exdata->sm = SM_PLAIN;
  ------------------
  |  |   91|    808|#define SM_PLAIN				0x00
  ------------------
  714|    808|	r = epass2003_transmit_apdu(card, &apdu);
  715|    808|	exdata->sm = tmp_sm;
  716|    808|	LOG_TEST_RET(card->ctx, r, "APDU gen_init_key failed");
  ------------------
  |  |  174|    808|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    808|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    808|	int _ret = (r); \
  |  |  |  |  168|    808|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 45, False: 763]
  |  |  |  |  ------------------
  |  |  |  |  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|    808|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 763]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  717|       |
  718|    763|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  719|    763|	LOG_TEST_RET(card->ctx, r, "gen_init_key failed");
  ------------------
  |  |  174|    763|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    763|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    763|	int _ret = (r); \
  |  |  |  |  168|    763|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 594, False: 169]
  |  |  |  |  ------------------
  |  |  |  |  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|    763|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 169]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  720|       |
  721|       |	/* Step 1 - Generate Derivation data */
  722|    169|	if (isFips) {
  ------------------
  |  Branch (722:6): [True: 1, False: 168]
  ------------------
  723|      1|		memset(data, 0x00, 15);
  724|      1|		data[11] = 0x04;
  725|      1|		data[14] = 0x80;
  726|      1|		data[15] = 0x01;
  727|      1|		memcpy(&data[16], g_random, 8);
  728|      1|		memcpy(&data[24], &result[12 + 1], 8);
  729|    168|	} else {
  730|    168|		memcpy(data, &result[16], 4);
  731|    168|		memcpy(&data[4], g_random, 4);
  732|    168|		memcpy(&data[8], &result[12], 4);
  733|    168|		memcpy(&data[12], &g_random[4], 4);
  734|    168|	}
  735|       |
  736|       |	/* Step 2,3 - Create S-ENC/S-MAC Session Key */
  737|    169|	if (KEY_TYPE_AES == key_type) {
  ------------------
  |  |   80|    169|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (737:6): [True: 14, False: 155]
  ------------------
  738|     14|		if (isFips) {
  ------------------
  |  Branch (738:7): [True: 1, False: 13]
  ------------------
  739|      1|			r = aes128_encrypt_cmac(card, key_enc, 128, data, 32, exdata->sk_enc);
  740|      1|			LOG_TEST_RET(card->ctx, r, "aes128_encrypt_cmac enc 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  741|      1|			memset(&data[11], 0x06, 1);
  742|      1|			r = aes128_encrypt_cmac(card, key_mac, 128, data, 32, exdata->sk_mac);
  743|      1|			LOG_TEST_RET(card->ctx, r, "aes128_encrypt_cmac mac  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  744|     13|		} else {
  745|     13|			r = aes128_encrypt_ecb(card, key_enc, 16, data, 16, exdata->sk_enc);
  746|     13|			LOG_TEST_RET(card->ctx, r, "aes128_encrypt_ecb enc  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  747|     13|			r = aes128_encrypt_ecb(card, key_mac, 16, data, 16, exdata->sk_mac);
  748|     13|			LOG_TEST_RET(card->ctx, r, "aes128_encrypt_ecb mac  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  749|     13|		}
  750|    155|	} else {
  751|    155|		r = des3_encrypt_ecb(card, key_enc, 16, data, 16, exdata->sk_enc);
  752|    155|		LOG_TEST_RET(card->ctx, r, "des3_encrypt_ecb failed");
  ------------------
  |  |  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: 0, False: 155]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|    155|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 155]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  753|    155|		r = des3_encrypt_ecb(card, key_mac, 16, data, 16, exdata->sk_mac);
  754|    155|		LOG_TEST_RET(card->ctx, r, "des3_encrypt_ecb failed");
  ------------------
  |  |  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: 0, False: 155]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|    155|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 155]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  755|    155|	}
  756|       |
  757|    169|	if (isFips) {
  ------------------
  |  Branch (757:6): [True: 1, False: 168]
  ------------------
  758|      1|		data[11] = 0x00;
  759|      1|		data[14] = 0x40;
  760|    168|	} else {
  761|    168|		memcpy(data, g_random, 8);
  762|    168|		memcpy(&data[8], &result[12], 8);
  763|    168|		data[16] = 0x80;
  764|    168|		blocksize = (key_type == KEY_TYPE_AES ? 16 : 8);
  ------------------
  |  |   80|    168|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (764:16): [True: 13, False: 155]
  ------------------
  765|    168|		memset(&data[17], 0x00, blocksize - 1);
  766|    168|	}
  767|       |
  768|       |	/* calculate host cryptogram */
  769|    169|	if (KEY_TYPE_AES == key_type) {
  ------------------
  |  |   80|    169|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (769:6): [True: 14, False: 155]
  ------------------
  770|     14|		if (isFips) {
  ------------------
  |  Branch (770:7): [True: 1, False: 13]
  ------------------
  771|      1|			r = aes128_encrypt_cmac(card, exdata->sk_enc, 128, data, 32, cryptogram);
  772|     13|		} else {
  773|     13|			r = aes128_encrypt_cbc(card, exdata->sk_enc, 16, iv, data, 16 + blocksize, cryptogram);
  774|     13|		}
  775|    155|	} else {
  776|    155|		r = des3_encrypt_cbc(card, exdata->sk_enc, 16, iv, data, 16 + blocksize, cryptogram);
  777|    155|	}
  778|       |
  779|    169|	LOG_TEST_RET(card->ctx, r, "calculate host cryptogram failed");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  780|       |
  781|       |	/* verify card cryptogram */
  782|    169|	if (isFips) {
  ------------------
  |  Branch (782:6): [True: 1, False: 168]
  ------------------
  783|      1|		if (0 != memcmp(&cryptogram[0], &result[20+1], 8))
  ------------------
  |  Branch (783:7): [True: 1, False: 0]
  ------------------
  784|      1|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_CARD_CMD_FAILED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  785|    168|	} else {
  786|    168|		if (0 != memcmp(&cryptogram[16], &result[20], 8))
  ------------------
  |  Branch (786:7): [True: 168, False: 0]
  ------------------
  787|    168|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_CARD_CMD_FAILED);
  ------------------
  |  |  164|    168|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    168|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    168|	int _ret = r; \
  |  |  |  |  155|    168|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 168, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    168|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    168|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    168|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    168|	return _ret; \
  |  |  |  |  163|    168|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  788|    168|	}
  789|      0|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  790|      0|}
card-epass2003.c:epass2003_transmit_apdu:
 1635|    808|{
 1636|    808|	int r;
 1637|       |
 1638|    808|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    808|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    808|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    808|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    808|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 808]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1639|       |
 1640|    808|	r = sc_transmit_apdu_t(card, apdu);
 1641|    808|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    808|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    808|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    808|	int _ret = (r); \
  |  |  |  |  168|    808|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 45, False: 763]
  |  |  |  |  ------------------
  |  |  |  |  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|    808|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 763]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1642|       |
 1643|    763|	return r;
 1644|    808|}
card-epass2003.c:sc_transmit_apdu_t:
  268|  6.82k|{
  269|  6.82k|	size_t resplen = apdu->resplen;
  270|  6.82k|	int r = sc_transmit_apdu(card, apdu);
  271|  6.82k|	if ((0x69 == apdu->sw1 && 0x85 == apdu->sw2) || (0x69 == apdu->sw1 && 0x88 == apdu->sw2)) {
  ------------------
  |  Branch (271:7): [True: 206, False: 6.61k]
  |  Branch (271:28): [True: 73, False: 133]
  |  Branch (271:51): [True: 133, False: 6.61k]
  |  Branch (271:72): [True: 80, False: 53]
  ------------------
  272|    153|		epass2003_refresh(card);
  273|       |		/* renew old resplen */
  274|    153|		apdu->resplen = resplen;
  275|    153|		r = sc_transmit_apdu(card, apdu);
  276|    153|	}
  277|  6.82k|	return r;
  278|  6.82k|}
card-epass2003.c:aes128_encrypt_cmac:
  415|      5|{
  416|      5|	size_t mactlen = 0;
  417|      5|	int r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      5|#define SC_ERROR_INTERNAL			-1400
  ------------------
  418|      5|#if OPENSSL_VERSION_NUMBER < 0x30000000L
  419|      5|	CMAC_CTX *ctx = CMAC_CTX_new();
  420|      5|	if (ctx == NULL) {
  ------------------
  |  Branch (420:6): [True: 0, False: 5]
  ------------------
  421|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  422|      0|	}
  423|       |
  424|      5|	if (!CMAC_Init(ctx, key, keysize / 8, EVP_aes_128_cbc(), NULL)) {
  ------------------
  |  Branch (424:6): [True: 0, False: 5]
  ------------------
  425|      0|		goto err;
  426|      0|	}
  427|      5|	if (!CMAC_Update(ctx, input, length)) {
  ------------------
  |  Branch (427:6): [True: 0, False: 5]
  ------------------
  428|      0|		goto err;
  429|      0|	}
  430|      5|	if (!CMAC_Final(ctx, output, &mactlen)) {
  ------------------
  |  Branch (430:6): [True: 0, False: 5]
  ------------------
  431|      0|		goto err;
  432|      0|	}
  433|      5|	r = SC_SUCCESS;
  ------------------
  |  |   28|      5|#define SC_SUCCESS				0
  ------------------
  434|      5|err:
  435|      5|	CMAC_CTX_free(ctx);
  436|       |#else
  437|       |	EVP_MAC *mac = EVP_MAC_fetch(card->ctx->ossl3ctx->libctx, "cmac", NULL);
  438|       |	if (mac == NULL) {
  439|       |		return r;
  440|       |	}
  441|       |
  442|       |	OSSL_PARAM params[2] = {0};
  443|       |	params[0] = OSSL_PARAM_construct_utf8_string("cipher","aes-128-cbc", 0);
  444|       |	params[1] = OSSL_PARAM_construct_end();
  445|       |
  446|       |	EVP_MAC_CTX *ctx = EVP_MAC_CTX_new(mac);
  447|       |	if (ctx == NULL) {
  448|       |		EVP_MAC_CTX_free(ctx);
  449|       |		sc_log_openssl(card->ctx);
  450|       |		return r;
  451|       |	}
  452|       |	if (!EVP_MAC_init(ctx, (const unsigned char *)key, keysize / 8, params)) {
  453|       |		sc_log_openssl(card->ctx);
  454|       |		goto err;
  455|       |	}
  456|       |	if (!EVP_MAC_update(ctx, input, length)) {
  457|       |		sc_log_openssl(card->ctx);
  458|       |		goto err;
  459|       |	}
  460|       |	if (!EVP_MAC_final(ctx, output, &mactlen, 16)) {
  461|       |		sc_log_openssl(card->ctx);
  462|       |		goto err;
  463|       |	}
  464|       |	r = SC_SUCCESS;
  465|       |err:
  466|       |	EVP_MAC_CTX_free(ctx);
  467|       |	EVP_MAC_free(mac);
  468|       |#endif
  469|      5|	return r;
  470|      5|}
card-epass2003.c:aes128_encrypt_ecb:
  475|     26|{
  476|     26|	unsigned char iv[EVP_MAX_IV_LENGTH] = {0};
  477|     26|	EVP_CIPHER *alg = sc_evp_cipher(card->ctx, "AES-128-ECB");
  478|     26|	int r;
  479|     26|	r = openssl_enc(alg, key, iv, input, length, output);
  480|     26|	sc_evp_cipher_free(alg);
  481|     26|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|     26|#define SC_SUCCESS				0
  ------------------
  |  Branch (481:6): [True: 0, False: 26]
  ------------------
  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|     26|	return r;
  484|     26|}
card-epass2003.c:openssl_enc:
  283|  2.89k|{
  284|  2.89k|	int r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|  2.89k|#define SC_ERROR_INTERNAL			-1400
  ------------------
  285|  2.89k|	EVP_CIPHER_CTX * ctx = NULL;
  286|  2.89k|	int outl = 0;
  287|  2.89k|	int outl_tmp = 0;
  288|  2.89k|	unsigned char iv_tmp[EVP_MAX_IV_LENGTH] = {0};
  289|       |
  290|  2.89k|	memcpy(iv_tmp, iv, EVP_MAX_IV_LENGTH);
  291|  2.89k|	ctx = EVP_CIPHER_CTX_new();
  292|  2.89k|	if (ctx == NULL)
  ------------------
  |  Branch (292:6): [True: 0, False: 2.89k]
  ------------------
  293|      0|		goto out;
  294|       |
  295|  2.89k|	if (!EVP_EncryptInit_ex(ctx, cipher, NULL, key, iv_tmp) || !EVP_CIPHER_CTX_set_padding(ctx, 0))
  ------------------
  |  Branch (295:6): [True: 0, False: 2.89k]
  |  Branch (295:61): [True: 0, False: 2.89k]
  ------------------
  296|      0|		goto out;
  297|       |
  298|  2.89k|	if (!EVP_EncryptUpdate(ctx, output, &outl, input, (int)length))
  ------------------
  |  Branch (298:6): [True: 0, False: 2.89k]
  ------------------
  299|      0|		goto out;
  300|       |
  301|  2.89k|	if (!EVP_EncryptFinal_ex(ctx, output + outl, &outl_tmp))
  ------------------
  |  Branch (301:6): [True: 0, False: 2.89k]
  ------------------
  302|      0|		goto out;
  303|       |
  304|  2.89k|	r = SC_SUCCESS;
  ------------------
  |  |   28|  2.89k|#define SC_SUCCESS				0
  ------------------
  305|  2.89k|out:
  306|  2.89k|	EVP_CIPHER_CTX_free(ctx);
  307|  2.89k|	return r;
  308|  2.89k|}
card-epass2003.c:des3_encrypt_ecb:
  518|    310|{
  519|    310|	unsigned char iv[EVP_MAX_IV_LENGTH] = {0};
  520|    310|	unsigned char bKey[24] = {0};
  521|    310|	EVP_CIPHER *alg = sc_evp_cipher(card->ctx, "DES-EDE3");
  522|    310|	int r;
  523|       |
  524|    310|	if (keysize == 16) {
  ------------------
  |  Branch (524:6): [True: 310, False: 0]
  ------------------
  525|    310|		memcpy(&bKey[0], key, 16);
  526|    310|		memcpy(&bKey[16], key, 8);
  527|    310|	} else {
  528|      0|		memcpy(&bKey[0], key, 24);
  529|      0|	}
  530|       |
  531|    310|	r = openssl_enc(alg, bKey, iv, input, length, output);
  532|    310|	sc_evp_cipher_free(alg);
  533|    310|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|    310|#define SC_SUCCESS				0
  ------------------
  |  Branch (533:6): [True: 0, False: 310]
  ------------------
  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|    310|	return r;
  536|    310|}
card-epass2003.c:aes128_encrypt_cbc:
  490|    107|{
  491|    107|	EVP_CIPHER *alg = sc_evp_cipher(card->ctx, "AES-128-CBC");
  492|    107|	int r;
  493|    107|	r = openssl_enc(alg, key, iv, input, length, output);
  494|    107|	sc_evp_cipher_free(alg);
  495|    107|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|    107|#define SC_SUCCESS				0
  ------------------
  |  Branch (495:6): [True: 0, False: 107]
  ------------------
  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|    107|	return r;
  498|    107|}
card-epass2003.c:des3_encrypt_cbc:
  542|    910|{
  543|    910|	unsigned char bKey[24] = {0};
  544|    910|	EVP_CIPHER *alg = sc_evp_cipher(card->ctx, "DES-EDE3-CBC");
  545|    910|	int r;
  546|       |
  547|    910|	if (keysize == 16) {
  ------------------
  |  Branch (547:6): [True: 910, False: 0]
  ------------------
  548|    910|		memcpy(&bKey[0], key, 16);
  549|    910|		memcpy(&bKey[16], key, 8);
  550|    910|	} else {
  551|      0|		memcpy(&bKey[0], key, 24);
  552|      0|	}
  553|       |
  554|    910|	r = openssl_enc(EVP_des_ede3_cbc(), bKey, iv, input, length, output);
  555|    910|	sc_evp_cipher_free(alg);
  556|    910|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|    910|#define SC_SUCCESS				0
  ------------------
  |  Branch (556:6): [True: 0, False: 910]
  ------------------
  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|    910|	return r;
  559|    910|}
card-epass2003.c:sc_get_driver:
 3289|  16.3k|{
 3290|  16.3k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 3291|       |
 3292|  16.3k|	if (iso_ops == NULL)
  ------------------
  |  Branch (3292:6): [True: 1, False: 16.3k]
  ------------------
 3293|      1|		iso_ops = iso_drv->ops;
 3294|       |
 3295|  16.3k|	epass2003_ops = *iso_ops;
 3296|       |
 3297|  16.3k|	epass2003_ops.match_card = epass2003_match_card;
 3298|  16.3k|	epass2003_ops.init = epass2003_init;
 3299|  16.3k|	epass2003_ops.finish = epass2003_finish;
 3300|  16.3k|	epass2003_ops.write_binary = NULL;
 3301|  16.3k|	epass2003_ops.write_record = NULL;
 3302|  16.3k|	epass2003_ops.select_file = epass2003_select_file;
 3303|       |	epass2003_ops.get_response = NULL;
 3304|  16.3k|	epass2003_ops.restore_security_env = epass2003_restore_security_env;
 3305|  16.3k|	epass2003_ops.set_security_env = epass2003_set_security_env;
 3306|  16.3k|	epass2003_ops.decipher = epass2003_decipher;
 3307|  16.3k|	epass2003_ops.compute_signature = epass2003_decipher;
 3308|  16.3k|	epass2003_ops.create_file = epass2003_create_file;
 3309|  16.3k|	epass2003_ops.delete_file = epass2003_delete_file;
 3310|  16.3k|	epass2003_ops.list_files = epass2003_list_files;
 3311|  16.3k|	epass2003_ops.card_ctl = epass2003_card_ctl;
 3312|  16.3k|	epass2003_ops.process_fci = epass2003_process_fci;
 3313|  16.3k|	epass2003_ops.construct_fci = epass2003_construct_fci;
 3314|  16.3k|	epass2003_ops.pin_cmd = epass2003_pin_cmd;
 3315|  16.3k|	epass2003_ops.check_sw = epass2003_check_sw;
 3316|  16.3k|	epass2003_ops.get_challenge = epass2003_get_challenge;
 3317|  16.3k|	epass2003_ops.logout = epass2003_logout;
 3318|  16.3k|	return &epass2003_drv;
 3319|  16.3k|}
card-epass2003.c:epass2003_match_card:
 1687|  11.8k|{
 1688|  11.8k|	int r;
 1689|       |
 1690|  11.8k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  11.8k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  11.8k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  11.8k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  11.8k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 11.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1691|  11.8k|	r = _sc_match_atr(card, epass2003_atrs, &card->type);
 1692|  11.8k|	if (r < 0)
  ------------------
  |  Branch (1692:6): [True: 10.9k, False: 882]
  ------------------
 1693|  10.9k|		return 0;
 1694|       |
 1695|    882|	return 1;
 1696|  11.8k|}
card-epass2003.c:epass2003_init:
 1701|    882|{
 1702|    882|	unsigned int flags;
 1703|    882|	unsigned int ext_flags;
 1704|    882|	unsigned char data[SC_MAX_APDU_BUFFER_SIZE] = {0};
 1705|    882|	size_t datalen = SC_MAX_APDU_BUFFER_SIZE;
  ------------------
  |  |   34|    882|#define SC_MAX_APDU_BUFFER_SIZE		261 /* takes account of: CLA INS P1 P2 Lc [255 byte of data] Le */
  ------------------
 1706|    882|	epass2003_exdata *exdata = NULL;
 1707|    882|	void *old_drv_data = card->drv_data;
 1708|       |
 1709|    882|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    882|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    882|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    882|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    882|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 882]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1710|       |
 1711|    882|	card->name = "epass2003";
 1712|    882|	card->cla = 0x00;
 1713|    882|	exdata = (epass2003_exdata *)calloc(1, sizeof(epass2003_exdata));
 1714|    882|	if (!exdata)
  ------------------
  |  Branch (1714:6): [True: 0, False: 882]
  ------------------
 1715|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1716|       |
 1717|    882|	card->drv_data = exdata;
 1718|       |
 1719|    882|	exdata->sm = SM_SCP01;
  ------------------
  |  |   92|    882|#define SM_SCP01				0x01
  ------------------
 1720|       |
 1721|       |	/* decide FIPS/Non-FIPS mode */
 1722|    882|	if (SC_SUCCESS != get_data(card, 0x86, data, datalen)) {
  ------------------
  |  |   28|    882|#define SC_SUCCESS				0
  ------------------
  |  Branch (1722:6): [True: 21, False: 861]
  ------------------
 1723|     21|		free(exdata);
 1724|     21|		card->drv_data = old_drv_data;
 1725|     21|		return SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|     21|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 1726|     21|	}
 1727|       |
 1728|    861|	if (memcmp(&data[32], "\x87\x01\x01", 3) == 0 && memcmp(&data[0], "\x80\x01\x01", 3) == 0) {
  ------------------
  |  Branch (1728:6): [True: 20, False: 841]
  |  Branch (1728:51): [True: 2, False: 18]
  ------------------
 1729|      2|		exdata->bFipsCertification = 0x01;
 1730|    859|	} else {
 1731|    859|		exdata->bFipsCertification = 0x00;
 1732|    859|	}
 1733|       |
 1734|    861|	if (0x01 == data[2])
  ------------------
  |  Branch (1734:6): [True: 22, False: 839]
  ------------------
 1735|     22|		exdata->smtype = KEY_TYPE_AES;
  ------------------
  |  |   80|     22|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
 1736|    839|	else
 1737|    839|		exdata->smtype = KEY_TYPE_DES;
  ------------------
  |  |   81|    839|#define KEY_TYPE_DES	0x02	/* Non-FIPS mode */
  ------------------
 1738|       |
 1739|    861|	if (0x84 == data[14]) {
  ------------------
  |  Branch (1739:6): [True: 177, False: 684]
  ------------------
 1740|    177|		if (0x00 == data[16]) {
  ------------------
  |  Branch (1740:7): [True: 174, False: 3]
  ------------------
 1741|    174|			exdata->sm = SM_PLAIN;
  ------------------
  |  |   91|    174|#define SM_PLAIN				0x00
  ------------------
 1742|    174|		}
 1743|    177|	}
 1744|       |
 1745|       |	/* mutual authentication */
 1746|    861|	card->max_recv_size = 0xD8;
 1747|    861|	card->max_send_size = 0xE8;
 1748|       |
 1749|    861|	card->sm_ctx.ops.open = epass2003_refresh;
 1750|    861|	card->sm_ctx.ops.get_sm_apdu = epass2003_sm_get_wrapped_apdu;
 1751|    861|	card->sm_ctx.ops.free_sm_apdu = epass2003_sm_free_wrapped_apdu;
 1752|       |
 1753|       |	/* FIXME (VT): rather then set/unset 'g_sm', better to implement filter for APDUs to be wrapped */
 1754|    861|	epass2003_refresh(card);
 1755|       |
 1756|    861|	card->sm_ctx.sm_mode = SM_MODE_TRANSMIT;
  ------------------
  |  |   47|    861|#define SM_MODE_TRANSMIT	0x200
  ------------------
 1757|       |
 1758|    861|	flags = SC_ALGORITHM_ONBOARD_KEY_GEN | SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |   93|    861|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
              	flags = SC_ALGORITHM_ONBOARD_KEY_GEN | SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  102|    861|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
              	flags = SC_ALGORITHM_ONBOARD_KEY_GEN | SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  133|    861|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
 1759|       |
 1760|    861|	_sc_card_add_rsa_alg(card, 512, flags, 0);
 1761|    861|	_sc_card_add_rsa_alg(card, 768, flags, 0);
 1762|    861|	_sc_card_add_rsa_alg(card, 1024, flags, 0);
 1763|    861|	_sc_card_add_rsa_alg(card, 2048, flags, 0);
 1764|       |
 1765|       |	//set EC Alg Flags
 1766|    861|	flags = SC_ALGORITHM_ONBOARD_KEY_GEN|SC_ALGORITHM_ECDSA_HASH_SHA1|SC_ALGORITHM_ECDSA_HASH_SHA256|SC_ALGORITHM_ECDSA_HASH_NONE|SC_ALGORITHM_ECDSA_RAW;
  ------------------
  |  |   93|    861|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
              	flags = SC_ALGORITHM_ONBOARD_KEY_GEN|SC_ALGORITHM_ECDSA_HASH_SHA1|SC_ALGORITHM_ECDSA_HASH_SHA256|SC_ALGORITHM_ECDSA_HASH_NONE|SC_ALGORITHM_ECDSA_RAW;
  ------------------
  |  |  176|    861|#define SC_ALGORITHM_ECDSA_HASH_SHA1		SC_ALGORITHM_RSA_HASH_SHA1
  |  |  ------------------
  |  |  |  |  134|    861|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  ------------------
  ------------------
              	flags = SC_ALGORITHM_ONBOARD_KEY_GEN|SC_ALGORITHM_ECDSA_HASH_SHA1|SC_ALGORITHM_ECDSA_HASH_SHA256|SC_ALGORITHM_ECDSA_HASH_NONE|SC_ALGORITHM_ECDSA_RAW;
  ------------------
  |  |  178|    861|#define SC_ALGORITHM_ECDSA_HASH_SHA256		SC_ALGORITHM_RSA_HASH_SHA256
  |  |  ------------------
  |  |  |  |  138|    861|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  |  |  ------------------
  ------------------
              	flags = SC_ALGORITHM_ONBOARD_KEY_GEN|SC_ALGORITHM_ECDSA_HASH_SHA1|SC_ALGORITHM_ECDSA_HASH_SHA256|SC_ALGORITHM_ECDSA_HASH_NONE|SC_ALGORITHM_ECDSA_RAW;
  ------------------
  |  |  175|    861|#define SC_ALGORITHM_ECDSA_HASH_NONE		SC_ALGORITHM_RSA_HASH_NONE
  |  |  ------------------
  |  |  |  |  133|    861|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  ------------------
              	flags = SC_ALGORITHM_ONBOARD_KEY_GEN|SC_ALGORITHM_ECDSA_HASH_SHA1|SC_ALGORITHM_ECDSA_HASH_SHA256|SC_ALGORITHM_ECDSA_HASH_NONE|SC_ALGORITHM_ECDSA_RAW;
  ------------------
  |  |  174|    861|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
 1767|    861|	ext_flags = 0;
 1768|    861|	_sc_card_add_ec_alg(card, 256, flags, ext_flags, NULL);
 1769|       |
 1770|    861|	card->caps = SC_CARD_CAP_RNG | SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  550|    861|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
              	card->caps = SC_CARD_CAP_RNG | SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  547|    861|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
 1771|       |
 1772|    861|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    861|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    861|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    861|	int _ret = r; \
  |  |  |  |  155|    861|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 861, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    861|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 861]
  |  |  |  |  ------------------
  |  |  |  |  157|    861|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    861|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    861|	return _ret; \
  |  |  |  |  163|    861|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1773|    861|}
card-epass2003.c:get_data:
 1649|  1.12k|{
 1650|  1.12k|	int r;
 1651|  1.12k|	struct sc_apdu apdu;
 1652|  1.12k|	unsigned char resp[SC_MAX_APDU_BUFFER_SIZE] = {0};
 1653|  1.12k|	size_t resplen = SC_MAX_APDU_BUFFER_SIZE;
  ------------------
  |  |   34|  1.12k|#define SC_MAX_APDU_BUFFER_SIZE		261 /* takes account of: CLA INS P1 P2 Lc [255 byte of data] Le */
  ------------------
 1654|  1.12k|	epass2003_exdata *exdata = NULL;
 1655|       |
 1656|  1.12k|	if (!card->drv_data)
  ------------------
  |  Branch (1656:6): [True: 0, False: 1.12k]
  ------------------
 1657|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1658|       |
 1659|  1.12k|	exdata = (epass2003_exdata *)card->drv_data;
 1660|       |
 1661|  1.12k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  1.12k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.12k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.12k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.12k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.12k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1662|       |
 1663|  1.12k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, type);
  ------------------
  |  |  292|  1.12k|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1664|  1.12k|	apdu.resp = resp;
 1665|  1.12k|	apdu.le = 0;
 1666|  1.12k|	apdu.resplen = resplen;
 1667|  1.12k|	if (0x86 == type) {
  ------------------
  |  Branch (1667:6): [True: 882, False: 247]
  ------------------
 1668|       |		/* No SM temporarily */
 1669|    882|		unsigned char tmp_sm = exdata->sm;
 1670|    882|		exdata->sm = SM_PLAIN;
  ------------------
  |  |   91|    882|#define SM_PLAIN				0x00
  ------------------
 1671|    882|		r = sc_transmit_apdu(card, &apdu);
 1672|    882|		exdata->sm = tmp_sm;
 1673|    882|	} else {
 1674|    247|		r = sc_transmit_apdu_t(card, &apdu);
 1675|    247|	}
 1676|  1.12k|	LOG_TEST_RET(card->ctx, r, "APDU get_data failed");
  ------------------
  |  |  174|  1.12k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.12k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.12k|	int _ret = (r); \
  |  |  |  |  168|  1.12k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 9, False: 1.12k]
  |  |  |  |  ------------------
  |  |  |  |  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|  1.12k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.12k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1677|  1.12k|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1678|  1.12k|	LOG_TEST_RET(card->ctx, r, "get_data failed");
  ------------------
  |  |  174|  1.12k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.12k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.12k|	int _ret = (r); \
  |  |  |  |  168|  1.12k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 202, False: 918]
  |  |  |  |  ------------------
  |  |  |  |  169|    202|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    202|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    202|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    202|		return _ret; \
  |  |  |  |  172|    202|	} \
  |  |  |  |  173|  1.12k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 918]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1679|       |
 1680|    918|	memcpy(data, resp, datalen);
 1681|    918|	return r;
 1682|  1.12k|}
card-epass2003.c:epass2003_sm_get_wrapped_apdu:
 1584|  1.60k|{
 1585|  1.60k|	struct sc_context *ctx = card->ctx;
 1586|  1.60k|	struct sc_apdu *apdu = NULL;
 1587|  1.60k|	int rv;
 1588|       |
 1589|  1.60k|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1590|  1.60k|	if (!plain || !sm_apdu)
  ------------------
  |  Branch (1590:6): [True: 0, False: 1.60k]
  |  Branch (1590:16): [True: 0, False: 1.60k]
  ------------------
 1591|  1.60k|		LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1592|       |
 1593|  1.60k|	*sm_apdu = NULL;
 1594|       |	//construct new SM apdu from original apdu
 1595|  1.60k|	apdu = calloc(1, sizeof(struct sc_apdu));
 1596|  1.60k|	if (!apdu) {
  ------------------
  |  Branch (1596:6): [True: 0, False: 1.60k]
  ------------------
 1597|      0|		rv = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1598|      0|		goto err;
 1599|      0|	}
 1600|  1.60k|	apdu->data = calloc (1, SC_MAX_EXT_APDU_BUFFER_SIZE);
  ------------------
  |  |   37|  1.60k|#define SC_MAX_EXT_APDU_BUFFER_SIZE	65538
  ------------------
 1601|  1.60k|	if (!apdu->data) {
  ------------------
  |  Branch (1601:6): [True: 0, False: 1.60k]
  ------------------
 1602|      0|		rv = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1603|      0|		goto err;
 1604|      0|	}
 1605|  1.60k|	apdu->resp = calloc (1, SC_MAX_EXT_APDU_BUFFER_SIZE);
  ------------------
  |  |   37|  1.60k|#define SC_MAX_EXT_APDU_BUFFER_SIZE	65538
  ------------------
 1606|  1.60k|	if (!apdu->resp) {
  ------------------
  |  Branch (1606:6): [True: 0, False: 1.60k]
  ------------------
 1607|      0|		rv = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1608|      0|		goto err;
 1609|      0|	}
 1610|  1.60k|	apdu->datalen = SC_MAX_EXT_APDU_BUFFER_SIZE;
  ------------------
  |  |   37|  1.60k|#define SC_MAX_EXT_APDU_BUFFER_SIZE	65538
  ------------------
 1611|  1.60k|	apdu->resplen = SC_MAX_EXT_APDU_BUFFER_SIZE;
  ------------------
  |  |   37|  1.60k|#define SC_MAX_EXT_APDU_BUFFER_SIZE	65538
  ------------------
 1612|       |
 1613|  1.60k|	rv = epass2003_sm_wrap_apdu(card, plain, apdu);
 1614|  1.60k|	if (rv) {
  ------------------
  |  Branch (1614:6): [True: 0, False: 1.60k]
  ------------------
 1615|      0|		rv = epass2003_sm_free_wrapped_apdu(card, NULL, &apdu);
 1616|      0|		if (rv < 0)
  ------------------
  |  Branch (1616:7): [True: 0, False: 0]
  ------------------
 1617|      0|			goto err;
 1618|      0|	}
 1619|       |
 1620|  1.60k|	*sm_apdu = apdu;
 1621|  1.60k|	apdu = NULL;
 1622|  1.60k|err:
 1623|  1.60k|	if (apdu) {
  ------------------
  |  Branch (1623:6): [True: 0, False: 1.60k]
  ------------------
 1624|      0|		free((unsigned char *) apdu->data);
 1625|      0|		free(apdu->resp);
 1626|      0|		free(apdu);
 1627|      0|		apdu = NULL;
 1628|      0|	}
 1629|  1.60k|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1630|  1.60k|}
card-epass2003.c:epass2003_sm_wrap_apdu:
 1299|  1.60k|{
 1300|  1.60k|	unsigned char buf[4096] = {0}; /* APDU buffer */
 1301|  1.60k|	size_t buf_len = sizeof(buf);
 1302|  1.60k|	epass2003_exdata *exdata = NULL;
 1303|       |
 1304|  1.60k|	if (!card->drv_data)
  ------------------
  |  Branch (1304:6): [True: 0, False: 1.60k]
  ------------------
 1305|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1306|       |
 1307|  1.60k|	exdata = (epass2003_exdata *)card->drv_data;
 1308|       |
 1309|  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1310|       |
 1311|  1.60k|	if (exdata->sm)
  ------------------
  |  Branch (1311:6): [True: 808, False: 798]
  ------------------
 1312|    808|		plain->cla |= 0x0C;
 1313|       |
 1314|  1.60k|	sm->cse = plain->cse;
 1315|  1.60k|	sm->cla = plain->cla;
 1316|  1.60k|	sm->ins = plain->ins;
 1317|  1.60k|	sm->p1 = plain->p1;
 1318|  1.60k|	sm->p2 = plain->p2;
 1319|  1.60k|	sm->lc = plain->lc;
 1320|  1.60k|	sm->le = plain->le;
 1321|  1.60k|	sm->control = plain->control;
 1322|  1.60k|	sm->flags = plain->flags;
 1323|       |
 1324|  1.60k|	switch (sm->cla & 0x0C) {
 1325|    798|	case 0x00:
  ------------------
  |  Branch (1325:2): [True: 798, False: 808]
  ------------------
 1326|    798|	case 0x04:
  ------------------
  |  Branch (1326:2): [True: 0, False: 1.60k]
  ------------------
 1327|    798|		sm->datalen = plain->datalen;
 1328|    798|		memcpy((void *)sm->data, plain->data, plain->datalen);
 1329|    798|		sm->resplen = plain->resplen;
 1330|    798|		memcpy(sm->resp, plain->resp, plain->resplen);
 1331|    798|		break;
 1332|    808|	case 0x0C:
  ------------------
  |  Branch (1332:2): [True: 808, False: 798]
  ------------------
 1333|    808|		memset(buf, 0, sizeof(buf));
 1334|    808|		if (0 != encode_apdu(card, plain, sm, buf, &buf_len))
  ------------------
  |  Branch (1334:7): [True: 0, False: 808]
  ------------------
 1335|      0|			return SC_ERROR_CARD_CMD_FAILED;
  ------------------
  |  |   50|      0|#define SC_ERROR_CARD_CMD_FAILED		-1200
  ------------------
 1336|    808|		break;
 1337|    808|	default:
  ------------------
  |  Branch (1337:2): [True: 0, False: 1.60k]
  ------------------
 1338|      0|		return SC_ERROR_INCORRECT_PARAMETERS;
  ------------------
  |  |   55|      0|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
 1339|  1.60k|	}
 1340|       |
 1341|  1.60k|	return SC_SUCCESS;
  ------------------
  |  |   28|  1.60k|#define SC_SUCCESS				0
  ------------------
 1342|  1.60k|}
card-epass2003.c:encode_apdu:
 1202|    808|{
 1203|    808|	size_t block_size = 0;
 1204|    808|	unsigned char dataTLV[4096] = {0};
 1205|    808|	size_t data_tlv_len = 0;
 1206|    808|	unsigned char le_tlv[256] = {0};
 1207|    808|	size_t le_tlv_len = 0;
 1208|    808|	size_t mac_tlv_len = 10;
 1209|    808|	size_t tmp_lc = 0;
 1210|    808|	size_t tmp_le = 0;
 1211|    808|	size_t expected_total_len;
 1212|    808|	unsigned char mac_tlv[256] = {0};
 1213|    808|	epass2003_exdata *exdata = NULL;
 1214|       |
 1215|    808|	mac_tlv[0] = 0x8E;
 1216|    808|	mac_tlv[1] = 8;
 1217|       |	/* size_t plain_le = 0; */
 1218|    808|	if (!card->drv_data)
  ------------------
  |  Branch (1218:6): [True: 0, False: 808]
  ------------------
 1219|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1220|    808|	exdata = (epass2003_exdata*)card->drv_data;
 1221|    808|	block_size = (KEY_TYPE_DES == exdata->smtype ? 16 : 8);
  ------------------
  |  |   81|    808|#define KEY_TYPE_DES	0x02	/* Non-FIPS mode */
  ------------------
  |  Branch (1221:16): [True: 758, False: 50]
  ------------------
 1222|       |
 1223|    808|	sm->cse = SC_APDU_CASE_4_SHORT;
  ------------------
  |  |  294|    808|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
 1224|    808|	apdu_buf[0] = (unsigned char)plain->cla;
 1225|    808|	apdu_buf[1] = (unsigned char)plain->ins;
 1226|    808|	apdu_buf[2] = (unsigned char)plain->p1;
 1227|    808|	apdu_buf[3] = (unsigned char)plain->p2;
 1228|       |	/* plain_le = plain->le; */
 1229|       |	/* padding */
 1230|    808|	if (exdata->bFipsCertification && plain->lc == 0 && apdu_buf[1] == 0x82 && apdu_buf[2] == 0x01) {
  ------------------
  |  Branch (1230:6): [True: 2, False: 806]
  |  Branch (1230:36): [True: 0, False: 2]
  |  Branch (1230:54): [True: 0, False: 0]
  |  Branch (1230:77): [True: 0, False: 0]
  ------------------
 1231|      0|		apdu_buf[4] = 0x00;
 1232|    808|	} else {
 1233|    808|		apdu_buf[4] = 0x80;
 1234|    808|	}
 1235|    808|	memset(&apdu_buf[5], 0x00, block_size - 5);
 1236|       |
 1237|       |	/* Data -> Data' */
 1238|    808|	if (plain->lc != 0)
  ------------------
  |  Branch (1238:6): [True: 801, False: 7]
  ------------------
 1239|    801|		if (0 != construct_data_tlv(card, plain, apdu_buf, dataTLV, &data_tlv_len, exdata->smtype))
  ------------------
  |  Branch (1239:7): [True: 0, False: 801]
  ------------------
 1240|      0|			return -1;
 1241|       |
 1242|    808|	if (plain->le != 0 || (plain->le == 0 && plain->resplen != 0))
  ------------------
  |  Branch (1242:6): [True: 24, False: 784]
  |  Branch (1242:25): [True: 784, False: 0]
  |  Branch (1242:43): [True: 780, False: 4]
  ------------------
 1243|    804|		if (0 != construct_le_tlv(plain, apdu_buf, data_tlv_len, le_tlv,
  ------------------
  |  Branch (1243:7): [True: 0, False: 804]
  ------------------
 1244|    804|				     &le_tlv_len, exdata->smtype))
 1245|      0|			return -1;
 1246|       |
 1247|    808|	if (exdata->bFipsCertification && plain->lc == 0 && apdu_buf[1] == 0x82 && apdu_buf[2] == 0x01) {
  ------------------
  |  Branch (1247:6): [True: 2, False: 806]
  |  Branch (1247:36): [True: 0, False: 2]
  |  Branch (1247:54): [True: 0, False: 0]
  |  Branch (1247:77): [True: 0, False: 0]
  ------------------
 1248|      0|		if (0 != construct_mac_tlv_case1(card, apdu_buf, data_tlv_len, le_tlv_len, mac_tlv, &mac_tlv_len, exdata->smtype))
  ------------------
  |  Branch (1248:7): [True: 0, False: 0]
  ------------------
 1249|      0|			return -1;
 1250|    808|	} else {
 1251|    808|		if (0 != construct_mac_tlv(card, apdu_buf, data_tlv_len, le_tlv_len, mac_tlv, &mac_tlv_len, exdata->smtype))
  ------------------
  |  Branch (1251:7): [True: 0, False: 808]
  ------------------
 1252|      0|			return -1;
 1253|    808|	}
 1254|       |
 1255|    808|	memset(apdu_buf + 4, 0, *apdu_buf_len - 4);
 1256|    808|	sm->lc = sm->datalen = data_tlv_len + le_tlv_len + mac_tlv_len;
 1257|    808|	if (sm->lc > 0xFF) {
  ------------------
  |  Branch (1257:6): [True: 0, False: 808]
  ------------------
 1258|      0|		sm->cse = SC_APDU_CASE_4_EXT;
  ------------------
  |  |  299|      0|#define SC_APDU_CASE_4_EXT		SC_APDU_CASE_4_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  294|      0|#define SC_APDU_CASE_4_SHORT		0x04
  |  |  ------------------
  |  |               #define SC_APDU_CASE_4_EXT		SC_APDU_CASE_4_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  296|      0|#define SC_APDU_EXT			0x10
  |  |  ------------------
  ------------------
 1259|      0|		apdu_buf[4] = (unsigned char)((sm->lc) / 0x10000);
 1260|      0|		apdu_buf[5] = (unsigned char)(((sm->lc) / 0x100) % 0x100);
 1261|      0|		apdu_buf[6] = (unsigned char)((sm->lc) % 0x100);
 1262|      0|		tmp_lc = 3;
 1263|    808|	} else {
 1264|    808|		apdu_buf[4] = (unsigned char)sm->lc;
 1265|    808|		tmp_lc = 1;
 1266|    808|	}
 1267|       |
 1268|       |	/* 2 is for Le extension in the worst case */
 1269|    808|	expected_total_len = 4 + tmp_lc + data_tlv_len + le_tlv_len + mac_tlv_len + 2;
 1270|       |
 1271|    808|	if (expected_total_len > *apdu_buf_len) {
  ------------------
  |  Branch (1271:6): [True: 0, False: 808]
  ------------------
 1272|      0|	    return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
 1273|      0|	}
 1274|       |
 1275|    808|	memcpy(apdu_buf + 4 + tmp_lc, dataTLV, data_tlv_len);
 1276|    808|	memcpy(apdu_buf + 4 + tmp_lc + data_tlv_len, le_tlv, le_tlv_len);
 1277|    808|	memcpy(apdu_buf + 4 + tmp_lc + data_tlv_len + le_tlv_len, mac_tlv, mac_tlv_len);
 1278|    808|	memcpy((unsigned char *)sm->data, apdu_buf + 4 + tmp_lc, sm->datalen);
 1279|    808|	*apdu_buf_len = 0;
 1280|       |
 1281|    808|	if (4 == le_tlv_len) {
  ------------------
  |  Branch (1281:6): [True: 23, False: 785]
  ------------------
 1282|     23|		sm->cse = SC_APDU_CASE_4_EXT;
  ------------------
  |  |  299|     23|#define SC_APDU_CASE_4_EXT		SC_APDU_CASE_4_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  294|     23|#define SC_APDU_CASE_4_SHORT		0x04
  |  |  ------------------
  |  |               #define SC_APDU_CASE_4_EXT		SC_APDU_CASE_4_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  296|     23|#define SC_APDU_EXT			0x10
  |  |  ------------------
  ------------------
 1283|     23|		*(apdu_buf + 4 + tmp_lc + sm->lc) = (unsigned char)(plain->le / 0x100);
 1284|     23|		*(apdu_buf + 4 + tmp_lc + sm->lc + 1) = (unsigned char)(plain->le % 0x100);
 1285|     23|		tmp_le = 2;
 1286|    785|	} else if (3 == le_tlv_len) {
  ------------------
  |  Branch (1286:13): [True: 781, False: 4]
  ------------------
 1287|    781|		*(apdu_buf + 4 + tmp_lc + sm->lc) = (unsigned char)plain->le;
 1288|    781|		tmp_le = 1;
 1289|    781|	}
 1290|       |
 1291|    808|	*apdu_buf_len += 4 + tmp_lc + data_tlv_len + le_tlv_len + mac_tlv_len + tmp_le;
 1292|       |	/* sm->le = calc_le(plain_le); */
 1293|    808|	return 0;
 1294|    808|}
card-epass2003.c:construct_data_tlv:
  950|    801|{
  951|    801|	size_t block_size = (KEY_TYPE_AES == key_type ? 16 : 8);
  ------------------
  |  |   80|    801|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (951:23): [True: 46, False: 755]
  ------------------
  952|    801|	unsigned char pad[4096] = {0};
  953|    801|	size_t pad_len;
  954|    801|	size_t tlv_more;	/* increased tlv length */
  955|    801|	unsigned char iv[16] = {0};
  956|    801|	epass2003_exdata *exdata = NULL;
  957|    801|	int r = 0;
  958|       |
  959|    801|	if (!card->drv_data)
  ------------------
  |  Branch (959:6): [True: 0, False: 801]
  ------------------
  960|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  961|       |
  962|    801|	exdata = (epass2003_exdata *)card->drv_data;
  963|       |
  964|       |	/* we encrypt the pad buffer and then write it to the apdu_buf at offset block_size + tlv_more */
  965|    801|	if (apdu->lc >= sizeof(pad) - block_size - 5)
  ------------------
  |  Branch (965:6): [True: 0, False: 801]
  ------------------
  966|    801|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_DATA,
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  967|    801|				"ePass2003 secure messaging APDU data too large");
  968|       |
  969|       |	/* padding */
  970|    801|	apdu_buf[block_size] = 0x87;
  971|    801|	memcpy(pad, apdu->data, apdu->lc);
  972|    801|	pad[apdu->lc] = 0x80;
  973|    801|	if ((apdu->lc + 1) % block_size)
  ------------------
  |  Branch (973:6): [True: 800, False: 1]
  ------------------
  974|    800|		pad_len = ((apdu->lc + 1) / block_size + 1) * block_size;
  975|      1|	else
  976|      1|		pad_len = apdu->lc + 1;
  977|       |
  978|       |	/* encode Lc' */
  979|    801|	if (pad_len > 0x7E) {
  ------------------
  |  Branch (979:6): [True: 0, False: 801]
  ------------------
  980|       |		/* Lc' > 0x7E, use extended APDU */
  981|      0|		apdu_buf[block_size + 1] = 0x82;
  982|      0|		apdu_buf[block_size + 2] = (unsigned char)((pad_len + 1) / 0x100);
  983|      0|		apdu_buf[block_size + 3] = (unsigned char)((pad_len + 1) % 0x100);
  984|      0|		apdu_buf[block_size + 4] = 0x01;
  985|      0|		tlv_more = 5;
  986|    801|	} else {
  987|    801|		apdu_buf[block_size + 1] = (unsigned char)pad_len + 1;
  988|    801|		apdu_buf[block_size + 2] = 0x01;
  989|    801|		tlv_more = 3;
  990|    801|	}
  991|    801|	memcpy(data_tlv, &apdu_buf[block_size], tlv_more);
  992|       |
  993|       |	/* encrypt Data */
  994|    801|	if (KEY_TYPE_AES == key_type) {
  ------------------
  |  |   80|    801|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (994:6): [True: 46, False: 755]
  ------------------
  995|     46|		r = aes128_encrypt_cbc(card, exdata->sk_enc, 16, iv, pad, pad_len, apdu_buf + block_size + tlv_more);
  996|     46|		LOG_TEST_RET(card->ctx, r, "aes128_encrypt_cbc failed");
  ------------------
  |  |  174|     46|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     46|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     46|	int _ret = (r); \
  |  |  |  |  168|     46|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 46]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|     46|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 46]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  997|    755|	} else {
  998|    755|		r = des3_encrypt_cbc(card, exdata->sk_enc, 16, iv, pad, pad_len, apdu_buf + block_size + tlv_more);
  999|    755|		LOG_TEST_RET(card->ctx, r, "des3_encrypt_cbc failed");
  ------------------
  |  |  174|    755|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    755|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    755|	int _ret = (r); \
  |  |  |  |  168|    755|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 755]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|    755|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 755]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1000|    755|	}
 1001|       |
 1002|    801|	memcpy(data_tlv + tlv_more, apdu_buf + block_size + tlv_more, pad_len);
 1003|    801|	*data_tlv_len = tlv_more + pad_len;
 1004|    801|	return 0;
 1005|    801|}
card-epass2003.c:construct_le_tlv:
 1012|    804|{
 1013|    804|	size_t block_size = (KEY_TYPE_AES == key_type ? 16 : 8);
  ------------------
  |  |   80|    804|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (1013:23): [True: 50, False: 754]
  ------------------
 1014|       |
 1015|    804|	*(apdu_buf + block_size + data_tlv_len) = 0x97;
 1016|    804|	if (apdu->le > 0x7F) {
  ------------------
  |  Branch (1016:6): [True: 23, False: 781]
  ------------------
 1017|       |		/* Le' > 0x7E, use extended APDU */
 1018|     23|		*(apdu_buf + block_size + data_tlv_len + 1) = 2;
 1019|     23|		*(apdu_buf + block_size + data_tlv_len + 2) = (unsigned char)(apdu->le / 0x100);
 1020|     23|		*(apdu_buf + block_size + data_tlv_len + 3) = (unsigned char)(apdu->le % 0x100);
 1021|     23|		memcpy(le_tlv, apdu_buf + block_size + data_tlv_len, 4);
 1022|     23|		*le_tlv_len = 4;
 1023|    781|	} else {
 1024|    781|		*(apdu_buf + block_size + data_tlv_len + 1) = 1;
 1025|    781|		*(apdu_buf + block_size + data_tlv_len + 2) = (unsigned char)apdu->le;
 1026|    781|		memcpy(le_tlv, apdu_buf + block_size + data_tlv_len, 3);
 1027|    781|		*le_tlv_len = 3;
 1028|    781|	}
 1029|    804|	return 0;
 1030|    804|}
card-epass2003.c:des_encrypt_cbc:
  588|  1.54k|{
  589|  1.54k|	EVP_CIPHER *alg = sc_evp_cipher(card->ctx, "DES-CBC");
  590|  1.54k|	int r;
  591|       |
  592|  1.54k|	r = openssl_enc(alg, key, iv, input, length, output);
  593|  1.54k|	sc_evp_cipher_free(alg);
  594|  1.54k|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|  1.54k|#define SC_SUCCESS				0
  ------------------
  |  Branch (594:6): [True: 0, False: 1.54k]
  ------------------
  595|      0|		sc_log_openssl(card->ctx);
  ------------------
  |  |   72|      0|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  596|  1.54k|	return r;
  597|  1.54k|}
card-epass2003.c:des_decrypt_cbc:
  603|    771|{
  604|    771|	EVP_CIPHER *alg = sc_evp_cipher(card->ctx, "DES-CBC");
  605|    771|	int r;
  606|       |
  607|    771|	r = openssl_dec(alg, key, iv, input, length, output);
  608|    771|	sc_evp_cipher_free(alg);
  609|    771|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|    771|#define SC_SUCCESS				0
  ------------------
  |  Branch (609:6): [True: 0, False: 771]
  ------------------
  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|    771|	return r;
  612|    771|}
card-epass2003.c:openssl_dec:
  313|    771|{
  314|    771|	int r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|    771|#define SC_ERROR_INTERNAL			-1400
  ------------------
  315|    771|	EVP_CIPHER_CTX * ctx = NULL;
  316|    771|	int outl = 0;
  317|    771|	int outl_tmp = 0;
  318|    771|	unsigned char iv_tmp[EVP_MAX_IV_LENGTH] = {0};
  319|       |
  320|    771|	memcpy(iv_tmp, iv, EVP_MAX_IV_LENGTH);
  321|    771|	ctx = EVP_CIPHER_CTX_new();
  322|    771|	if (ctx == NULL)
  ------------------
  |  Branch (322:6): [True: 0, False: 771]
  ------------------
  323|      0|		goto out;
  324|       |
  325|    771|	if (!EVP_DecryptInit_ex(ctx, cipher, NULL, key, iv_tmp) ||
  ------------------
  |  Branch (325:6): [True: 0, False: 771]
  ------------------
  326|    771|			!EVP_CIPHER_CTX_set_padding(ctx, 0))
  ------------------
  |  Branch (326:4): [True: 0, False: 771]
  ------------------
  327|      0|		goto out;
  328|       |
  329|    771|	if (!EVP_DecryptUpdate(ctx, output, &outl, input, (int)length))
  ------------------
  |  Branch (329:6): [True: 0, False: 771]
  ------------------
  330|      0|		goto out;
  331|       |
  332|    771|	if (!EVP_DecryptFinal_ex(ctx, output + outl, &outl_tmp))
  ------------------
  |  Branch (332:6): [True: 0, False: 771]
  ------------------
  333|      0|		goto out;
  334|       |
  335|    771|	r = SC_SUCCESS;
  ------------------
  |  |   28|    771|#define SC_SUCCESS				0
  ------------------
  336|    771|out:
  337|    771|	EVP_CIPHER_CTX_free(ctx);
  338|    771|	return r;
  339|    771|}
card-epass2003.c:construct_mac_tlv:
 1037|    808|{
 1038|    808|	size_t block_size = (KEY_TYPE_AES == key_type ? 16 : 8);
  ------------------
  |  |   80|    808|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (1038:23): [True: 50, False: 758]
  ------------------
 1039|    808|	unsigned char mac[4096] = {0};
 1040|    808|	size_t mac_len;
 1041|    808|	unsigned char icv[16] = {0};
 1042|    808|	int r ;
 1043|    808|	int i = (KEY_TYPE_AES == key_type ? 15 : 7);
  ------------------
  |  |   80|    808|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (1043:11): [True: 50, False: 758]
  ------------------
 1044|    808|	epass2003_exdata *exdata = NULL;
 1045|       |
 1046|    808|	if (!card->drv_data)
  ------------------
  |  Branch (1046:6): [True: 0, False: 808]
  ------------------
 1047|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1048|       |
 1049|    808|	exdata = (epass2003_exdata *)card->drv_data;
 1050|       |
 1051|    808|	if (data_tlv_len + le_tlv_len + block_size + 1 > sizeof(mac)) {
  ------------------
  |  Branch (1051:6): [True: 0, False: 808]
  ------------------
 1052|      0|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
 1053|      0|	}
 1054|       |
 1055|    808|	if (0 == data_tlv_len && 0 == le_tlv_len) {
  ------------------
  |  Branch (1055:6): [True: 7, False: 801]
  |  Branch (1055:27): [True: 0, False: 7]
  ------------------
 1056|      0|		mac_len = block_size;
 1057|    808|	} else {
 1058|       |		/* padding */
 1059|    808|		*(apdu_buf + block_size + data_tlv_len + le_tlv_len) = 0x80;
 1060|    808|		if ((data_tlv_len + le_tlv_len + 1) % block_size) {
  ------------------
  |  Branch (1060:7): [True: 795, False: 13]
  ------------------
 1061|    795|			mac_len = (((data_tlv_len + le_tlv_len + 1) / block_size) +
 1062|    795|					1) * block_size + block_size;
 1063|    795|		} else {
 1064|     13|			mac_len = data_tlv_len + le_tlv_len + 1 + block_size;
 1065|     13|		}
 1066|    808|		memset((apdu_buf + block_size + data_tlv_len + le_tlv_len + 1),
 1067|    808|		       0, (mac_len - (data_tlv_len + le_tlv_len + 1)));
 1068|    808|	}
 1069|       |
 1070|       |	/* increase icv */
 1071|    808|	for (; i >= 0; i--) {
  ------------------
  |  Branch (1071:9): [True: 808, False: 0]
  ------------------
 1072|    808|		if (exdata->icv_mac[i] == 0xff) {
  ------------------
  |  Branch (1072:7): [True: 0, False: 808]
  ------------------
 1073|      0|			exdata->icv_mac[i] = 0;
 1074|    808|		} else {
 1075|    808|			exdata->icv_mac[i]++;
 1076|    808|			break;
 1077|    808|		}
 1078|    808|	}
 1079|       |
 1080|       |	/* calculate MAC */
 1081|    808|	memset(icv, 0, sizeof(icv));
 1082|    808|	memcpy(icv, exdata->icv_mac, 16);
 1083|    808|	if (KEY_TYPE_AES == key_type) {
  ------------------
  |  |   80|    808|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (1083:6): [True: 50, False: 758]
  ------------------
 1084|     50|		if (exdata->bFipsCertification) {
  ------------------
  |  Branch (1084:7): [True: 2, False: 48]
  ------------------
 1085|     34|			for (int i = 0; i < 16; i++) {
  ------------------
  |  Branch (1085:20): [True: 32, False: 2]
  ------------------
 1086|     32|				apdu_buf[i] = apdu_buf[i] ^ icv[i];
 1087|     32|			}
 1088|      2|			r = aes128_encrypt_cmac(card, exdata->sk_mac, 128, apdu_buf, data_tlv_len + le_tlv_len + block_size, mac);
 1089|      2|			LOG_TEST_RET(card->ctx, r, "aes128_encrypt_cmac 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1090|      2|			memcpy(mac_tlv + 2, &mac[0 /*ulmacLen-16*/], 8);
 1091|     10|			for (int j = 0; j < 4; j++) {
  ------------------
  |  Branch (1091:20): [True: 8, False: 2]
  ------------------
 1092|      8|				apdu_buf[j] = apdu_buf[j] ^ icv[j];
 1093|      8|			}
 1094|     48|		} else {
 1095|     48|			r = aes128_encrypt_cbc(card, exdata->sk_mac, 16, icv, apdu_buf, mac_len, mac);
 1096|     48|			LOG_TEST_RET(card->ctx, r, "aes128_encrypt_cbc failed");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1097|     48|			memcpy(mac_tlv + 2, &mac[mac_len - 16], 8);
 1098|     48|		}
 1099|    758|	} else {
 1100|    758|		unsigned char iv[EVP_MAX_IV_LENGTH] = {0};
 1101|    758|		unsigned char tmp[8] = {0};
 1102|    758|		r = des_encrypt_cbc(card, exdata->sk_mac, 8, icv, apdu_buf, mac_len, mac);
 1103|    758|		LOG_TEST_RET(card->ctx, r, "des_encrypt_cbc 1 failed");
  ------------------
  |  |  174|    758|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    758|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    758|	int _ret = (r); \
  |  |  |  |  168|    758|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 758]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|    758|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 758]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1104|    758|		r = des_decrypt_cbc(card, &exdata->sk_mac[8], 8, iv, &mac[mac_len - 8], 8, tmp);
 1105|    758|		LOG_TEST_RET(card->ctx, r, "des_decrypt_cbc failed");
  ------------------
  |  |  174|    758|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    758|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    758|	int _ret = (r); \
  |  |  |  |  168|    758|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 758]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|    758|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 758]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1106|    758|		memset(iv, 0x00, sizeof iv);
 1107|    758|		r = des_encrypt_cbc(card, exdata->sk_mac, 8, iv, tmp, 8, mac_tlv + 2);
 1108|    758|		LOG_TEST_RET(card->ctx, r, "des_encrypt_cbc 2 failed");
  ------------------
  |  |  174|    758|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    758|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    758|	int _ret = (r); \
  |  |  |  |  168|    758|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 758]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|    758|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 758]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1109|    758|	}
 1110|       |
 1111|    808|	*mac_tlv_len = 2 + 8;
 1112|    808|	return 0;
 1113|    808|}
card-epass2003.c:epass2003_sm_free_wrapped_apdu:
 1552|  1.60k|{
 1553|  1.60k|	struct sc_context *ctx = card->ctx;
 1554|  1.60k|	int rv = SC_SUCCESS;
  ------------------
  |  |   28|  1.60k|#define SC_SUCCESS				0
  ------------------
 1555|       |
 1556|  1.60k|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1557|  1.60k|	if (!sm_apdu)
  ------------------
  |  Branch (1557:6): [True: 0, False: 1.60k]
  ------------------
 1558|  1.60k|		LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1559|  1.60k|	if (!(*sm_apdu))
  ------------------
  |  Branch (1559:6): [True: 0, False: 1.60k]
  ------------------
 1560|  1.60k|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1561|       |
 1562|       |
 1563|  1.60k|	if (plain)
  ------------------
  |  Branch (1563:6): [True: 1.60k, False: 0]
  ------------------
 1564|  1.60k|		rv = epass2003_sm_unwrap_apdu(card, *sm_apdu, plain);
 1565|       |
 1566|  1.60k|	if ((*sm_apdu)->data) {
  ------------------
  |  Branch (1566:6): [True: 1.60k, False: 0]
  ------------------
 1567|  1.60k|		unsigned char * p = (unsigned char *)((*sm_apdu)->data);
 1568|  1.60k|		free(p);
 1569|  1.60k|	}
 1570|  1.60k|	if ((*sm_apdu)->resp) {
  ------------------
  |  Branch (1570:6): [True: 1.60k, False: 0]
  ------------------
 1571|  1.60k|		free((*sm_apdu)->resp);
 1572|  1.60k|	}
 1573|       |
 1574|  1.60k|	free(*sm_apdu);
 1575|  1.60k|	*sm_apdu = NULL;
 1576|       |
 1577|  1.60k|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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|    807|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 807, False: 799]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1578|  1.60k|}
card-epass2003.c:epass2003_sm_unwrap_apdu:
 1509|  1.60k|{
 1510|  1.60k|	int r;
 1511|  1.60k|	size_t len = 0;
 1512|  1.60k|	epass2003_exdata *exdata = NULL;
 1513|       |
 1514|  1.60k|	if (!card->drv_data)
  ------------------
  |  Branch (1514:6): [True: 0, False: 1.60k]
  ------------------
 1515|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1516|       |
 1517|  1.60k|	exdata = (epass2003_exdata *)card->drv_data;
 1518|       |
 1519|  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1520|       |
 1521|       |	/* verify MAC, and check if SW1,2 match SW1,2 encapsulated in SM */
 1522|  1.60k|	if (exdata->sm) {
  ------------------
  |  Branch (1522:6): [True: 808, False: 798]
  ------------------
 1523|    808|		if (epass2003_check_response_mac_and_sw(card, sm)) {
  ------------------
  |  Branch (1523:7): [True: 807, False: 1]
  ------------------
 1524|    807|			sc_log(card->ctx, "MAC or SW incorrect");
  ------------------
  |  |   71|    807|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1525|    807|			return SC_ERROR_CARD_CMD_FAILED;
  ------------------
  |  |   50|    807|#define SC_ERROR_CARD_CMD_FAILED		-1200
  ------------------
 1526|    807|		}
 1527|    808|	}
 1528|    799|	r = sc_check_sw(card, sm->sw1, sm->sw2);
 1529|    799|	if (r == SC_SUCCESS) {
  ------------------
  |  |   28|    799|#define SC_SUCCESS				0
  ------------------
  |  Branch (1529:6): [True: 444, False: 355]
  ------------------
 1530|    444|		if (exdata->sm) {
  ------------------
  |  Branch (1530:7): [True: 0, False: 444]
  ------------------
 1531|      0|			len = plain->resplen;
 1532|      0|			if (0 != decrypt_response(card, sm->resp, sm->resplen, plain->resp, &len))
  ------------------
  |  Branch (1532:8): [True: 0, False: 0]
  ------------------
 1533|      0|				return SC_ERROR_CARD_CMD_FAILED;
  ------------------
  |  |   50|      0|#define SC_ERROR_CARD_CMD_FAILED		-1200
  ------------------
 1534|    444|		} else {
 1535|    444|			memcpy(plain->resp, sm->resp, sm->resplen);
 1536|    444|			len = sm->resplen;
 1537|    444|		}
 1538|    444|	}
 1539|       |
 1540|    799|	plain->resplen = len;
 1541|    799|	plain->sw1 = sm->sw1;
 1542|    799|	plain->sw2 = sm->sw2;
 1543|       |
 1544|    799|	sc_log(card->ctx, "unwrapped APDU: resplen %zu, SW %02X%02X", plain->resplen, plain->sw1, plain->sw2);
  ------------------
  |  |   71|    799|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1545|    799|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    799|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    799|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    799|	int _ret = r; \
  |  |  |  |  155|    799|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 799, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    799|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 799]
  |  |  |  |  ------------------
  |  |  |  |  157|    799|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    799|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    799|	return _ret; \
  |  |  |  |  163|    799|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1546|    799|}
card-epass2003.c:epass2003_check_response_mac_and_sw:
 1346|    808|{
 1347|    808|	unsigned char iv[16];
 1348|    808|	unsigned char *data = NULL, *mac = NULL;
 1349|    808|	size_t blocksize, mac_len;
 1350|    808|	int ret = -1;
 1351|    808|	size_t taglen;
 1352|    808|	const u8 *tag;
 1353|    808|	epass2003_exdata *exdata;
 1354|    808|	unsigned char *in = sm->resp;
 1355|    808|	unsigned char *alt_in;
 1356|    808|	size_t inlen = sm->resplen;
 1357|    808|	size_t len_correction;
 1358|       |
 1359|       |	/* card/ctx/drv_data is already checked by caller */
 1360|    808|	exdata = (epass2003_exdata *)card->drv_data;
 1361|       |
 1362|       |	/* The SM must contain at least TLV encoded SW and MAC fields. */
 1363|    808|	if (inlen < 14 )
  ------------------
  |  Branch (1363:6): [True: 646, False: 162]
  ------------------
 1364|    646|		return ret;
 1365|       |
 1366|       |	/* compare BER-TLV encoded SW (TAG 0x99) and raw SW */
 1367|    162|	alt_in = in;
 1368|    162|	tag = sc_asn1_find_tag(card->ctx, alt_in, inlen, 0x99, &taglen);
 1369|    162|	if (tag == NULL || taglen != 2) {
  ------------------
  |  Branch (1369:6): [True: 141, False: 21]
  |  Branch (1369:21): [True: 3, False: 18]
  ------------------
 1370|       |		/*
 1371|       |		 * It seems that the EPASS2003 firmware has some problem with BER-TLV encoding.
 1372|       |		 * Instead of (correct) TLV 87 81 81 [01 .. ..] incorrect TLV 87 81 [01 .. ..]
 1373|       |		 * is returned. There seems to be some proprietary fix for the faulty encoding
 1374|       |		 * in the decrypt_response() function, similar fix here:
 1375|       |		 */
 1376|    144|		if (0x01 == in[2] && 0x82 != in[1]) {
  ------------------
  |  Branch (1376:7): [True: 53, False: 91]
  |  Branch (1376:24): [True: 42, False: 11]
  ------------------
 1377|     42|			sc_log(card->ctx, "Workaround, wrong BER-TLV ?");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1378|     42|			len_correction = in[1] + 2;
 1379|     42|			if (inlen < len_correction)
  ------------------
  |  Branch (1379:8): [True: 16, False: 26]
  ------------------
 1380|     16|				return ret;
 1381|     26|			inlen -= len_correction;
 1382|     26|			alt_in += len_correction;
 1383|     26|			tag = sc_asn1_find_tag(card->ctx, alt_in, inlen, 0x99, &taglen);
 1384|     26|			if (tag == NULL || taglen != 2)
  ------------------
  |  Branch (1384:8): [True: 17, False: 9]
  |  Branch (1384:23): [True: 6, False: 3]
  ------------------
 1385|     23|				return ret;
 1386|    102|		} else {
 1387|    102|			return ret;
 1388|    102|		}
 1389|    144|	}
 1390|     21|	if (sm->sw1 != tag[0] || sm->sw2 != tag[1])
  ------------------
  |  Branch (1390:6): [True: 2, False: 19]
  |  Branch (1390:27): [True: 4, False: 15]
  ------------------
 1391|      6|		return ret;
 1392|       |
 1393|       |	/* no documentation/real hardware to test, the response is accepted without MAC check */
 1394|     15|	if (exdata->bFipsCertification) {
  ------------------
  |  Branch (1394:6): [True: 0, False: 15]
  ------------------
 1395|      0|		sc_log(card->ctx, "Warning, MAC is not checked");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1396|      0|		return 0;
 1397|      0|	}
 1398|     15|	tag = sc_asn1_find_tag(card->ctx, alt_in, inlen, 0x8e, &taglen);
 1399|     15|	if (tag == NULL || taglen != 8)
  ------------------
  |  Branch (1399:6): [True: 1, False: 14]
  |  Branch (1399:21): [True: 1, False: 13]
  ------------------
 1400|      2|		return ret;
 1401|       |
 1402|     13|	if (KEY_TYPE_AES == exdata->smtype)
  ------------------
  |  |   80|     13|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (1402:6): [True: 0, False: 13]
  ------------------
 1403|      0|		blocksize = 16;
 1404|     13|	else
 1405|     13|		blocksize = 8;
 1406|       |
 1407|     13|	mac_len = tag - in - 2;
 1408|     13|	if (NULL == (data = calloc(1, mac_len + blocksize)))
  ------------------
  |  Branch (1408:6): [True: 0, False: 13]
  ------------------
 1409|      0|		goto end;
 1410|     13|	if (NULL == (mac = malloc(mac_len + blocksize)))
  ------------------
  |  Branch (1410:6): [True: 0, False: 13]
  ------------------
 1411|      0|		goto end;
 1412|       |
 1413|       |	/* copy response to buffer and append padding */
 1414|     13|	memcpy(data, in, mac_len);
 1415|     13|	data[mac_len++] = 0x80;
 1416|       |
 1417|     13|	if (mac_len % blocksize)
  ------------------
  |  Branch (1417:6): [True: 11, False: 2]
  ------------------
 1418|     11|		mac_len += (blocksize - (mac_len % blocksize));
 1419|       |
 1420|       |	/* calculate MAC */
 1421|     13|	memcpy(iv, exdata->icv_mac, blocksize);
 1422|       |
 1423|     13|	if (KEY_TYPE_AES == exdata->smtype) {
  ------------------
  |  |   80|     13|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (1423:6): [True: 0, False: 13]
  ------------------
 1424|      0|		if (aes128_encrypt_cbc(card, exdata->sk_mac, 16, iv, data, mac_len, mac))
  ------------------
  |  Branch (1424:7): [True: 0, False: 0]
  ------------------
 1425|      0|			goto end;
 1426|     13|	} else {
 1427|     13|		uint8_t tmp[8];
 1428|     13|		uint8_t iv0[EVP_MAX_IV_LENGTH];
 1429|     13|		if (des_encrypt_cbc(card, exdata->sk_mac, 8, iv, data, mac_len, mac))
  ------------------
  |  Branch (1429:7): [True: 0, False: 13]
  ------------------
 1430|      0|			goto end;
 1431|     13|		memset(iv0, 0, EVP_MAX_IV_LENGTH);
 1432|     13|		if (des_decrypt_cbc(card, &exdata->sk_mac[8], 8, iv0, &mac[mac_len - 8], 8, tmp))
  ------------------
  |  Branch (1432:7): [True: 0, False: 13]
  ------------------
 1433|      0|			goto end;
 1434|     13|		memset(iv0, 0, EVP_MAX_IV_LENGTH);
 1435|     13|		if (des_encrypt_cbc(card, exdata->sk_mac, 8, iv0, tmp, 8, &mac[mac_len - 8]))
  ------------------
  |  Branch (1435:7): [True: 0, False: 13]
  ------------------
 1436|      0|			goto end;
 1437|     13|	}
 1438|       |	/* compare MAC */
 1439|     13|	if (!memcmp(tag, mac + mac_len - blocksize, 8))
  ------------------
  |  Branch (1439:6): [True: 1, False: 12]
  ------------------
 1440|      1|		ret = 0;
 1441|     13|end:
 1442|     13|	if (data)
  ------------------
  |  Branch (1442:6): [True: 13, False: 0]
  ------------------
 1443|     13|		free(data);
 1444|     13|	if (mac)
  ------------------
  |  Branch (1444:6): [True: 13, False: 0]
  ------------------
 1445|     13|		free(mac);
 1446|     13|	return ret;
 1447|     13|}
card-epass2003.c:epass2003_finish:
 1777|    861|{
 1778|    861|	epass2003_exdata *exdata = (epass2003_exdata *)card->drv_data;
 1779|       |
 1780|    861|	if (exdata)
  ------------------
  |  Branch (1780:6): [True: 861, False: 0]
  ------------------
 1781|    861|		free(exdata);
 1782|    861|	return SC_SUCCESS;
  ------------------
  |  |   28|    861|#define SC_SUCCESS				0
  ------------------
 1783|    861|}
card-epass2003.c:epass2003_select_file:
 2023|  6.88k|{
 2024|  6.88k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  6.88k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  6.88k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  6.88k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  6.88k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 6.88k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2025|       |
 2026|  6.88k|	switch (in_path->type) {
 2027|    496|	case SC_PATH_TYPE_FILE_ID:
  ------------------
  |  |  117|    496|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (2027:2): [True: 496, False: 6.39k]
  ------------------
 2028|    496|		if (in_path->len != 2)
  ------------------
  |  Branch (2028:7): [True: 213, False: 283]
  ------------------
 2029|    496|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|    213|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    213|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    213|	int _ret = r; \
  |  |  |  |  155|    213|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 213, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    213|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    213|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    213|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    213|	return _ret; \
  |  |  |  |  163|    213|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2030|    283|		return epass2003_select_fid(card, in_path->value[0], in_path->value[1], file_out);
 2031|  2.05k|	case SC_PATH_TYPE_DF_NAME:
  ------------------
  |  |  118|  2.05k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (2031:2): [True: 2.05k, False: 4.83k]
  ------------------
 2032|  2.05k|		return epass2003_select_aid(card, in_path, file_out);
 2033|  4.33k|	case SC_PATH_TYPE_PATH:
  ------------------
  |  |  119|  4.33k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (2033:2): [True: 4.33k, False: 2.54k]
  ------------------
 2034|  4.33k|		return epass2003_select_path(card, in_path->value, in_path->len, file_out);
 2035|      0|	default:
  ------------------
  |  Branch (2035:2): [True: 0, False: 6.88k]
  ------------------
 2036|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2037|  6.88k|	}
 2038|  6.88k|}
card-epass2003.c:epass2003_select_fid:
 1936|  5.86k|{
 1937|  5.86k|	int r;
 1938|  5.86k|	sc_file_t *file = NULL;
 1939|  5.86k|	sc_path_t path;
 1940|       |
 1941|  5.86k|	memset(&path, 0, sizeof(path));
 1942|  5.86k|	path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|  5.86k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
 1943|  5.86k|	path.value[0] = id_hi;
 1944|  5.86k|	path.value[1] = id_lo;
 1945|  5.86k|	path.len = 2;
 1946|       |
 1947|  5.86k|	r = epass2003_select_fid_(card, &path, &file);
 1948|  5.86k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  5.86k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  5.86k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  5.86k|	int _ret = (r); \
  |  |  |  |  168|  5.86k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3.54k, False: 2.31k]
  |  |  |  |  ------------------
  |  |  |  |  169|  3.54k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.54k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  3.54k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  3.54k|		return _ret; \
  |  |  |  |  172|  3.54k|	} \
  |  |  |  |  173|  5.86k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.31k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1949|       |
 1950|  2.31k|	if (file_out) {
  ------------------
  |  Branch (1950:6): [True: 789, False: 1.52k]
  ------------------
 1951|    789|		*file_out = file;
 1952|  1.52k|	} else {
 1953|  1.52k|		sc_file_free(file);
 1954|  1.52k|	}
 1955|       |
 1956|  2.31k|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|  2.31k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.31k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.31k|	int _ret = r; \
  |  |  |  |  155|  2.31k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.31k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.31k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 2.31k]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.31k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.31k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|  2.31k|	return _ret; \
  |  |  |  |  163|  2.31k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1957|  2.31k|}
card-epass2003.c:epass2003_select_fid_:
 1841|  5.86k|{
 1842|  5.86k|	struct sc_apdu apdu;
 1843|  5.86k|	u8 buf[SC_MAX_APDU_BUFFER_SIZE] = {0};
 1844|  5.86k|	u8 pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf;
 1845|  5.86k|	int r;
 1846|  5.86k|	size_t pathlen;
 1847|  5.86k|	sc_file_t *file = NULL;
 1848|       |
 1849|  5.86k|	r = epass2003_hook_path(in_path, 1);
 1850|  5.86k|	LOG_TEST_RET(card->ctx, r, "Can not hook path");
  ------------------
  |  |  174|  5.86k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  5.86k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  5.86k|	int _ret = (r); \
  |  |  |  |  168|  5.86k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 5.86k]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|  5.86k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 5.86k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1851|       |
 1852|  5.86k|	memcpy(path, in_path->value, in_path->len);
 1853|  5.86k|	pathlen = in_path->len;
 1854|       |
 1855|  5.86k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0x00, 0x00);
  ------------------
  |  |  294|  5.86k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
 1856|       |
 1857|  5.86k|	switch (in_path->type) {
 1858|  5.86k|	case SC_PATH_TYPE_FILE_ID:
  ------------------
  |  |  117|  5.86k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (1858:2): [True: 5.86k, False: 0]
  ------------------
 1859|  5.86k|		apdu.p1 = 0;
 1860|  5.86k|		if (pathlen != 2)
  ------------------
  |  Branch (1860:7): [True: 0, False: 5.86k]
  ------------------
 1861|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1862|  5.86k|		break;
 1863|  5.86k|	default:
  ------------------
  |  Branch (1863:2): [True: 0, False: 5.86k]
  ------------------
 1864|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1865|  5.86k|	}
 1866|  5.86k|	apdu.p2 = 0;		/* first record, return FCI */
 1867|  5.86k|	apdu.lc = pathlen;
 1868|  5.86k|	apdu.data = path;
 1869|  5.86k|	apdu.datalen = pathlen;
 1870|       |
 1871|  5.86k|	if (file_out != NULL) {
  ------------------
  |  Branch (1871:6): [True: 5.86k, False: 0]
  ------------------
 1872|  5.86k|		apdu.resp = buf;
 1873|  5.86k|		apdu.resplen = sizeof(buf);
 1874|  5.86k|		apdu.le = 0;
 1875|  5.86k|	} else {
 1876|      0|		apdu.cse = (apdu.lc == 0) ? SC_APDU_CASE_1 : SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  291|      0|#define SC_APDU_CASE_1			0x01
  ------------------
              		apdu.cse = (apdu.lc == 0) ? SC_APDU_CASE_1 : SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  |  Branch (1876:14): [True: 0, False: 0]
  ------------------
 1877|      0|	}
 1878|       |
 1879|  5.86k|	if (path[0] == 0x29) {	/* TODO:0x29 accords with FID prefix in profile  */
  ------------------
  |  Branch (1879:6): [True: 557, False: 5.30k]
  ------------------
 1880|       |		/* Not allowed to select private key file, so fake fci. */
 1881|       |		/* 62 16 82 02 11 00 83 02 29 00 85 02 08 00 86 08 FF 90 90 90 FF FF FF FF */
 1882|    557|		apdu.resplen = 0x18;
 1883|    557|		memcpy(apdu.resp,
 1884|    557|		       "\x6f\x16\x82\x02\x11\x00\x83\x02\x29\x00\x85\x02\x08\x00\x86\x08\xff\x90\x90\x90\xff\xff\xff\xff",
 1885|    557|		       apdu.resplen);
 1886|    557|		apdu.resp[9] = path[1];
 1887|    557|		apdu.sw1 = 0x90;
 1888|    557|		apdu.sw2 = 0x00;
 1889|    557|	}
 1890|  5.30k|	else {
 1891|  5.30k|		r = sc_transmit_apdu_t(card, &apdu);
 1892|  5.30k|		LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  5.30k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  5.30k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  5.30k|	int _ret = (r); \
  |  |  |  |  168|  5.30k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 801, False: 4.50k]
  |  |  |  |  ------------------
  |  |  |  |  169|    801|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    801|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    801|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    801|		return _ret; \
  |  |  |  |  172|    801|	} \
  |  |  |  |  173|  5.30k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4.50k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1893|  5.30k|	}
 1894|       |
 1895|  5.06k|	if (file_out == NULL) {
  ------------------
  |  Branch (1895:6): [True: 0, False: 5.06k]
  ------------------
 1896|      0|		if (apdu.sw1 == 0x61)
  ------------------
  |  Branch (1896:7): [True: 0, False: 0]
  ------------------
 1897|      0|			LOG_FUNC_RETURN(card->ctx, 0);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1898|      0|		LOG_FUNC_RETURN(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1899|      0|	}
 1900|       |
 1901|  5.06k|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1902|  5.06k|	if (r)
  ------------------
  |  Branch (1902:6): [True: 2.37k, False: 2.68k]
  ------------------
 1903|  5.06k|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  2.37k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.37k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.37k|	int _ret = r; \
  |  |  |  |  155|  2.37k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.37k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.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|  2.37k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.37k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.37k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.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|  2.37k|	return _ret; \
  |  |  |  |  163|  2.37k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1904|  2.68k|	if (apdu.resplen < 2)
  ------------------
  |  Branch (1904:6): [True: 305, False: 2.38k]
  ------------------
 1905|  2.68k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|    305|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    305|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    305|	int _ret = r; \
  |  |  |  |  155|    305|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 305, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    305|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    305|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 305, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    305|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    305|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    305|	return _ret; \
  |  |  |  |  163|    305|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1906|       |
 1907|  2.38k|	switch (apdu.resp[0]) {
 1908|  2.31k|	case 0x6F:
  ------------------
  |  Branch (1908:2): [True: 2.31k, False: 66]
  ------------------
 1909|  2.31k|		file = sc_file_new();
 1910|  2.31k|		if (file == NULL)
  ------------------
  |  Branch (1910:7): [True: 0, False: 2.31k]
  ------------------
 1911|  2.31k|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1912|  2.31k|		file->path = *in_path;
 1913|  2.31k|		if (card->ops->process_fci == NULL) {
  ------------------
  |  Branch (1913:7): [True: 0, False: 2.31k]
  ------------------
 1914|      0|			sc_file_free(file);
 1915|      0|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1916|      0|		}
 1917|       |
 1918|  2.31k|		if ((size_t) apdu.resp[1] + 2 <= apdu.resplen)
  ------------------
  |  Branch (1918:7): [True: 2.18k, False: 137]
  ------------------
 1919|  2.18k|			card->ops->process_fci(card, file, apdu.resp + 2, apdu.resp[1]);
 1920|  2.31k|		epass2003_hook_file(file, 0);
 1921|  2.31k|		*file_out = file;
 1922|  2.31k|		break;
 1923|     29|	case 0x00:		/* proprietary coding */
  ------------------
  |  Branch (1923:2): [True: 29, False: 2.35k]
  ------------------
 1924|     29|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|     29|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     29|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     29|	int _ret = r; \
  |  |  |  |  155|     29|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 29, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     29|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     29|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 29, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     29|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     29|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     29|	return _ret; \
  |  |  |  |  163|     29|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1925|      0|		break;
 1926|     37|	default:
  ------------------
  |  Branch (1926:2): [True: 37, False: 2.34k]
  ------------------
 1927|     37|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|     37|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     37|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     37|	int _ret = r; \
  |  |  |  |  155|     37|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 37, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     37|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     37|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 37, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     37|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     37|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     37|	return _ret; \
  |  |  |  |  163|     37|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1928|  2.38k|	}
 1929|  2.31k|	return 0;
 1930|  2.38k|}
card-epass2003.c:epass2003_hook_path:
 1789|  8.78k|{
 1790|  8.78k|	u8 fid_h = 0;
 1791|  8.78k|	u8 fid_l = 0;
 1792|       |
 1793|  8.78k|	if (!path || path->len < 2)
  ------------------
  |  Branch (1793:6): [True: 0, False: 8.78k]
  |  Branch (1793:15): [True: 81, False: 8.70k]
  ------------------
 1794|     81|		return -1;
 1795|  8.70k|	fid_h = path->value[path->len - 2];
 1796|  8.70k|	fid_l = path->value[path->len - 1];
 1797|       |
 1798|  8.70k|	switch (fid_h) {
 1799|  1.28k|	case 0x29:
  ------------------
  |  Branch (1799:2): [True: 1.28k, False: 7.41k]
  ------------------
 1800|  1.44k|	case 0x30:
  ------------------
  |  Branch (1800:2): [True: 160, False: 8.54k]
  ------------------
 1801|  1.69k|	case 0x31:
  ------------------
  |  Branch (1801:2): [True: 243, False: 8.46k]
  ------------------
 1802|  1.82k|	case 0x32:
  ------------------
  |  Branch (1802:2): [True: 132, False: 8.57k]
  ------------------
 1803|  1.89k|	case 0x33:
  ------------------
  |  Branch (1803:2): [True: 74, False: 8.63k]
  ------------------
 1804|  1.99k|	case 0x34:
  ------------------
  |  Branch (1804:2): [True: 93, False: 8.61k]
  ------------------
 1805|  1.99k|		if (inc)
  ------------------
  |  Branch (1805:7): [True: 1.07k, False: 916]
  ------------------
 1806|  1.07k|			fid_l = fid_l * FID_STEP;
  ------------------
  |  |  742|  1.07k|#define FID_STEP 0x20
  ------------------
 1807|    916|		else
 1808|    916|			fid_l = fid_l / FID_STEP;
  ------------------
  |  |  742|    916|#define FID_STEP 0x20
  ------------------
 1809|  1.99k|		path->value[path->len - 1] = fid_l;
 1810|  1.99k|		return 1;
 1811|  6.71k|	default:
  ------------------
  |  Branch (1811:2): [True: 6.71k, False: 1.99k]
  ------------------
 1812|  6.71k|		break;
 1813|  8.70k|	}
 1814|  6.71k|	return 0;
 1815|  8.70k|}
card-epass2003.c:epass2003_hook_file:
 1820|  2.81k|{
 1821|  2.81k|	int fidl = file->id & 0xff;
 1822|  2.81k|	int fidh = file->id & 0xff00;
 1823|  2.81k|	int rv = 0;
 1824|       |
 1825|  2.81k|	rv = epass2003_hook_path(&file->path, inc);
 1826|       |
 1827|  2.81k|	if (rv > 0) {
  ------------------
  |  Branch (1827:6): [True: 1.02k, False: 1.79k]
  ------------------
 1828|  1.02k|		if (inc)
  ------------------
  |  Branch (1828:7): [True: 105, False: 916]
  ------------------
 1829|    105|			file->id = fidh + fidl * FID_STEP;
  ------------------
  |  |  742|    105|#define FID_STEP 0x20
  ------------------
 1830|    916|		else
 1831|    916|			file->id = fidh + fidl / FID_STEP;
  ------------------
  |  |  742|    916|#define FID_STEP 0x20
  ------------------
 1832|  1.02k|	}
 1833|  2.81k|	if (rv < 0)
  ------------------
  |  Branch (1833:6): [True: 81, False: 2.73k]
  ------------------
 1834|     81|		return rv;
 1835|  2.73k|	return SC_SUCCESS;
  ------------------
  |  |   28|  2.73k|#define SC_SUCCESS				0
  ------------------
 1836|  2.81k|}
card-epass2003.c:epass2003_select_aid:
 1962|  2.05k|{
 1963|  2.05k|	int r = 0;
 1964|       |
 1965|  2.05k|	r = iso_ops->select_file(card, in_path, file_out);
 1966|  2.05k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  2.05k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.05k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.05k|	int _ret = (r); \
  |  |  |  |  168|  2.05k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.38k, False: 666]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.38k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  1.38k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.38k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.38k|		return _ret; \
  |  |  |  |  172|  1.38k|	} \
  |  |  |  |  173|  2.05k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 666]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1967|       |
 1968|    666|	if (file_out) {
  ------------------
  |  Branch (1968:6): [True: 98, False: 568]
  ------------------
 1969|     98|		sc_file_t *file = *file_out;
 1970|       |
 1971|     98|		file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|     98|#define SC_FILE_TYPE_DF			0x04
  ------------------
 1972|     98|		file->ef_structure = SC_FILE_EF_UNKNOWN;
  ------------------
  |  |  220|     98|#define SC_FILE_EF_UNKNOWN		0x00
  ------------------
 1973|     98|		file->path.len = 0;
 1974|     98|		file->size = 0;
 1975|       |		/* AID */
 1976|     98|		memcpy(file->name, in_path->value, in_path->len);
 1977|     98|		file->namelen = in_path->len;
 1978|     98|		file->id = 0x0000;
 1979|     98|	}
 1980|       |
 1981|    666|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    666|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    666|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    666|	int _ret = r; \
  |  |  |  |  155|    666|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 666, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    666|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 666]
  |  |  |  |  ------------------
  |  |  |  |  157|    666|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    666|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    666|	return _ret; \
  |  |  |  |  163|    666|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1982|    666|}
card-epass2003.c:epass2003_select_path:
 1988|  4.33k|{
 1989|  4.33k|	u8 n_pathbuf[SC_MAX_PATH_SIZE];
 1990|  4.33k|	const u8 *path = pathbuf;
 1991|  4.33k|	size_t pathlen = len;
 1992|  4.33k|	unsigned int i;
 1993|  4.33k|	int r;
 1994|       |
 1995|  4.33k|	if (pathlen % 2 != 0 || pathlen > 6 || pathlen <= 0)
  ------------------
  |  Branch (1995:6): [True: 0, False: 4.33k]
  |  Branch (1995:26): [True: 12, False: 4.32k]
  |  Branch (1995:41): [True: 6, False: 4.32k]
  ------------------
 1996|  4.33k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1997|       |
 1998|       |	/* if pathlen == 6 then the first FID must be MF (== 3F00) */
 1999|  4.32k|	if (pathlen == 6 && (path[0] != 0x3f || path[1] != 0x00))
  ------------------
  |  Branch (1999:6): [True: 1.02k, False: 3.29k]
  |  Branch (1999:23): [True: 53, False: 976]
  |  Branch (1999:42): [True: 13, False: 963]
  ------------------
 2000|  4.32k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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|     66|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 66, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2001|       |
 2002|       |	/* unify path (the first FID should be MF) */
 2003|  4.25k|	if (path[0] != 0x3f || path[1] != 0x00) {
  ------------------
  |  Branch (2003:6): [True: 607, False: 3.64k]
  |  Branch (2003:25): [True: 33, False: 3.61k]
  ------------------
 2004|    640|		n_pathbuf[0] = 0x3f;
 2005|    640|		n_pathbuf[1] = 0x00;
 2006|    640|		memcpy(n_pathbuf + 2, path, pathlen);
 2007|    640|		path = n_pathbuf;
 2008|    640|		pathlen += 2;
 2009|    640|	}
 2010|       |
 2011|  5.57k|	for (i = 0; i < pathlen - 2; i += 2) {
  ------------------
  |  Branch (2011:14): [True: 4.37k, False: 1.20k]
  ------------------
 2012|  4.37k|		r = epass2003_select_fid(card, path[i], path[i + 1], NULL);
 2013|  4.37k|		LOG_TEST_RET(card->ctx, r, "SELECT FILE (DF-ID) failed");
  ------------------
  |  |  174|  4.37k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  4.37k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  4.37k|	int _ret = (r); \
  |  |  |  |  168|  4.37k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3.05k, False: 1.32k]
  |  |  |  |  ------------------
  |  |  |  |  169|  3.05k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  3.05k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  3.05k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  3.05k|		return _ret; \
  |  |  |  |  172|  3.05k|	} \
  |  |  |  |  173|  4.37k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.32k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2014|  4.37k|	}
 2015|       |
 2016|  1.20k|	return epass2003_select_fid(card, path[pathlen - 2], path[pathlen - 1], file_out);
 2017|  4.25k|}
card-epass2003.c:hash_data:
 2731|     31|{
 2732|       |
 2733|     31|	if ((NULL == data) || (NULL == hash))
  ------------------
  |  Branch (2733:6): [True: 0, False: 31]
  |  Branch (2733:24): [True: 0, False: 31]
  ------------------
 2734|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 2735|       |
 2736|     31|	if (mechanismType & SC_ALGORITHM_ECDSA_HASH_SHA1) {
  ------------------
  |  |  176|     31|#define SC_ALGORITHM_ECDSA_HASH_SHA1		SC_ALGORITHM_RSA_HASH_SHA1
  |  |  ------------------
  |  |  |  |  134|     31|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  ------------------
  ------------------
  |  Branch (2736:6): [True: 31, False: 0]
  ------------------
 2737|     31|		unsigned char data_hash[24] = {0};
 2738|     31|		size_t len = 0;
 2739|       |
 2740|     31|		sha1_digest(card, data, datalen, data_hash);
 2741|     31|		len = REVERSE_ORDER4(datalen);
  ------------------
  |  |  117|     31|#define REVERSE_ORDER4(x)	(			  \
  |  |  118|     31|		((unsigned long)x & 0xFF000000)>> 24	| \
  |  |  119|     31|		((unsigned long)x & 0x00FF0000)>>  8 	| \
  |  |  120|     31|		((unsigned long)x & 0x0000FF00)<<  8	| \
  |  |  121|     31|		((unsigned long)x & 0x000000FF)<< 24)
  ------------------
 2742|     31|		memcpy(&data_hash[20], &len, 4);
 2743|     31|		memcpy(hash, data_hash, 24);
 2744|     31|	} else if (mechanismType & SC_ALGORITHM_ECDSA_HASH_SHA256) {
  ------------------
  |  |  178|      0|#define SC_ALGORITHM_ECDSA_HASH_SHA256		SC_ALGORITHM_RSA_HASH_SHA256
  |  |  ------------------
  |  |  |  |  138|      0|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  |  |  ------------------
  ------------------
  |  Branch (2744:13): [True: 0, False: 0]
  ------------------
 2745|      0|		unsigned char data_hash[36] = {0};
 2746|      0|		size_t len = 0;
 2747|       |
 2748|      0|		sha256_digest(card, data, datalen, data_hash);
 2749|      0|		len = REVERSE_ORDER4(datalen);
  ------------------
  |  |  117|      0|#define REVERSE_ORDER4(x)	(			  \
  |  |  118|      0|		((unsigned long)x & 0xFF000000)>> 24	| \
  |  |  119|      0|		((unsigned long)x & 0x00FF0000)>>  8 	| \
  |  |  120|      0|		((unsigned long)x & 0x0000FF00)<<  8	| \
  |  |  121|      0|		((unsigned long)x & 0x000000FF)<< 24)
  ------------------
 2750|      0|		memcpy(&data_hash[32], &len, 4);
 2751|      0|		memcpy(hash, data_hash, 36);
 2752|      0|	} else {
 2753|      0|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 2754|      0|	}
 2755|       |
 2756|     31|	return SC_SUCCESS;
  ------------------
  |  |   28|     31|#define SC_SUCCESS				0
  ------------------
 2757|     31|}
card-epass2003.c:sha1_digest:
  651|     31|{
  652|     31|	EVP_MD *md = sc_evp_md(card->ctx, "SHA1");
  653|     31|	int r;
  654|       |
  655|     31|	r = openssl_dig(md, input, length, output);
  656|     31|	sc_evp_md_free(md);
  657|     31|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|     31|#define SC_SUCCESS				0
  ------------------
  |  Branch (657:6): [True: 0, False: 31]
  ------------------
  658|      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__
  |  |  ------------------
  ------------------
  659|     31|	return r;
  660|     31|}
card-epass2003.c:openssl_dig:
  618|     31|{
  619|     31|	int r = 0;
  620|     31|	EVP_MD_CTX *ctx = NULL;
  621|     31|	unsigned outl = 0;
  622|       |
  623|     31|	ctx = EVP_MD_CTX_create();
  624|     31|	if (ctx == NULL) {
  ------------------
  |  Branch (624:6): [True: 0, False: 31]
  ------------------
  625|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  626|      0|		goto err;
  627|      0|	}
  628|       |
  629|     31|	EVP_MD_CTX_init(ctx);
  630|     31|	if (!EVP_DigestInit_ex(ctx, digest, NULL) ||
  ------------------
  |  Branch (630:6): [True: 0, False: 31]
  ------------------
  631|     31|			!EVP_DigestUpdate(ctx, input, length)) {
  ------------------
  |  Branch (631:4): [True: 0, False: 31]
  ------------------
  632|      0|		r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  633|      0|		goto err;
  634|      0|	}
  635|       |
  636|     31|	if (!EVP_DigestFinal_ex(ctx, output, &outl)) {
  ------------------
  |  Branch (636:6): [True: 0, False: 31]
  ------------------
  637|      0|		r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  638|      0|		goto err;
  639|      0|	}
  640|     31|	r = SC_SUCCESS;
  ------------------
  |  |   28|     31|#define SC_SUCCESS				0
  ------------------
  641|     31|err:
  642|     31|	if (ctx)
  ------------------
  |  Branch (642:6): [True: 31, False: 0]
  ------------------
  643|     31|		EVP_MD_CTX_destroy(ctx);
  644|       |
  645|     31|	return r;
  646|     31|}
card-epass2003.c:epass2003_create_file:
 2594|    323|{
 2595|    323|	int r;
 2596|    323|	size_t len;
 2597|    323|	u8 sbuf[SC_MAX_APDU_BUFFER_SIZE] = {0};
 2598|    323|	struct sc_apdu apdu;
 2599|       |
 2600|    323|	len = SC_MAX_APDU_BUFFER_SIZE;
  ------------------
  |  |   34|    323|#define SC_MAX_APDU_BUFFER_SIZE		261 /* takes account of: CLA INS P1 P2 Lc [255 byte of data] Le */
  ------------------
 2601|       |
 2602|    323|	epass2003_hook_file(file, 1);
 2603|       |
 2604|    323|	if (card->ops->construct_fci == NULL)
  ------------------
  |  Branch (2604:6): [True: 0, False: 323]
  ------------------
 2605|    323|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2606|       |
 2607|    323|	r = epass2003_construct_fci(card, file, sbuf, &len);
 2608|    323|	LOG_TEST_RET(card->ctx, r, "construct_fci() failed");
  ------------------
  |  |  174|    323|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    323|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    323|	int _ret = (r); \
  |  |  |  |  168|    323|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 51, False: 272]
  |  |  |  |  ------------------
  |  |  |  |  169|     51|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     51|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     51|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     51|		return _ret; \
  |  |  |  |  172|     51|	} \
  |  |  |  |  173|    323|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 272]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2609|       |
 2610|    272|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE0, 0x00, 0x00);
  ------------------
  |  |  293|    272|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 2611|    272|	apdu.lc = len;
 2612|    272|	apdu.datalen = len;
 2613|    272|	apdu.data = sbuf;
 2614|       |
 2615|    272|	r = sc_transmit_apdu_t(card, &apdu);
 2616|    272|	LOG_TEST_RET(card->ctx, r, "APDU transmit 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: 5, False: 267]
  |  |  |  |  ------------------
  |  |  |  |  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|    272|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 267]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2617|    267|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 2618|    267|	LOG_TEST_RET(card->ctx, r, "APDU sw1/2 wrong");
  ------------------
  |  |  174|    267|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    267|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    267|	int _ret = (r); \
  |  |  |  |  168|    267|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 90, False: 177]
  |  |  |  |  ------------------
  |  |  |  |  169|     90|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     90|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     90|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     90|		return _ret; \
  |  |  |  |  172|     90|	} \
  |  |  |  |  173|    267|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 177]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2619|       |
 2620|    177|	epass2003_hook_file(file, 0);
 2621|    177|	return r;
 2622|    267|}
card-epass2003.c:epass2003_delete_file:
 2627|    361|{
 2628|    361|	int r;
 2629|    361|	u8 sbuf[2];
 2630|    361|	struct sc_apdu apdu;
 2631|       |
 2632|    361|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    361|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    361|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    361|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    361|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 361]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2633|       |
 2634|    361|	r = sc_select_file(card, path, NULL);
 2635|    361|	LOG_TEST_RET(card->ctx, r, "Can not select file");
  ------------------
  |  |  174|    361|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    361|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    361|	int _ret = (r); \
  |  |  |  |  168|    361|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 253, False: 108]
  |  |  |  |  ------------------
  |  |  |  |  169|    253|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    253|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    253|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    253|		return _ret; \
  |  |  |  |  172|    253|	} \
  |  |  |  |  173|    361|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 108]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2636|    108|	r = epass2003_hook_path((struct sc_path *)path, 1);
 2637|    108|	LOG_TEST_RET(card->ctx, r, "Can not hook path");
  ------------------
  |  |  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: 0, False: 108]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|    108|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 108]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2638|       |
 2639|    108|	sbuf[0] = path->value[path->len - 2];
 2640|    108|	sbuf[1] = path->value[path->len - 1];
 2641|    108|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE4, 0x00, 0x00);
  ------------------
  |  |  293|    108|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 2642|    108|	apdu.lc = 2;
 2643|    108|	apdu.datalen = 2;
 2644|    108|	apdu.data = sbuf;
 2645|       |
 2646|    108|	r = sc_transmit_apdu_t(card, &apdu);
 2647|    108|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    108|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    108|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    108|	int _ret = (r); \
  |  |  |  |  168|    108|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 107]
  |  |  |  |  ------------------
  |  |  |  |  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|    108|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 107]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2648|    107|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 2649|    107|	LOG_TEST_RET(card->ctx, r, "Delete file failed");
  ------------------
  |  |  174|    107|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    107|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    107|	int _ret = (r); \
  |  |  |  |  168|    107|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 25, False: 82]
  |  |  |  |  ------------------
  |  |  |  |  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|    107|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 82]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2650|       |
 2651|     82|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     82|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     82|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     82|	int _ret = r; \
  |  |  |  |  155|     82|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 82, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     82|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 82]
  |  |  |  |  ------------------
  |  |  |  |  157|     82|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     82|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     82|	return _ret; \
  |  |  |  |  163|     82|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2652|     82|}
card-epass2003.c:epass2003_card_ctl:
 3038|  1.42k|{
 3039|  1.42k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  1.42k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.42k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.42k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.42k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.42k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3040|       |
 3041|  1.42k|	sc_log(card->ctx, "cmd is %0lx", cmd);
  ------------------
  |  |   71|  1.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__
  |  |  ------------------
  ------------------
 3042|  1.42k|	switch (cmd) {
 3043|     31|	case SC_CARDCTL_ENTERSAFE_WRITE_KEY:
  ------------------
  |  Branch (3043:2): [True: 31, False: 1.39k]
  ------------------
 3044|     31|		return epass2003_write_key(card, (sc_epass2003_wkey_data *) ptr);
 3045|     30|	case SC_CARDCTL_ENTERSAFE_GENERATE_KEY:
  ------------------
  |  Branch (3045:2): [True: 30, False: 1.39k]
  ------------------
 3046|     30|		return epass2003_gen_key(card, (sc_epass2003_gen_key_data *) ptr);
 3047|     12|	case SC_CARDCTL_ERASE_CARD:
  ------------------
  |  Branch (3047:2): [True: 12, False: 1.41k]
  ------------------
 3048|     12|		return epass2003_erase_card(card);
 3049|    247|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (3049:2): [True: 247, False: 1.18k]
  ------------------
 3050|    247|		return epass2003_get_serialnr(card, (sc_serial_number_t *) ptr);
 3051|  1.10k|	default:
  ------------------
  |  Branch (3051:2): [True: 1.10k, False: 320]
  ------------------
 3052|  1.10k|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|  1.10k|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 3053|  1.42k|	}
 3054|  1.42k|}
card-epass2003.c:epass2003_write_key:
 2842|     31|{
 2843|     31|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     31|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     31|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     31|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     31|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 31]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2844|       |
 2845|     31|	if (data->type & SC_EPASS2003_KEY) {
  ------------------
  |  |  727|     31|#define	SC_EPASS2003_KEY	0x00000010
  ------------------
  |  Branch (2845:6): [True: 0, False: 31]
  ------------------
 2846|      0|		if (data->type == SC_EPASS2003_KEY_RSA)
  ------------------
  |  |  728|      0|#define	SC_EPASS2003_KEY_RSA	0x00000011
  ------------------
  |  Branch (2846:7): [True: 0, False: 0]
  ------------------
 2847|      0|			return internal_write_rsa_key(card, data->key_data.es_key.fid,
 2848|      0|						      data->key_data.es_key.rsa);
 2849|      0|		else
 2850|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2851|     31|	} else if (data->type & SC_EPASS2003_SECRET) {
  ------------------
  |  |  729|     31|#define	SC_EPASS2003_SECRET	0x00000020
  ------------------
  |  Branch (2851:13): [True: 31, False: 0]
  ------------------
 2852|     31|		if (data->type == SC_EPASS2003_SECRET_PRE)
  ------------------
  |  |  730|     31|#define	SC_EPASS2003_SECRET_PRE	0x00000021
  ------------------
  |  Branch (2852:7): [True: 0, False: 31]
  ------------------
 2853|      0|			return internal_install_pre(card);
 2854|     31|		else if (data->type == SC_EPASS2003_SECRET_PIN)
  ------------------
  |  |  731|     31|#define	SC_EPASS2003_SECRET_PIN	0x00000022
  ------------------
  |  Branch (2854:12): [True: 31, False: 0]
  ------------------
 2855|     31|			return internal_install_pin(card, data);
 2856|      0|		else
 2857|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2858|     31|	} else {
 2859|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2860|      0|	}
 2861|       |
 2862|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2863|      0|}
card-epass2003.c:install_secret_key:
 2764|     31|{
 2765|     31|	int r;
 2766|     31|	struct sc_apdu apdu;
 2767|     31|	unsigned char isapp = 0x00;	/* appendable */
 2768|     31|	unsigned char tmp_data[256] = {0};
 2769|       |
 2770|     31|	tmp_data[0] = ktype;
 2771|     31|	tmp_data[1] = kid;
 2772|     31|	tmp_data[2] = useac;
 2773|     31|	tmp_data[3] = modifyac;
 2774|     31|	tmp_data[8] = 0xFF;
 2775|       |
 2776|     31|	if (0x04 == ktype || 0x06 == ktype) {
  ------------------
  |  Branch (2776:6): [True: 31, False: 0]
  |  Branch (2776:23): [True: 0, False: 0]
  ------------------
 2777|     31|		tmp_data[4] = EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_SO;
  ------------------
  |  |  738|     31|#define EPASS2003_AC_MAC_NOLESS		0x90
  ------------------
              		tmp_data[4] = EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_SO;
  ------------------
  |  |  735|     31|#define EPASS2003_AC_SO			0x08
  ------------------
 2778|     31|		tmp_data[5] = EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_SO;
  ------------------
  |  |  738|     31|#define EPASS2003_AC_MAC_NOLESS		0x90
  ------------------
              		tmp_data[5] = EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_SO;
  ------------------
  |  |  735|     31|#define EPASS2003_AC_SO			0x08
  ------------------
 2779|     31|		tmp_data[7] = (kid == PIN_ID[0] ? EPASS2003_AC_USER : EPASS2003_AC_SO);
  ------------------
  |  |  734|      2|#define EPASS2003_AC_USER		0x06
  ------------------
              		tmp_data[7] = (kid == PIN_ID[0] ? EPASS2003_AC_USER : EPASS2003_AC_SO);
  ------------------
  |  |  735|     29|#define EPASS2003_AC_SO			0x08
  ------------------
  |  Branch (2779:18): [True: 2, False: 29]
  ------------------
 2780|     31|		tmp_data[9] = (EC << 4) | EC;
 2781|     31|	}
 2782|       |
 2783|     31|	memcpy(&tmp_data[10], data, dataLen);
 2784|     31|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xe3, isapp, 0x00);
  ------------------
  |  |  293|     31|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 2785|     31|	apdu.cla = 0x80;
 2786|     31|	apdu.lc = apdu.datalen = 10 + dataLen;
 2787|     31|	apdu.data = tmp_data;
 2788|       |
 2789|     31|	r = sc_transmit_apdu_t(card, &apdu);
 2790|     31|	LOG_TEST_RET(card->ctx, r, "APDU install_secret_key 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: 1, False: 30]
  |  |  |  |  ------------------
  |  |  |  |  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|     31|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 30]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2791|     30|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 2792|     30|	LOG_TEST_RET(card->ctx, r, "install_secret_key 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: 23, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  169|     23|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     23|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     23|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     23|		return _ret; \
  |  |  |  |  172|     23|	} \
  |  |  |  |  173|     30|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2793|       |
 2794|      7|	return r;
 2795|     30|}
card-epass2003.c:internal_install_pin:
 2823|     31|{
 2824|     31|	int r;
 2825|     31|	unsigned char hash[HASH_LEN] = {0};
 2826|       |
 2827|     31|	r = hash_data(card, pin->key_data.es_secret.key_val, pin->key_data.es_secret.key_len, hash, SC_ALGORITHM_ECDSA_HASH_SHA1);
  ------------------
  |  |  176|     31|#define SC_ALGORITHM_ECDSA_HASH_SHA1		SC_ALGORITHM_RSA_HASH_SHA1
  |  |  ------------------
  |  |  |  |  134|     31|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  ------------------
  ------------------
 2828|     31|	LOG_TEST_RET(card->ctx, r, "hash data 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2829|       |
 2830|     31|	r = install_secret_key(card, 0x04, pin->key_data.es_secret.kid,
 2831|     31|			       pin->key_data.es_secret.ac[0],
 2832|     31|			       pin->key_data.es_secret.ac[1],
 2833|     31|			       pin->key_data.es_secret.EC, hash, HASH_LEN);
  ------------------
  |  |   86|     31|#define HASH_LEN	24
  ------------------
 2834|     31|	LOG_TEST_RET(card->ctx, r, "Install 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: 24, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  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|     31|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2835|       |
 2836|      7|	return r;
 2837|     31|}
card-epass2003.c:epass2003_gen_key:
 2868|     30|{
 2869|     30|	int r;
 2870|     30|	size_t len = data->key_length;
 2871|     30|	struct sc_apdu apdu;
 2872|     30|	u8 rbuf[SC_MAX_EXT_APDU_BUFFER_SIZE] = {0};
 2873|     30|	u8 sbuf[SC_MAX_EXT_APDU_BUFFER_SIZE] = {0};
 2874|       |
 2875|     30|	LOG_FUNC_CALLED(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2876|       |
 2877|     30|	if (len == 256) {
  ------------------
  |  Branch (2877:6): [True: 16, False: 14]
  ------------------
 2878|     16|		sbuf[0] = 0x02;
 2879|     16|	} else {
 2880|     14|		sbuf[0] = 0x01;
 2881|     14|	}
 2882|     30|	sbuf[1] = (u8) ((len >> 8) & 0xff);
 2883|     30|	sbuf[2] = (u8) (len & 0xff);
 2884|     30|	sbuf[3] = (u8) ((data->prkey_id >> 8) & 0xFF);
 2885|     30|	sbuf[4] = (u8) ((data->prkey_id) & 0xFF);
 2886|     30|	sbuf[5] = (u8) ((data->pukey_id >> 8) & 0xFF);
 2887|     30|	sbuf[6] = (u8) ((data->pukey_id) & 0xFF);
 2888|       |
 2889|       |	/* generate key */
 2890|     30|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x46, 0x00, 0x00);
  ------------------
  |  |  293|     30|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 2891|     30|	apdu.lc = apdu.datalen = 7;
 2892|     30|	apdu.data = sbuf;
 2893|       |
 2894|     30|	r = sc_transmit_apdu_t(card, &apdu);
 2895|     30|	LOG_TEST_RET(card->ctx, r, "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: 1, False: 29]
  |  |  |  |  ------------------
  |  |  |  |  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|     30|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 29]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2896|     29|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 2897|     29|	LOG_TEST_RET(card->ctx, r, "generate key pair 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: 5, False: 24]
  |  |  |  |  ------------------
  |  |  |  |  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|     29|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 24]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2898|       |
 2899|       |	/* read public key */
 2900|     24|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xb4, 0x02, 0x00);
  ------------------
  |  |  293|     24|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 2901|     24|	if (len == 256) {
  ------------------
  |  Branch (2901:6): [True: 14, False: 10]
  ------------------
 2902|     14|		apdu.p1 = 0x00;
 2903|     14|	}
 2904|       |
 2905|     24|	apdu.cla = 0x80;
 2906|     24|	apdu.lc = apdu.datalen = 2;
 2907|     24|	apdu.data = &sbuf[5];
 2908|     24|	apdu.resp = rbuf;
 2909|     24|	apdu.resplen = sizeof(rbuf);
 2910|     24|	apdu.le = 0x00;
 2911|       |
 2912|     24|	r = sc_transmit_apdu_t(card, &apdu);
 2913|     24|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     24|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     24|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     24|	int _ret = (r); \
  |  |  |  |  168|     24|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 23]
  |  |  |  |  ------------------
  |  |  |  |  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|     24|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 23]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2914|     23|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 2915|     23|	LOG_TEST_RET(card->ctx, r, "get pukey failed");
  ------------------
  |  |  174|     23|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     23|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     23|	int _ret = (r); \
  |  |  |  |  168|     23|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2916|       |
 2917|     19|	if (len < apdu.resplen)
  ------------------
  |  Branch (2917:6): [True: 3, False: 16]
  ------------------
 2918|     19|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2919|       |
 2920|     16|	if (256 == len) { /* ECC 256 bit */
  ------------------
  |  Branch (2920:6): [True: 10, False: 6]
  ------------------
 2921|     10|		size_t xCoordinateLen = rbuf[1];
 2922|     10|		size_t yCoordinateLen;
 2923|     10|		unsigned char *tmp;
 2924|       |
 2925|     10|		if (2 + xCoordinateLen + 1 > apdu.resplen) {
  ------------------
  |  Branch (2925:7): [True: 4, False: 6]
  ------------------
 2926|      4|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2927|      4|		}
 2928|      6|		yCoordinateLen = rbuf[2 + xCoordinateLen + 1];
 2929|      6|		if (2 + xCoordinateLen + 2 + yCoordinateLen > apdu.resplen) {
  ------------------
  |  Branch (2929:7): [True: 4, False: 2]
  ------------------
 2930|      4|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2931|      4|		}
 2932|      2|		data->modulus_len = xCoordinateLen + yCoordinateLen;
 2933|      2|		tmp = (u8 *)malloc(data->modulus_len);
 2934|      2|		if (!tmp) {
  ------------------
  |  Branch (2934:7): [True: 0, False: 2]
  ------------------
 2935|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2936|      0|		}
 2937|       |
 2938|      2|		if (0x58 == rbuf[0]) {
  ------------------
  |  Branch (2938:7): [True: 0, False: 2]
  ------------------
 2939|      0|			memcpy(tmp, &rbuf[2], xCoordinateLen);
 2940|      2|		} else {
 2941|      2|			free(tmp);
 2942|      2|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_OBJECT_NOT_VALID);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2943|      2|		}
 2944|      0|		if (0x59 == rbuf[2 + xCoordinateLen]) {
  ------------------
  |  Branch (2944:7): [True: 0, False: 0]
  ------------------
 2945|      0|			memcpy(tmp + xCoordinateLen, &rbuf[2+xCoordinateLen+2], yCoordinateLen);
 2946|      0|		} else {
 2947|      0|			free(tmp);
 2948|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2949|      0|		}
 2950|       |
 2951|      0|		data->modulus = tmp;
 2952|      6|	} else {
 2953|      6|		data->modulus = (u8 *) malloc(len);
 2954|      6|		if (!data->modulus) {
  ------------------
  |  Branch (2954:7): [True: 0, False: 6]
  ------------------
 2955|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2956|      6|		} else {
 2957|      6|			memcpy(data->modulus, rbuf, len);
 2958|      6|		}
 2959|      6|	}
 2960|      6|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|      6|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      6|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      6|	int _ret = r; \
  |  |  |  |  155|      6|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      6|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 6]
  |  |  |  |  ------------------
  |  |  |  |  157|      6|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      6|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      6|	return _ret; \
  |  |  |  |  163|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2961|      6|}
card-epass2003.c:epass2003_erase_card:
 2966|     12|{
 2967|     12|	static const unsigned char install_magic_pin[26] = {
 2968|       |		/* compare install_secret_key */
 2969|     12|			0x06, 0x01, 0x10, 0x16, 0x16, 0x16, 0x00, 0x0f, 0xff, 0x66,
 2970|     12|			0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
 2971|     12|			0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
 2972|     12|	};
 2973|     12|	static const unsigned char magic_pin[16] = {
 2974|     12|			0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
 2975|     12|			0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
 2976|     12|	};
 2977|     12|	static const unsigned char mf_path[2] = { 0x3f, 0x00 };
 2978|     12|	sc_apdu_t apdu;
 2979|     12|	int r;
 2980|       |
 2981|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2982|       |
 2983|       |	/* install magic pin */
 2984|     12|	sc_format_apdu(card, &apdu, 0x03, 0xe3, 0x00, 0x00);
 2985|     12|	apdu.cla = 0x80;
 2986|     12|	apdu.data = install_magic_pin;
 2987|     12|	apdu.datalen = apdu.lc = sizeof(install_magic_pin);
 2988|     12|	r = sc_transmit_apdu(card, &apdu);
 2989|     12|	LOG_TEST_RET(card->ctx, r, "APDU install magic pin failed");
  ------------------
  |  |  174|     12|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     12|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     12|	int _ret = (r); \
  |  |  |  |  168|     12|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 11]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|     12|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 11]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2990|     11|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 2991|     11|	LOG_TEST_RET(card->ctx, r, "install magic pin 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2992|       |
 2993|       |	/* verify magic pin */
 2994|      8|	sc_format_apdu(card, &apdu, 0x03, 0x20, 0x00, 0x01);
 2995|      8|	apdu.cla = 0;
 2996|      8|	apdu.data = magic_pin;
 2997|      8|	apdu.datalen = apdu.lc = sizeof(magic_pin);
 2998|      8|	r = sc_transmit_apdu(card, &apdu);
 2999|      8|	LOG_TEST_RET(card->ctx, r, "APDU verify magic pin 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3000|      7|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 3001|      7|	LOG_TEST_RET(card->ctx, r, "verify magic pin failed");
  ------------------
  |  |  174|      7|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      7|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      7|	int _ret = (r); \
  |  |  |  |  168|      7|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  169|      3|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      3|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      3|		return _ret; \
  |  |  |  |  172|      3|	} \
  |  |  |  |  173|      7|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3002|       |
 3003|       |	/* delete MF */
 3004|      4|	sc_format_apdu(card, &apdu, 0x03, 0xe4, 0x00, 0x00);
 3005|      4|	apdu.cla = 0;
 3006|      4|	apdu.data = mf_path;
 3007|      4|	apdu.datalen = apdu.lc = sizeof(mf_path);
 3008|      4|	r = sc_transmit_apdu(card, &apdu);
 3009|      4|	LOG_TEST_RET(card->ctx, r, "APDU delete MF 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3010|      3|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 3011|      3|	LOG_TEST_RET(card->ctx, r, "delete MF 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3012|       |
 3013|      2|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|      2|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      2|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      2|	int _ret = r; \
  |  |  |  |  155|      2|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      2|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  157|      2|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      2|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      2|	return _ret; \
  |  |  |  |  163|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3014|      2|}
card-epass2003.c:epass2003_get_serialnr:
 3019|    247|{
 3020|    247|	u8 rbuf[8];
 3021|    247|	size_t rbuf_len = sizeof(rbuf);
 3022|       |
 3023|    247|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    247|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    247|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    247|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    247|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 247]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3024|       |
 3025|    247|	if (SC_SUCCESS != get_data(card, 0x80, rbuf, rbuf_len))
  ------------------
  |  |   28|    247|#define SC_SUCCESS				0
  ------------------
  |  Branch (3025:6): [True: 190, False: 57]
  ------------------
 3026|    190|		return SC_ERROR_CARD_CMD_FAILED;
  ------------------
  |  |   50|    190|#define SC_ERROR_CARD_CMD_FAILED		-1200
  ------------------
 3027|       |
 3028|     57|	card->serialnr.len = serial->len = 8;
 3029|     57|	memcpy(card->serialnr.value, rbuf, 8);
 3030|     57|	memcpy(serial->value, rbuf, 8);
 3031|       |
 3032|     57|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|     57|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     57|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     57|	int _ret = r; \
  |  |  |  |  155|     57|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 57, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     57|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 57]
  |  |  |  |  ------------------
  |  |  |  |  157|     57|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     57|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     57|	return _ret; \
  |  |  |  |  163|     57|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3033|     57|}
card-epass2003.c:epass2003_process_fci:
 2297|  2.18k|{
 2298|  2.18k|	sc_context_t *ctx = card->ctx;
 2299|  2.18k|	size_t taglen, len = buflen;
 2300|  2.18k|	const u8 *tag = NULL, *p = buf;
 2301|       |
 2302|  2.18k|	sc_log(ctx, "processing FCI bytes");
  ------------------
  |  |   71|  2.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__
  |  |  ------------------
  ------------------
 2303|  2.18k|	tag = sc_asn1_find_tag(ctx, p, len, 0x83, &taglen);
 2304|  2.18k|	if (tag != NULL && taglen == 2) {
  ------------------
  |  Branch (2304:6): [True: 636, False: 1.54k]
  |  Branch (2304:21): [True: 602, False: 34]
  ------------------
 2305|    602|		file->id = (tag[0] << 8) | tag[1];
 2306|    602|		sc_log(ctx, "  file identifier: 0x%02X%02X", tag[0], tag[1]);
  ------------------
  |  |   71|    602|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2307|    602|	}
 2308|       |
 2309|  2.18k|	tag = sc_asn1_find_tag(ctx, p, len, 0x80, &taglen);
 2310|  2.18k|	if (tag != NULL && taglen > 0 && taglen < 3) {
  ------------------
  |  Branch (2310:6): [True: 157, False: 2.02k]
  |  Branch (2310:21): [True: 123, False: 34]
  |  Branch (2310:35): [True: 73, False: 50]
  ------------------
 2311|     73|		file->size = tag[0];
 2312|     73|		if (taglen == 2)
  ------------------
  |  Branch (2312:7): [True: 60, False: 13]
  ------------------
 2313|     60|			file->size = (file->size << 8) + tag[1];
 2314|     73|		sc_log(ctx, "  bytes in file: %zu", file->size);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2315|     73|	}
 2316|       |
 2317|  2.18k|	if (tag == NULL) {
  ------------------
  |  Branch (2317:6): [True: 2.02k, False: 157]
  ------------------
 2318|  2.02k|		tag = sc_asn1_find_tag(ctx, p, len, 0x81, &taglen);
 2319|  2.02k|		if (tag != NULL && taglen >= 2) {
  ------------------
  |  Branch (2319:7): [True: 76, False: 1.94k]
  |  Branch (2319:22): [True: 41, False: 35]
  ------------------
 2320|     41|			int bytes = (tag[0] << 8) + tag[1];
 2321|       |
 2322|     41|			sc_log(ctx, "  bytes in file: %d", bytes);
  ------------------
  |  |   71|     41|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2323|     41|			file->size = bytes;
 2324|     41|		}
 2325|  2.02k|	}
 2326|       |
 2327|  2.18k|	tag = sc_asn1_find_tag(ctx, p, len, 0x82, &taglen);
 2328|  2.18k|	if (tag != NULL) {
  ------------------
  |  Branch (2328:6): [True: 893, False: 1.28k]
  ------------------
 2329|    893|		if (taglen > 0) {
  ------------------
  |  Branch (2329:7): [True: 869, False: 24]
  ------------------
 2330|    869|			unsigned char byte = tag[0];
 2331|    869|			const char *type;
 2332|       |
 2333|    869|			if (byte == 0x38) {
  ------------------
  |  Branch (2333:8): [True: 22, False: 847]
  ------------------
 2334|     22|				type = "DF";
 2335|     22|				file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|     22|#define SC_FILE_TYPE_DF			0x04
  ------------------
 2336|    847|			} else if (0x01 <= byte && byte <= 0x07) {
  ------------------
  |  Branch (2336:15): [True: 801, False: 46]
  |  Branch (2336:31): [True: 154, False: 647]
  ------------------
 2337|    154|				type = "working EF";
 2338|    154|				file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|    154|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
 2339|    154|				switch (byte) {
 2340|     70|				case 0x01:
  ------------------
  |  Branch (2340:5): [True: 70, False: 84]
  ------------------
 2341|     70|					file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|     70|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
 2342|     70|					break;
 2343|     50|				case 0x02:
  ------------------
  |  Branch (2343:5): [True: 50, False: 104]
  ------------------
 2344|     50|					file->ef_structure = SC_FILE_EF_LINEAR_FIXED;
  ------------------
  |  |  222|     50|#define SC_FILE_EF_LINEAR_FIXED		0x02
  ------------------
 2345|     50|					break;
 2346|     11|				case 0x04:
  ------------------
  |  Branch (2346:5): [True: 11, False: 143]
  ------------------
 2347|     11|					file->ef_structure = SC_FILE_EF_LINEAR_FIXED;
  ------------------
  |  |  222|     11|#define SC_FILE_EF_LINEAR_FIXED		0x02
  ------------------
 2348|     11|					break;
 2349|     23|				default:
  ------------------
  |  Branch (2349:5): [True: 23, False: 131]
  ------------------
 2350|     23|					break;
 2351|    154|				}
 2352|       |
 2353|    693|			} else if (0x10 == byte) {
  ------------------
  |  Branch (2353:15): [True: 6, False: 687]
  ------------------
 2354|      6|				type = "BSO";
 2355|      6|				file->type = SC_FILE_TYPE_BSO;
  ------------------
  |  |  217|      6|#define SC_FILE_TYPE_BSO		0x10
  ------------------
 2356|    687|			} else if (0x11 <= byte) {
  ------------------
  |  Branch (2356:15): [True: 633, False: 54]
  ------------------
 2357|    633|				type = "internal EF";
 2358|    633|				file->type = SC_FILE_TYPE_INTERNAL_EF;
  ------------------
  |  |  215|    633|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
 2359|    633|				switch (byte) {
 2360|    558|				case 0x11:
  ------------------
  |  Branch (2360:5): [True: 558, False: 75]
  ------------------
 2361|    558|					break;
 2362|     11|				case 0x12:
  ------------------
  |  Branch (2362:5): [True: 11, False: 622]
  ------------------
 2363|     11|					break;
 2364|     64|				default:
  ------------------
  |  Branch (2364:5): [True: 64, False: 569]
  ------------------
 2365|     64|					break;
 2366|    633|				}
 2367|    633|			} else {
 2368|     54|				type = "unknown";
 2369|     54|				file->type = SC_FILE_TYPE_INTERNAL_EF;
  ------------------
  |  |  215|     54|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
 2370|     54|			}
 2371|    869|			sc_log(ctx, "type %s, EF structure %d", type, byte);
  ------------------
  |  |   71|    869|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2372|    869|		}
 2373|    893|	}
 2374|       |
 2375|  2.18k|	tag = sc_asn1_find_tag(ctx, p, len, 0x84, &taglen);
 2376|  2.18k|	if (tag != NULL && taglen > 0 && taglen <= 16) {
  ------------------
  |  Branch (2376:6): [True: 81, False: 2.09k]
  |  Branch (2376:21): [True: 68, False: 13]
  |  Branch (2376:35): [True: 46, False: 22]
  ------------------
 2377|     46|		memcpy(file->name, tag, taglen);
 2378|     46|		file->namelen = taglen;
 2379|       |
 2380|     46|		sc_log_hex(ctx, "File name", file->name, file->namelen);
  ------------------
  |  |  129|     46|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|     46|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2381|     46|		if (!file->type)
  ------------------
  |  Branch (2381:7): [True: 23, False: 23]
  ------------------
 2382|     23|			file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|     23|#define SC_FILE_TYPE_DF			0x04
  ------------------
 2383|     46|	}
 2384|       |
 2385|  2.18k|	tag = sc_asn1_find_tag(ctx, p, len, 0x85, &taglen);
 2386|  2.18k|	if (tag != NULL && taglen)
  ------------------
  |  Branch (2386:6): [True: 621, False: 1.55k]
  |  Branch (2386:21): [True: 600, False: 21]
  ------------------
 2387|    600|		sc_file_set_prop_attr(file, tag, taglen);
 2388|  1.58k|	else
 2389|  1.58k|		file->prop_attr_len = 0;
 2390|       |
 2391|  2.18k|	tag = sc_asn1_find_tag(ctx, p, len, 0xA5, &taglen);
 2392|  2.18k|	if (tag != NULL && taglen)
  ------------------
  |  Branch (2392:6): [True: 18, False: 2.16k]
  |  Branch (2392:21): [True: 11, False: 7]
  ------------------
 2393|     11|		sc_file_set_prop_attr(file, tag, taglen);
 2394|       |
 2395|  2.18k|	tag = sc_asn1_find_tag(ctx, p, len, 0x86, &taglen);
 2396|  2.18k|	if (tag != NULL && taglen) {
  ------------------
  |  Branch (2396:6): [True: 713, False: 1.46k]
  |  Branch (2396:21): [True: 706, False: 7]
  ------------------
 2397|    706|		unsigned int i;
 2398|    706|		sc_file_set_sec_attr(file, tag, taglen);
 2399|  7.42k|		for (i = 0; i< taglen; i++)
  ------------------
  |  Branch (2399:15): [True: 6.71k, False: 706]
  ------------------
 2400|  6.71k|			if (tag[i] != 0xff) /* skip unused entries */
  ------------------
  |  Branch (2400:8): [True: 3.50k, False: 3.21k]
  ------------------
 2401|  3.50k|				sec_attr_to_entry(card, file, i);
 2402|    706|	}
 2403|       |
 2404|  2.18k|	tag = sc_asn1_find_tag(ctx, p, len, 0x8A, &taglen);
 2405|  2.18k|	if (tag != NULL && taglen == 1) {
  ------------------
  |  Branch (2405:6): [True: 99, False: 2.08k]
  |  Branch (2405:21): [True: 92, False: 7]
  ------------------
 2406|     92|		if (tag[0] == 0x01)
  ------------------
  |  Branch (2406:7): [True: 25, False: 67]
  ------------------
 2407|     25|			file->status = SC_FILE_STATUS_CREATION;
  ------------------
  |  |  240|     25|#define SC_FILE_STATUS_CREATION		0x02 /* ISO7816-4: Creation state, (1) */
  ------------------
 2408|     67|		else if (tag[0] == 0x07 || tag[0] == 0x05)
  ------------------
  |  Branch (2408:12): [True: 20, False: 47]
  |  Branch (2408:30): [True: 6, False: 41]
  ------------------
 2409|     26|			file->status = SC_FILE_STATUS_ACTIVATED;
  ------------------
  |  |  236|     26|#define SC_FILE_STATUS_ACTIVATED	0x00 /* ISO7816-4: Operational state (activated)   (5, 7) */
  ------------------
 2410|     41|		else if (tag[0] == 0x06 || tag[0] == 0x04)
  ------------------
  |  Branch (2410:12): [True: 10, False: 31]
  |  Branch (2410:30): [True: 10, False: 21]
  ------------------
 2411|     20|			file->status = SC_FILE_STATUS_INVALIDATED;
  ------------------
  |  |  237|     20|#define SC_FILE_STATUS_INVALIDATED	0x01 /* ISO7816-4: Operational state (deactivated) (4, 6) */
  ------------------
 2412|     92|	}
 2413|  2.18k|	file->magic = SC_FILE_MAGIC;
  ------------------
  |  |   57|  2.18k|#define SC_FILE_MAGIC			0x14426950
  ------------------
 2414|       |
 2415|  2.18k|	return 0;
 2416|  2.18k|}
card-epass2003.c:epass2003_construct_fci:
 2422|    323|{
 2423|    323|	u8 *p = out;
 2424|    323|	u8 buf[64];
 2425|    323|	unsigned char ops[8] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
 2426|    323|	int rv;
 2427|    323|	unsigned ii;
 2428|       |
 2429|    323|	if (*outlen < 2)
  ------------------
  |  Branch (2429:6): [True: 0, False: 323]
  ------------------
 2430|      0|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
 2431|       |
 2432|    323|	*p++ = 0x62;
 2433|    323|	p++;
 2434|    323|	if (file->type == SC_FILE_TYPE_WORKING_EF) {
  ------------------
  |  |  216|    323|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (2434:6): [True: 37, False: 286]
  ------------------
 2435|     37|		if (file->ef_structure == SC_FILE_EF_TRANSPARENT) {
  ------------------
  |  |  221|     37|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (2435:7): [True: 36, False: 1]
  ------------------
 2436|     36|			buf[0] = (file->size >> 8) & 0xFF;
 2437|     36|			buf[1] = file->size & 0xFF;
 2438|     36|			sc_asn1_put_tag(0x80, buf, 2, p, *outlen - (p - out), &p);
 2439|     36|		}
 2440|     37|	}
 2441|    323|	if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|    323|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (2441:6): [True: 22, False: 301]
  ------------------
 2442|     22|		buf[0] = 0x38;
 2443|     22|		buf[1] = 0x00;
 2444|     22|		sc_asn1_put_tag(0x82, buf, 2, p, *outlen - (p - out), &p);
 2445|     22|	}
 2446|    301|	else if (file->type == SC_FILE_TYPE_WORKING_EF) {
  ------------------
  |  |  216|    301|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (2446:11): [True: 37, False: 264]
  ------------------
 2447|     37|		buf[0] = file->ef_structure & 7;
 2448|     37|		if (file->ef_structure == SC_FILE_EF_TRANSPARENT) {
  ------------------
  |  |  221|     37|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (2448:7): [True: 36, False: 1]
  ------------------
 2449|     36|			buf[1] = 0x00;
 2450|     36|			sc_asn1_put_tag(0x82, buf, 2, p, *outlen - (p - out), &p);
 2451|     36|		} else if (file->ef_structure == SC_FILE_EF_LINEAR_FIXED ||
  ------------------
  |  |  222|      2|#define SC_FILE_EF_LINEAR_FIXED		0x02
  ------------------
  |  Branch (2451:14): [True: 0, False: 1]
  ------------------
 2452|      1|				file->ef_structure == SC_FILE_EF_LINEAR_VARIABLE) {
  ------------------
  |  |  224|      1|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  |  Branch (2452:5): [True: 0, False: 1]
  ------------------
 2453|      0|			buf[1] = 0x00;
 2454|      0|			buf[2] = 0x00;
 2455|      0|			buf[3] = 0x40;	/* record length */
 2456|      0|			buf[4] = 0x00;	/* record count */
 2457|      0|			sc_asn1_put_tag(0x82, buf, 5, p, *outlen - (p - out), &p);
 2458|      1|		} else {
 2459|      1|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      1|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 2460|      1|		}
 2461|       |
 2462|     37|	}
 2463|    264|	else if (file->type == SC_FILE_TYPE_INTERNAL_EF) {
  ------------------
  |  |  215|    264|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (2463:11): [True: 223, False: 41]
  ------------------
 2464|    223|		if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_CRT ||
  ------------------
  |  Branch (2464:7): [True: 100, False: 123]
  ------------------
 2465|    179|				file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_EC_CRT) {
  ------------------
  |  Branch (2465:5): [True: 79, False: 44]
  ------------------
 2466|    179|			buf[0] = 0x11;
 2467|    179|			buf[1] = 0x00;
 2468|    179|		} else if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC ||
  ------------------
  |  Branch (2468:14): [True: 20, False: 24]
  ------------------
 2469|     43|				file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_EC_PUBLIC) {
  ------------------
  |  Branch (2469:5): [True: 23, False: 1]
  ------------------
 2470|     43|			buf[0] = 0x12;
 2471|     43|			buf[1] = 0x00;
 2472|     43|		} else {
 2473|      1|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      1|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 2474|      1|		}
 2475|    222|		sc_asn1_put_tag(0x82, buf, 2, p, *outlen - (p - out), &p);
 2476|    222|	} else if (file->type == SC_FILE_TYPE_BSO) {
  ------------------
  |  |  217|     41|#define SC_FILE_TYPE_BSO		0x10
  ------------------
  |  Branch (2476:13): [True: 1, False: 40]
  ------------------
 2477|      1|		buf[0] = 0x10;
 2478|      1|		buf[1] = 0x00;
 2479|      1|		sc_asn1_put_tag(0x82, buf, 2, p, *outlen - (p - out), &p);
 2480|      1|	}
 2481|       |
 2482|    321|	buf[0] = (file->id >> 8) & 0xFF;
 2483|    321|	buf[1] = file->id & 0xFF;
 2484|    321|	sc_asn1_put_tag(0x83, buf, 2, p, *outlen - (p - out), &p);
 2485|    321|	if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|    321|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (2485:6): [True: 22, False: 299]
  ------------------
 2486|     22|		if (file->namelen != 0) {
  ------------------
  |  Branch (2486:7): [True: 13, False: 9]
  ------------------
 2487|     13|			sc_asn1_put_tag(0x84, file->name, file->namelen, p, *outlen - (p - out), &p);
 2488|     13|		} else {
 2489|      9|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      9|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 2490|      9|		}
 2491|     22|	}
 2492|    312|	if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|    312|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (2492:6): [True: 13, False: 299]
  ------------------
 2493|     13|		unsigned char data[2] = {0x00, 0x7F};
 2494|       |		/* 127 files at most */
 2495|     13|		sc_asn1_put_tag(0x85, data, sizeof(data), p, *outlen - (p - out), &p);
 2496|    299|	} else if (file->type == SC_FILE_TYPE_BSO) {
  ------------------
  |  |  217|    299|#define SC_FILE_TYPE_BSO		0x10
  ------------------
  |  Branch (2496:13): [True: 1, False: 298]
  ------------------
 2497|      1|		buf[0] = file->size & 0xff;
 2498|      1|		sc_asn1_put_tag(0x85, buf, 1, p, *outlen - (p - out), &p);
 2499|    298|	} else if (file->type == SC_FILE_TYPE_INTERNAL_EF) {
  ------------------
  |  |  215|    298|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (2499:13): [True: 222, False: 76]
  ------------------
 2500|    222|		if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_CRT ||
  ------------------
  |  Branch (2500:7): [True: 100, False: 122]
  ------------------
 2501|    122|				file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC ||
  ------------------
  |  Branch (2501:5): [True: 20, False: 102]
  ------------------
 2502|    102|				file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_EC_CRT ||
  ------------------
  |  Branch (2502:5): [True: 79, False: 23]
  ------------------
 2503|    222|				file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_EC_PUBLIC) {
  ------------------
  |  Branch (2503:5): [True: 23, False: 0]
  ------------------
 2504|    222|			buf[0] = (file->size >> 8) & 0xFF;
 2505|    222|			buf[1] = file->size & 0xFF;
 2506|    222|			sc_asn1_put_tag(0x85, buf, 2, p, *outlen - (p - out), &p);
 2507|    222|		}
 2508|    222|	}
 2509|    312|	if (file->sec_attr_len) {
  ------------------
  |  Branch (2509:6): [True: 0, False: 312]
  ------------------
 2510|      0|		if (file->sec_attr_len > sizeof(buf)) {
  ------------------
  |  Branch (2510:7): [True: 0, False: 0]
  ------------------
 2511|      0|			return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 2512|      0|		}
 2513|      0|		memcpy(buf, file->sec_attr, file->sec_attr_len);
 2514|      0|		sc_asn1_put_tag(0x86, buf, file->sec_attr_len, p, *outlen - (p - out), &p);
 2515|       |
 2516|    312|	} else {
 2517|    312|		sc_log(card->ctx, "SC_FILE_ACL");
  ------------------
  |  |   71|    312|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2518|    312|		if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|    312|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (2518:7): [True: 13, False: 299]
  ------------------
 2519|     13|			ops[0] = SC_AC_OP_LIST_FILES;
  ------------------
  |  |  172|     13|#define SC_AC_OP_LIST_FILES		6
  ------------------
 2520|     13|			ops[1] = SC_AC_OP_CREATE;
  ------------------
  |  |  169|     13|#define SC_AC_OP_CREATE			3
  ------------------
 2521|     13|			ops[3] = SC_AC_OP_DELETE;
  ------------------
  |  |  168|     13|#define SC_AC_OP_DELETE			2
  ------------------
 2522|    299|		} else if (file->type == SC_FILE_TYPE_WORKING_EF) {
  ------------------
  |  |  216|    299|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (2522:14): [True: 36, False: 263]
  ------------------
 2523|     36|			if (file->ef_structure == SC_FILE_EF_TRANSPARENT) {
  ------------------
  |  |  221|     36|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (2523:8): [True: 36, False: 0]
  ------------------
 2524|     36|				ops[0] = SC_AC_OP_READ;
  ------------------
  |  |  188|     36|#define SC_AC_OP_READ			22
  ------------------
 2525|     36|				ops[1] = SC_AC_OP_UPDATE;
  ------------------
  |  |  189|     36|#define SC_AC_OP_UPDATE			23
  ------------------
 2526|     36|				ops[3] = SC_AC_OP_DELETE;
  ------------------
  |  |  168|     36|#define SC_AC_OP_DELETE			2
  ------------------
 2527|     36|			} else if (file->ef_structure == SC_FILE_EF_LINEAR_FIXED ||
  ------------------
  |  |  222|      0|#define SC_FILE_EF_LINEAR_FIXED		0x02
  ------------------
  |  Branch (2527:15): [True: 0, False: 0]
  ------------------
 2528|      0|					file->ef_structure == SC_FILE_EF_LINEAR_VARIABLE) {
  ------------------
  |  |  224|      0|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  |  Branch (2528:6): [True: 0, False: 0]
  ------------------
 2529|      0|				ops[0] = SC_AC_OP_READ;
  ------------------
  |  |  188|      0|#define SC_AC_OP_READ			22
  ------------------
 2530|      0|				ops[1] = SC_AC_OP_UPDATE;
  ------------------
  |  |  189|      0|#define SC_AC_OP_UPDATE			23
  ------------------
 2531|      0|				ops[2] = SC_AC_OP_WRITE;
  ------------------
  |  |  190|      0|#define SC_AC_OP_WRITE			24
  ------------------
 2532|      0|				ops[3] = SC_AC_OP_DELETE;
  ------------------
  |  |  168|      0|#define SC_AC_OP_DELETE			2
  ------------------
 2533|      0|			} else {
 2534|      0|				return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 2535|      0|			}
 2536|    263|		} else if (file->type == SC_FILE_TYPE_BSO) {
  ------------------
  |  |  217|    263|#define SC_FILE_TYPE_BSO		0x10
  ------------------
  |  Branch (2536:14): [True: 1, False: 262]
  ------------------
 2537|      1|			ops[0] = SC_AC_OP_UPDATE;
  ------------------
  |  |  189|      1|#define SC_AC_OP_UPDATE			23
  ------------------
 2538|      1|			ops[3] = SC_AC_OP_DELETE;
  ------------------
  |  |  168|      1|#define SC_AC_OP_DELETE			2
  ------------------
 2539|    262|		} else if (file->type == SC_FILE_TYPE_INTERNAL_EF) {
  ------------------
  |  |  215|    262|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (2539:14): [True: 222, False: 40]
  ------------------
 2540|    222|			if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_CRT ||
  ------------------
  |  Branch (2540:8): [True: 100, False: 122]
  ------------------
 2541|    179|					file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_EC_CRT) {
  ------------------
  |  Branch (2541:6): [True: 79, False: 43]
  ------------------
 2542|    179|				ops[1] = SC_AC_OP_UPDATE;
  ------------------
  |  |  189|    179|#define SC_AC_OP_UPDATE			23
  ------------------
 2543|    179|				ops[2] = SC_AC_OP_CRYPTO;
  ------------------
  |  |  173|    179|#define SC_AC_OP_CRYPTO			7
  ------------------
 2544|    179|				ops[3] = SC_AC_OP_DELETE;
  ------------------
  |  |  168|    179|#define SC_AC_OP_DELETE			2
  ------------------
 2545|    179|			} else if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC ||
  ------------------
  |  Branch (2545:15): [True: 20, False: 23]
  ------------------
 2546|     43|					file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_EC_PUBLIC) {
  ------------------
  |  Branch (2546:6): [True: 23, False: 0]
  ------------------
 2547|     43|				ops[0] = SC_AC_OP_READ;
  ------------------
  |  |  188|     43|#define SC_AC_OP_READ			22
  ------------------
 2548|     43|				ops[1] = SC_AC_OP_UPDATE;
  ------------------
  |  |  189|     43|#define SC_AC_OP_UPDATE			23
  ------------------
 2549|     43|				ops[2] = SC_AC_OP_CRYPTO;
  ------------------
  |  |  173|     43|#define SC_AC_OP_CRYPTO			7
  ------------------
 2550|     43|				ops[3] = SC_AC_OP_DELETE;
  ------------------
  |  |  168|     43|#define SC_AC_OP_DELETE			2
  ------------------
 2551|     43|			}
 2552|    222|		} else {
 2553|     40|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|     40|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 2554|     40|		}
 2555|       |
 2556|  2.44k|		for (ii = 0; ii < sizeof(ops); ii++) {
  ------------------
  |  Branch (2556:16): [True: 2.17k, False: 272]
  ------------------
 2557|  2.17k|			const struct sc_acl_entry *entry;
 2558|       |
 2559|  2.17k|			buf[ii] = 0xFF;
 2560|  2.17k|			if (ops[ii] == 0xFF)
  ------------------
  |  Branch (2560:8): [True: 1.31k, False: 858]
  ------------------
 2561|  1.31k|				continue;
 2562|    858|			entry = sc_file_get_acl_entry(file, ops[ii]);
 2563|       |
 2564|    858|			rv = acl_to_ac_byte(card, entry);
 2565|    858|			LOG_TEST_RET(card->ctx, rv, "Invalid ACL");
  ------------------
  |  |  174|    858|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    858|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    858|	int _ret = (r); \
  |  |  |  |  168|    858|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 858]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|    858|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 858]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2566|       |
 2567|    858|			buf[ii] = rv;
 2568|    858|		}
 2569|    272|		sc_asn1_put_tag(0x86, buf, sizeof(ops), p, *outlen - (p - out), &p);
 2570|    272|		if (file->size == 256) {
  ------------------
  |  Branch (2570:7): [True: 102, False: 170]
  ------------------
 2571|    102|			out[4]= 0x13;
 2572|    102|		}
 2573|    272|	}
 2574|       |
 2575|       |	/* VT ??? */
 2576|    272|	if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC ||
  ------------------
  |  Branch (2576:6): [True: 20, False: 252]
  ------------------
 2577|    252|			file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_EC_PUBLIC) {
  ------------------
  |  Branch (2577:4): [True: 23, False: 229]
  ------------------
 2578|     43|		unsigned char data[2] = {0x00, 0x66};
 2579|     43|		sc_asn1_put_tag(0x87, data, sizeof(data), p, *outlen - (p - out), &p);
 2580|     43|		if (file->size == 256) {
  ------------------
  |  Branch (2580:7): [True: 23, False: 20]
  ------------------
 2581|     23|			out[4] = 0x14;
 2582|     23|		}
 2583|     43|	}
 2584|       |
 2585|    272|	out[1] = p - out - 2;
 2586|       |
 2587|    272|	*outlen = p - out;
 2588|    272|	return 0;
 2589|    312|}
card-epass2003.c:acl_to_ac_byte:
 2234|    858|{
 2235|    858|	if (e == NULL)
  ------------------
  |  Branch (2235:6): [True: 0, False: 858]
  ------------------
 2236|      0|		return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|      0|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
 2237|       |
 2238|    858|	switch (e->method) {
 2239|    747|	case SC_AC_NONE:
  ------------------
  |  |  150|    747|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (2239:2): [True: 747, False: 111]
  ------------------
 2240|    747|		LOG_FUNC_RETURN(card->ctx, EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_EVERYONE);
  ------------------
  |  |  164|    747|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    747|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    747|	int _ret = r; \
  |  |  |  |  155|    747|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 747]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    747|	} else { \
  |  |  |  |  159|    747|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    747|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    747|	} \
  |  |  |  |  162|    747|	return _ret; \
  |  |  |  |  163|    747|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2241|      4|	case SC_AC_NEVER:
  ------------------
  |  |  163|      4|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (2241:2): [True: 4, False: 854]
  ------------------
 2242|      4|		LOG_FUNC_RETURN(card->ctx, EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_NOONE);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2243|    107|	default:
  ------------------
  |  Branch (2243:2): [True: 107, False: 751]
  ------------------
 2244|    107|		LOG_FUNC_RETURN(card->ctx, EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_USER);
  ------------------
  |  |  164|    107|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    107|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    107|	int _ret = r; \
  |  |  |  |  155|    107|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 107]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    107|	} else { \
  |  |  |  |  159|    107|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    107|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    107|	} \
  |  |  |  |  162|    107|	return _ret; \
  |  |  |  |  163|    107|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2245|    858|	}
 2246|       |
 2247|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2248|      0|}
card-epass2003.c:epass2003_pin_cmd:
 3211|    247|{
 3212|    247|	int r;
 3213|    247|	u8 kid;
 3214|    247|	u8 retries = 0;
 3215|    247|	u8 pin_low = 3;
 3216|    247|	unsigned char maxtries = 0;
 3217|       |
 3218|    247|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    247|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    247|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    247|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    247|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 247]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3219|       |
 3220|    247|	internal_sanitize_pin_info(&data->pin1, 0);
 3221|    247|	internal_sanitize_pin_info(&data->pin2, 1);
 3222|    247|	data->flags |= SC_PIN_CMD_NEED_PADDING;
  ------------------
  |  |  422|    247|#define SC_PIN_CMD_NEED_PADDING		0x0002
  ------------------
 3223|    247|	kid = data->pin_reference;
 3224|       |
 3225|    247|	if (NULL == (unsigned char *)data->pin1.data || 0 == data->pin1.len)
  ------------------
  |  Branch (3225:6): [True: 247, False: 0]
  |  Branch (3225:50): [True: 0, False: 0]
  ------------------
 3226|    247|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_PIN_CODE_INCORRECT);
  ------------------
  |  |  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: 247, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    247|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    247|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 247, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    247|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    247|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    247|	return _ret; \
  |  |  |  |  163|    247|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3227|       |
 3228|       |	/* get pin retries */
 3229|      0|	if (data->cmd == SC_PIN_CMD_GET_INFO) {
  ------------------
  |  |  418|      0|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (3229:6): [True: 0, False: 0]
  ------------------
 3230|       |
 3231|      0|		r = get_external_key_retries(card, 0x80 | kid, &retries);
 3232|      0|		if (r == SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (3232:7): [True: 0, False: 0]
  ------------------
 3233|      0|			data->pin1.tries_left = retries;
 3234|       |
 3235|      0|			r = get_external_key_maxtries(card, &maxtries);
 3236|      0|			LOG_TEST_RET(card->ctx, r, "get max counter failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3237|       |
 3238|      0|			data->pin1.max_tries = maxtries;
 3239|      0|		}
 3240|      0|		LOG_TEST_RET(card->ctx, r, "verify pin failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3241|      0|	} else if (data->cmd == SC_PIN_CMD_UNBLOCK) { /* verify */
  ------------------
  |  |  417|      0|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (3241:13): [True: 0, False: 0]
  ------------------
 3242|      0|		r = external_key_auth(card, (kid + 1), (unsigned char *)data->pin1.data,
 3243|      0|				data->pin1.len);
 3244|      0|		LOG_TEST_RET(card->ctx, r, "verify pin failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3245|      0|	} else if (data->cmd == SC_PIN_CMD_CHANGE || data->cmd == SC_PIN_CMD_UNBLOCK) { /* change */
  ------------------
  |  |  416|      0|#define SC_PIN_CMD_CHANGE	1
  ------------------
              	} else if (data->cmd == SC_PIN_CMD_CHANGE || data->cmd == SC_PIN_CMD_UNBLOCK) { /* change */
  ------------------
  |  |  417|      0|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (3245:13): [True: 0, False: 0]
  |  Branch (3245:47): [True: 0, False: 0]
  ------------------
 3246|      0|		r = external_key_auth(card, kid, (unsigned char *)data->pin1.data,
 3247|      0|				data->pin1.len);
 3248|      0|		LOG_TEST_RET(card->ctx, r, "verify pin failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3249|       |
 3250|      0|		r = update_secret_key(card, 0x04, kid, data->pin2.data,
 3251|      0|				(unsigned long)data->pin2.len);
 3252|      0|		LOG_TEST_RET(card->ctx, r, "change pin failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3253|      0|	} else {
 3254|      0|		r = external_key_auth(card, kid, (unsigned char *)data->pin1.data,
 3255|      0|				data->pin1.len);
 3256|      0|		LOG_TEST_RET(card->ctx, r, "verify pin failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3257|       |
 3258|      0|		r = get_external_key_retries(card, 0x80 | kid, &retries);
 3259|      0|		if (retries < pin_low)
  ------------------
  |  Branch (3259:7): [True: 0, False: 0]
  ------------------
 3260|      0|			sc_log(card->ctx, "Verification failed (remaining tries: %d)", retries);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3261|       |
 3262|      0|		LOG_TEST_RET(card->ctx, r, "verify pin failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3263|      0|	}
 3264|       |
 3265|      0|	if (r == SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (3265:6): [True: 0, False: 0]
  ------------------
 3266|      0|		data->pin1.logged_in = SC_PIN_STATE_LOGGED_IN;
  ------------------
  |  |  432|      0|#define SC_PIN_STATE_LOGGED_IN  2
  ------------------
 3267|      0|	}
 3268|      0|	return r;
 3269|      0|}
card-epass2003.c:internal_sanitize_pin_info:
 3059|    494|{
 3060|    494|	pin->encoding = SC_PIN_ENCODING_ASCII;
  ------------------
  |  |  425|    494|#define SC_PIN_ENCODING_ASCII	0
  ------------------
 3061|    494|	pin->min_length = 4;
 3062|    494|	pin->max_length = 16;
 3063|    494|	pin->pad_length = 16;
 3064|    494|	pin->offset = 5 + num * 16;
 3065|    494|	pin->pad_char = 0x00;
 3066|    494|}
card-epass2003.c:epass2003_check_sw:
  245|  10.2k|{
  246|  10.2k|	const int err_count = sizeof(epass2003_errors)/sizeof(epass2003_errors[0]);
  247|  10.2k|	int i;
  248|       |
  249|       |	/* Handle special cases here */
  250|  10.2k|	if (sw1 == 0x6C) {
  ------------------
  |  Branch (250:6): [True: 31, False: 10.2k]
  ------------------
  251|     31|		sc_log(card->ctx, "Wrong length; correct length is %d", sw2);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  252|     31|		return SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|     31|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
  253|     31|	}
  254|       |
  255|   478k|	for (i = 0; i < err_count; i++) {
  ------------------
  |  Branch (255:14): [True: 478k, False: 744]
  ------------------
  256|   478k|		if (epass2003_errors[i].SWs == ((sw1 << 8) | sw2)) {
  ------------------
  |  Branch (256:7): [True: 9.50k, False: 468k]
  ------------------
  257|  9.50k|			sc_log(card->ctx, "%s", epass2003_errors[i].errorstr);
  ------------------
  |  |   71|  9.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__
  |  |  ------------------
  ------------------
  258|  9.50k|			return epass2003_errors[i].errorno;
  259|  9.50k|		}
  260|   478k|	}
  261|       |
  262|    744|	sc_log(card->ctx, "Unknown SWs; SW1=%02X, SW2=%02X", sw1, sw2);
  ------------------
  |  |   71|    744|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  263|    744|	return SC_ERROR_CARD_CMD_FAILED;
  ------------------
  |  |   50|    744|#define SC_ERROR_CARD_CMD_FAILED		-1200
  ------------------
  264|  10.2k|}

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

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

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

sc_get_gemsafeV1_driver:
  591|  16.3k|{
  592|  16.3k|	return sc_get_driver();
  593|  16.3k|}
card-gemsafeV1.c:sc_get_driver:
  566|  16.3k|{
  567|  16.3k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
  568|  16.3k|	if (!iso_ops)
  ------------------
  |  Branch (568:6): [True: 1, False: 16.3k]
  ------------------
  569|      1|		iso_ops = iso_drv->ops;
  570|       |	/* use the standard iso operations as default */
  571|  16.3k|	gemsafe_ops = *iso_drv->ops;
  572|       |	/* gemsafe specific functions */
  573|  16.3k|	gemsafe_ops.match_card	= gemsafe_match_card;
  574|  16.3k|	gemsafe_ops.init	= gemsafe_init;
  575|  16.3k|	gemsafe_ops.finish	= gemsafe_finish;
  576|  16.3k|	gemsafe_ops.select_file	= gemsafe_select_file;
  577|  16.3k|	gemsafe_ops.restore_security_env = gemsafe_restore_security_env;
  578|  16.3k|	gemsafe_ops.set_security_env     = gemsafe_set_security_env;
  579|  16.3k|	gemsafe_ops.decipher             = gemsafe_decipher;
  580|  16.3k|	gemsafe_ops.compute_signature    = gemsafe_compute_signature;
  581|  16.3k|	gemsafe_ops.get_challenge 		 = gemsafe_get_challenge;
  582|  16.3k|	gemsafe_ops.process_fci	= gemsafe_process_fci;
  583|  16.3k|	gemsafe_ops.pin_cmd		 = iso_ops->pin_cmd;
  584|  16.3k|	gemsafe_ops.card_reader_lock_obtained = gemsafe_card_reader_lock_obtained;
  585|  16.3k|	gemsafe_ops.logout = gemsafe_logout;
  586|       |
  587|  16.3k|	return &gemsafe_drv;
  588|  16.3k|}
card-gemsafeV1.c:gemsafe_match_card:
  124|  15.2k|{
  125|  15.2k|	int i;
  126|       |
  127|  15.2k|	i = _sc_match_atr(card, gemsafe_atrs, &card->type);
  128|  15.2k|	if (i < 0)
  ------------------
  |  Branch (128:6): [True: 15.2k, False: 6]
  ------------------
  129|  15.2k|		return 0;
  130|       |
  131|      6|	return 1;
  132|  15.2k|}
card-gemsafeV1.c:gemsafe_init:
  135|      6|{
  136|      6|	int	r;
  137|      6|	gemsafe_exdata *exdata = NULL;
  138|       |
  139|      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]
  |  |  ------------------
  ------------------
  140|       |
  141|      6|	card->name = "GemSAFE V1";
  142|      6|	card->cla  = 0x00;
  143|       |
  144|      6|	exdata = (gemsafe_exdata *)calloc(1, sizeof(gemsafe_exdata));
  145|      6|	if (!exdata)
  ------------------
  |  Branch (145:6): [True: 0, False: 6]
  ------------------
  146|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  147|      6|	exdata->aid_len = sizeof(exdata->aid);
  148|      6|	if(card->type == SC_CARD_TYPE_GEMSAFEV1_GENERIC) {
  ------------------
  |  Branch (148:5): [True: 2, False: 4]
  ------------------
  149|       |		/* try to get a AID from the config file */
  150|      2|		r = get_conf_aid(card, exdata->aid, &exdata->aid_len);
  151|      2|		if (r < 0) {
  ------------------
  |  Branch (151:7): [True: 2, False: 0]
  ------------------
  152|       |			/* failed, use default value */
  153|      2|			memcpy(exdata->aid, gemsafe_def_aid, sizeof(gemsafe_def_aid));
  154|      2|			exdata->aid_len = sizeof(gemsafe_def_aid);
  155|      2|		}
  156|      4|	} else if (card->type == SC_CARD_TYPE_GEMSAFEV1_PTEID) {
  ------------------
  |  Branch (156:13): [True: 2, False: 2]
  ------------------
  157|      2|		memcpy(exdata->aid, gemsafe_pteid_aid, sizeof(gemsafe_pteid_aid));
  158|      2|		exdata->aid_len = sizeof(gemsafe_pteid_aid);
  159|      2|	} else if (card->type == SC_CARD_TYPE_GEMSAFEV1_SEEID) {
  ------------------
  |  Branch (159:13): [True: 2, False: 0]
  ------------------
  160|      2|		memcpy(exdata->aid, gemsafe_seeid_aid, sizeof(gemsafe_seeid_aid));
  161|      2|		exdata->aid_len = sizeof(gemsafe_seeid_aid);
  162|      2|	}
  163|       |
  164|       |	/* increase lock_count here to prevent sc_unlock to select
  165|       |	 * applet twice in gp_select_applet */
  166|      6|	card->lock_count++;
  167|       |	/* SELECT applet */
  168|      6|	r = iso7816_select_aid(card, exdata->aid, exdata->aid_len, NULL, NULL);
  169|      6|	if (r < 0) {
  ------------------
  |  Branch (169:6): [True: 3, False: 3]
  ------------------
  170|      3|		free(exdata);
  171|      3|		sc_log(card->ctx,  "applet selection failed\n");
  ------------------
  |  |   71|      3|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  172|      3|		return SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|      3|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  173|      3|	}
  174|      3|	card->lock_count--;
  175|       |
  176|       |	/* set the supported algorithm */
  177|      3|	unsigned long flags;
  178|       |
  179|      3|	flags  = SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |  111|      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) */
  |  |  ------------------
  |  |  |  |  109|      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) */
  |  |  ------------------
  |  |  |  |  110|      3|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  180|      3|	flags |= SC_ALGORITHM_RSA_PAD_ISO9796;
  ------------------
  |  |  106|      3|#define SC_ALGORITHM_RSA_PAD_ISO9796	0x00000008
  ------------------
  181|      3|	flags |= SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|      3|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  182|      3|	flags |= SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  133|      3|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  183|       |
  184|       |	/* GemSAFE V3 cards support SHA256 */
  185|      3|	if (card->type == SC_CARD_TYPE_GEMSAFEV1_PTEID ||
  ------------------
  |  Branch (185:6): [True: 1, False: 2]
  ------------------
  186|      2|	    card->type == SC_CARD_TYPE_GEMSAFEV1_SEEID)
  ------------------
  |  Branch (186:6): [True: 1, False: 1]
  ------------------
  187|      2|		flags |= SC_ALGORITHM_RSA_HASH_SHA256;
  ------------------
  |  |  138|      2|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  ------------------
  188|       |
  189|      3|	_sc_card_add_rsa_alg(card,  512, flags, 0);
  190|      3|	_sc_card_add_rsa_alg(card,  768, flags, 0);
  191|      3|	_sc_card_add_rsa_alg(card, 1024, flags, 0);
  192|      3|	_sc_card_add_rsa_alg(card, 2048, flags, 0);
  193|      3|	_sc_card_add_rsa_alg(card, 3072, flags, 0);
  194|      3|	_sc_card_add_rsa_alg(card, 4096, flags, 0);
  195|       |
  196|       |	/* fake algorithm to persuade register_mechanisms()
  197|       |	 * to register these hashes */
  198|      3|	if (card->type == SC_CARD_TYPE_GEMSAFEV1_PTEID ||
  ------------------
  |  Branch (198:6): [True: 1, False: 2]
  ------------------
  199|      2|	    card->type == SC_CARD_TYPE_GEMSAFEV1_SEEID) {
  ------------------
  |  Branch (199:6): [True: 1, False: 1]
  ------------------
  200|      2|		flags  = SC_ALGORITHM_RSA_HASH_SHA1;
  ------------------
  |  |  134|      2|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  ------------------
  201|      2|		flags |= SC_ALGORITHM_RSA_HASH_MD5;
  ------------------
  |  |  135|      2|#define SC_ALGORITHM_RSA_HASH_MD5	0x00000400
  ------------------
  202|      2|		flags |= SC_ALGORITHM_RSA_HASH_MD5_SHA1;
  ------------------
  |  |  136|      2|#define SC_ALGORITHM_RSA_HASH_MD5_SHA1	0x00000800
  ------------------
  203|      2|		flags |= SC_ALGORITHM_RSA_HASH_RIPEMD160;
  ------------------
  |  |  137|      2|#define SC_ALGORITHM_RSA_HASH_RIPEMD160	0x00001000
  ------------------
  204|       |
  205|      2|		_sc_card_add_rsa_alg(card,  512, flags, 0);
  206|      2|	}
  207|       |
  208|      3|	card->caps |= SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  553|      3|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
  209|      3|	card->drv_data = exdata;
  210|       |
  211|      3|	return SC_SUCCESS;
  ------------------
  |  |   28|      3|#define SC_SUCCESS				0
  ------------------
  212|      6|}
card-gemsafeV1.c:get_conf_aid:
   93|      2|{
   94|      2|	sc_context_t		*ctx = card->ctx;
   95|      2|	scconf_block		*conf_block, **blocks;
   96|      2|	int			i;
   97|      2|	const char		*str_aid;
   98|       |
   99|      2|	SC_FUNC_CALLED(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]
  |  |  ------------------
  ------------------
  100|       |
  101|      2|	conf_block = NULL;
  102|      4|	for (i = 0; ctx->conf_blocks[i] != NULL; i++) {
  ------------------
  |  Branch (102:14): [True: 2, False: 2]
  ------------------
  103|      2|		blocks = scconf_find_blocks(ctx->conf, ctx->conf_blocks[i],
  104|      2|						"card", "gemsafeV1");
  105|      2|		if (blocks != NULL && blocks[0] != NULL)
  ------------------
  |  Branch (105:7): [True: 2, False: 0]
  |  Branch (105:25): [True: 0, False: 2]
  ------------------
  106|      0|			conf_block = blocks[0];
  107|      2|		free(blocks);
  108|      2|	}
  109|       |
  110|      2|	if (!conf_block) {
  ------------------
  |  Branch (110:6): [True: 2, False: 0]
  ------------------
  111|      2|		sc_log(ctx,  "no card specific options configured, trying default AID\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__
  |  |  ------------------
  ------------------
  112|      2|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      2|#define SC_ERROR_INTERNAL			-1400
  ------------------
  113|      2|	}
  114|       |
  115|      0|	str_aid = scconf_get_str(conf_block, "aid", NULL);
  116|      0|	if (!str_aid) {
  ------------------
  |  Branch (116:6): [True: 0, False: 0]
  ------------------
  117|      0|		sc_log(ctx,  "no aid configured, trying default AID\n");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  118|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  119|      0|	}
  120|      0|	return sc_hex_to_bin(str_aid, aid, len);
  121|      0|}
card-gemsafeV1.c:gemsafe_finish:
  215|      3|{
  216|      3|	gemsafe_exdata *exdata = (gemsafe_exdata *)card->drv_data;
  217|       |
  218|      3|	if (exdata)
  ------------------
  |  Branch (218:6): [True: 3, False: 0]
  ------------------
  219|      3|		free(exdata);
  220|      3|	return SC_SUCCESS;
  ------------------
  |  |   28|      3|#define SC_SUCCESS				0
  ------------------
  221|      3|}

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

sc_invalidate_cache:
  164|  2.51k|{
  165|  2.51k|	if (card) {
  ------------------
  |  Branch (165:6): [True: 2.51k, False: 0]
  ------------------
  166|  2.51k|		struct iasecc_private_data *prv = (struct iasecc_private_data *)card->drv_data;
  167|  2.51k|		sc_file_free(prv->cache.current_ef);
  168|  2.51k|		sc_file_free(prv->cache.current_df);
  169|  2.51k|		memset(&prv->cache, 0, sizeof(prv->cache));
  170|  2.51k|		prv->cache.valid = 0;
  171|  2.51k|	}
  172|  2.51k|}
iasecc_se_get_info:
 1609|     75|{
 1610|     75|	struct sc_context *ctx = card->ctx;
 1611|     75|	struct sc_apdu apdu;
 1612|     75|	unsigned char rbuf[0x100];
 1613|     75|	unsigned char sbuf_iasecc[10] = {
 1614|     75|		0x4D, 0x08, IASECC_SDO_TEMPLATE_TAG, 0x06,
  ------------------
  |  |   29|     75|#define IASECC_SDO_TEMPLATE_TAG	0x70
  ------------------
 1615|     75|		IASECC_SDO_TAG_HEADER, IASECC_SDO_CLASS_SE | IASECC_OBJECT_REF_LOCAL,
  ------------------
  |  |   27|     75|#define IASECC_SDO_TAG_HEADER	0xBF
  ------------------
              		IASECC_SDO_TAG_HEADER, IASECC_SDO_CLASS_SE | IASECC_OBJECT_REF_LOCAL,
  ------------------
  |  |  102|     75|#define IASECC_SDO_CLASS_SE		0x7B
  ------------------
              		IASECC_SDO_TAG_HEADER, IASECC_SDO_CLASS_SE | IASECC_OBJECT_REF_LOCAL,
  ------------------
  |  |   59|     75|#define IASECC_OBJECT_REF_LOCAL		0x80
  ------------------
 1616|     75|		se->reference & 0x3F,
 1617|     75|		0x02, IASECC_SDO_CLASS_SE, 0x80
  ------------------
  |  |  102|     75|#define IASECC_SDO_CLASS_SE		0x7B
  ------------------
 1618|     75|	};
 1619|     75|	int rv;
 1620|       |
 1621|     75|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     75|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     75|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     75|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     75|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 75]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1622|       |
 1623|     75|	if (iasecc_is_cpx(card)) {
  ------------------
  |  Branch (1623:6): [True: 2, False: 73]
  ------------------
 1624|      2|		rv = iasecc_select_mf(card, NULL);
 1625|      2|		LOG_TEST_RET(ctx, rv, "MF invalid");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1626|      2|	}
 1627|       |
 1628|     74|	if (se->reference > IASECC_SE_REF_MAX)
  ------------------
  |  |   66|     74|#define IASECC_SE_REF_MAX	0x0F
  ------------------
  |  Branch (1628:6): [True: 0, False: 74]
  ------------------
 1629|     74|                LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1630|       |
 1631|     74|	rv = iasecc_se_get_info_from_cache(card, se);
 1632|     74|	if (rv == SC_ERROR_OBJECT_NOT_FOUND)   {
  ------------------
  |  |   88|     74|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  |  Branch (1632:6): [True: 74, False: 0]
  ------------------
 1633|     74|		sc_log(ctx, "No SE#%X info in cache, try to use 'GET DATA'", se->reference);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1634|       |
 1635|     74|		sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xCB, 0x3F, 0xFF);
  ------------------
  |  |  294|     74|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
 1636|     74|		apdu.data = sbuf_iasecc;
 1637|     74|		apdu.datalen = sizeof(sbuf_iasecc);
 1638|     74|		apdu.lc = apdu.datalen;
 1639|     74|		apdu.resp = rbuf;
 1640|     74|		apdu.resplen = sizeof(rbuf);
 1641|     74|		apdu.le = sizeof(rbuf);
 1642|       |
 1643|     74|		rv = sc_transmit_apdu(card, &apdu);
 1644|     74|		LOG_TEST_RET(ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|     74|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     74|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     74|	int _ret = (r); \
  |  |  |  |  168|     74|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 4, False: 70]
  |  |  |  |  ------------------
  |  |  |  |  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|     74|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 70]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1645|     70|		rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1646|     70|		LOG_TEST_RET(ctx, rv, "get SE data  error");
  ------------------
  |  |  174|     70|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     70|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     70|	int _ret = (r); \
  |  |  |  |  168|     70|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 7, False: 63]
  |  |  |  |  ------------------
  |  |  |  |  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|     70|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 63]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1647|       |
 1648|     63|		rv = iasecc_se_parse(card, apdu.resp, apdu.resplen, se);
 1649|     63|		LOG_TEST_RET(ctx, rv, "cannot parse SE data");
  ------------------
  |  |  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: 53, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  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|     63|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1650|       |
 1651|     10|		rv = iasecc_se_cache_info(card, se);
 1652|     10|		LOG_TEST_RET(ctx, rv, "failed to put SE data into cache");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1653|     10|	}
 1654|       |
 1655|     10|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1656|     10|}
sc_get_iasecc_driver:
 3638|  16.3k|{
 3639|  16.3k|	return sc_get_driver();
 3640|  16.3k|}
card-iasecc.c:iasecc_is_cpx:
  586|  8.98k|{
  587|  8.98k|	switch(card->type) {
  588|    386|		case SC_CARD_TYPE_IASECC_CPX:
  ------------------
  |  Branch (588:3): [True: 386, False: 8.59k]
  ------------------
  589|  1.15k|		case SC_CARD_TYPE_IASECC_CPXCL:
  ------------------
  |  Branch (589:3): [True: 767, False: 8.21k]
  ------------------
  590|  1.15k|			return 1;
  591|  7.83k|		default:
  ------------------
  |  Branch (591:3): [True: 7.83k, False: 1.15k]
  ------------------
  592|  7.83k|			return 0;
  593|  8.98k|	}
  594|       |
  595|      0|	return 0;
  596|  8.98k|}
card-iasecc.c:iasecc_select_mf:
  283|  2.74k|{
  284|  2.74k|	struct iasecc_private_data *prv = (struct iasecc_private_data *)card->drv_data;
  285|  2.74k|	struct sc_context *ctx = card->ctx;
  286|  2.74k|	struct sc_file *mf_file = NULL;
  287|  2.74k|	struct sc_path path;
  288|  2.74k|	int rv;
  289|       |
  290|  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  291|       |
  292|  2.74k|	if (file_out)
  ------------------
  |  Branch (292:6): [True: 1.87k, False: 871]
  ------------------
  293|  1.87k|		*file_out = NULL;
  294|       |
  295|  2.74k|	memset(&path, 0, sizeof(struct sc_path));
  296|  2.74k|	if (!card->ef_atr || !card->ef_atr->aid.len)   {
  ------------------
  |  Branch (296:6): [True: 434, False: 2.30k]
  |  Branch (296:23): [True: 1.84k, False: 466]
  ------------------
  297|  2.27k|		struct sc_apdu apdu;
  298|  2.27k|		unsigned char apdu_resp[SC_MAX_APDU_BUFFER_SIZE];
  299|       |
  300|       |		/* ISO 'select' command fails when not FCP data returned */
  301|  2.27k|		sc_format_path("3F00", &path);
  302|  2.27k|		path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|  2.27k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  303|       |
  304|  2.27k|		sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xA4, 0x00, 0x0C);
  ------------------
  |  |  293|  2.27k|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  305|  2.27k|		apdu.lc = path.len;
  306|  2.27k|		apdu.data = path.value;
  307|  2.27k|		apdu.datalen = path.len;
  308|  2.27k|		apdu.resplen = sizeof(apdu_resp);
  309|  2.27k|		apdu.resp = apdu_resp;
  310|       |
  311|       |		/* TODO: this might be obsolete now that 0x0c (no data) is default for p2 */
  312|  2.27k|		if (card->type == SC_CARD_TYPE_IASECC_MI2)
  ------------------
  |  Branch (312:7): [True: 0, False: 2.27k]
  ------------------
  313|      0|			apdu.p2 = 0x04;
  314|       |
  315|  2.27k|		rv = sc_transmit_apdu(card, &apdu);
  316|  2.27k|		LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|  2.27k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.27k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.27k|	int _ret = (r); \
  |  |  |  |  168|  2.27k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 11, False: 2.26k]
  |  |  |  |  ------------------
  |  |  |  |  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|  2.27k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.26k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  317|  2.26k|		rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  318|  2.26k|		LOG_TEST_RET(card->ctx, rv, "Cannot select MF");
  ------------------
  |  |  174|  2.26k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.26k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.26k|	int _ret = (r); \
  |  |  |  |  168|  2.26k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.41k, False: 855]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.41k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  1.41k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.41k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.41k|		return _ret; \
  |  |  |  |  172|  1.41k|	} \
  |  |  |  |  173|  2.26k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 855]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  319|  2.26k|	}
  320|    466|	else   {
  321|    466|		memset(&path, 0, sizeof(path));
  322|    466|		path.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|    466|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  323|    466|		memcpy(path.value, card->ef_atr->aid.value, card->ef_atr->aid.len);
  324|    466|		path.len = card->ef_atr->aid.len;
  325|    466|		rv = iasecc_select_file(card, &path, file_out);
  326|    466|		LOG_TEST_RET(ctx, rv, "Unable to ROOT selection");
  ------------------
  |  |  174|    466|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    466|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    466|	int _ret = (r); \
  |  |  |  |  168|    466|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 173, False: 293]
  |  |  |  |  ------------------
  |  |  |  |  169|    173|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    173|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    173|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    173|		return _ret; \
  |  |  |  |  172|    173|	} \
  |  |  |  |  173|    466|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 293]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  327|    466|	}
  328|       |
  329|       |	/* Ignore the FCP of the MF, because:
  330|       |	 * - some cards do not return it;
  331|       |	 * - there is not need of it -- create/delete of the files in MF is not envisaged.
  332|       |	 */
  333|  1.14k|	mf_file = sc_file_new();
  334|  1.14k|	if (mf_file == NULL)
  ------------------
  |  Branch (334:6): [True: 0, False: 1.14k]
  ------------------
  335|  1.14k|		LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "Cannot allocate MF file");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  336|  1.14k|	mf_file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|  1.14k|#define SC_FILE_TYPE_DF			0x04
  ------------------
  337|  1.14k|	mf_file->path = path;
  338|       |
  339|  1.14k|	sc_invalidate_cache(card);
  340|  1.14k|	sc_file_dup(&prv->cache.current_df, mf_file);
  341|  1.14k|	prv->cache.valid = 1;
  342|       |
  343|  1.14k|	if (file_out && *file_out == NULL)
  ------------------
  |  Branch (343:6): [True: 899, False: 249]
  |  Branch (343:18): [True: 778, False: 121]
  ------------------
  344|    778|		*file_out = mf_file;
  345|    370|	else
  346|    370|		sc_file_free(mf_file);
  347|       |
  348|  1.14k|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|  1.14k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.14k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.14k|	int _ret = r; \
  |  |  |  |  155|  1.14k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.14k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.14k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 1.14k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.14k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.14k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|  1.14k|	return _ret; \
  |  |  |  |  163|  1.14k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  349|  1.14k|}
card-iasecc.c:iasecc_select_file:
  863|  6.61k|{
  864|  6.61k|	struct iasecc_private_data *prv = (struct iasecc_private_data *)card->drv_data;
  865|  6.61k|	struct sc_context *ctx = card->ctx;
  866|  6.61k|	struct sc_path lpath;
  867|  6.61k|	int rv, ii;
  868|       |
  869|  6.61k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  6.61k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  6.61k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  6.61k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  6.61k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 6.61k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  870|  6.61k|	memcpy(&lpath, path, sizeof(struct sc_path));
  871|  6.61k|	if (file_out)
  ------------------
  |  Branch (871:6): [True: 3.73k, False: 2.88k]
  ------------------
  872|  3.73k|		*file_out = NULL;
  873|       |
  874|  6.61k|	sc_log(ctx, "iasecc_select_file(card:%p) path.len %zu; path.type %i; aid_len %zu",
  ------------------
  |  |   71|  6.61k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  875|  6.61k|			card, path->len, path->type, path->aid.len);
  876|  6.61k|	sc_log(ctx, "iasecc_select_file() path:%s", sc_print_path(path));
  ------------------
  |  |   71|  6.61k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  877|       |
  878|  6.61k|	if ((!iasecc_is_cpx(card)) &&
  ------------------
  |  Branch (878:6): [True: 6.27k, False: 342]
  ------------------
  879|  6.27k|	    (card->type != SC_CARD_TYPE_IASECC_GEMALTO) &&
  ------------------
  |  Branch (879:6): [True: 4.30k, False: 1.96k]
  ------------------
  880|  4.30k|	    (path->type != SC_PATH_TYPE_DF_NAME
  ------------------
  |  |  118|  8.61k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (880:7): [True: 2.91k, False: 1.39k]
  ------------------
  881|  2.91k|			&& lpath.len >= 2
  ------------------
  |  Branch (881:7): [True: 2.82k, False: 92]
  ------------------
  882|  2.82k|			&& lpath.value[0] == 0x3F && lpath.value[1] == 0x00))   {
  ------------------
  |  Branch (882:7): [True: 2.56k, False: 253]
  |  Branch (882:33): [True: 2.55k, False: 10]
  ------------------
  883|  2.55k|		sc_log(ctx, "EF.ATR(aid:'%s')", card->ef_atr ? sc_dump_hex(card->ef_atr->aid.value, card->ef_atr->aid.len) : "");
  ------------------
  |  |   71|  5.11k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  |  Branch (71:122): [True: 2.13k, False: 424]
  |  |  ------------------
  ------------------
  884|       |
  885|  2.55k|		rv = iasecc_select_mf(card, file_out);
  886|  2.55k|		LOG_TEST_RET(ctx, rv, "MF selection error");
  ------------------
  |  |  174|  2.55k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.55k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.55k|	int _ret = (r); \
  |  |  |  |  168|  2.55k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.53k, False: 1.02k]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.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|  1.53k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.53k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.53k|		return _ret; \
  |  |  |  |  172|  1.53k|	} \
  |  |  |  |  173|  2.55k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.02k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  887|       |
  888|  1.02k|		memmove(&lpath.value[0], &lpath.value[2], lpath.len - 2);
  889|  1.02k|		lpath.len -=  2;
  890|  1.02k|	}
  891|       |
  892|  5.08k|	if (lpath.aid.len)	{
  ------------------
  |  Branch (892:6): [True: 169, False: 4.91k]
  ------------------
  893|    169|		struct sc_file *file = NULL;
  894|    169|		struct sc_path ppath;
  895|       |
  896|    169|		sc_log(ctx, "iasecc_select_file() select parent AID:%p/%zu", lpath.aid.value, lpath.aid.len);
  ------------------
  |  |   71|    169|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  897|    169|		sc_log(ctx, "iasecc_select_file() select parent AID:%s", sc_dump_hex(lpath.aid.value, lpath.aid.len));
  ------------------
  |  |   71|    169|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  898|    169|		memset(&ppath, 0, sizeof(ppath));
  899|    169|		memcpy(ppath.value, lpath.aid.value, lpath.aid.len);
  900|    169|		ppath.len = lpath.aid.len;
  901|    169|		ppath.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|    169|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  902|       |
  903|    169|		rv = iasecc_select_file(card, &ppath, &file);
  904|    169|		LOG_TEST_GOTO_ERR(ctx, rv, "select AID path failed");
  ------------------
  |  |  184|    169|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    169|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    169|	int _ret = (r); \
  |  |  |  |  178|    169|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 46, False: 123]
  |  |  |  |  ------------------
  |  |  |  |  179|     46|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     46|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     46|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     46|		goto err; \
  |  |  |  |  182|     46|	} \
  |  |  |  |  183|    169|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 123]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  905|       |
  906|    123|		if (file_out) {
  ------------------
  |  Branch (906:7): [True: 95, False: 28]
  ------------------
  907|     95|			sc_file_free(*file_out);
  908|     95|			*file_out = file;
  909|     95|		} else {
  910|     28|			sc_file_free(file);
  911|     28|		}
  912|       |
  913|    123|		if (lpath.type == SC_PATH_TYPE_DF_NAME)
  ------------------
  |  |  118|    123|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (913:7): [True: 34, False: 89]
  ------------------
  914|     34|			lpath.type = SC_PATH_TYPE_FROM_CURRENT;
  ------------------
  |  |  122|     34|#define SC_PATH_TYPE_FROM_CURRENT	4
  ------------------
  915|    123|	}
  916|       |
  917|  5.03k|	if (lpath.type == SC_PATH_TYPE_PATH)
  ------------------
  |  |  119|  5.03k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (917:6): [True: 2.63k, False: 2.40k]
  ------------------
  918|  2.63k|		lpath.type = SC_PATH_TYPE_FROM_CURRENT;
  ------------------
  |  |  122|  2.63k|#define SC_PATH_TYPE_FROM_CURRENT	4
  ------------------
  919|       |
  920|  5.03k|	if (!lpath.len) {
  ------------------
  |  Branch (920:6): [True: 242, False: 4.79k]
  ------------------
  921|    242|		if (file_out) {
  ------------------
  |  Branch (921:7): [True: 191, False: 51]
  ------------------
  922|    191|			sc_file_free(*file_out);
  923|    191|			*file_out = NULL;
  924|    191|		}
  925|    242|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    242|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    242|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    242|	int _ret = r; \
  |  |  |  |  155|    242|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 242, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    242|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 242]
  |  |  |  |  ------------------
  |  |  |  |  157|    242|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    242|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    242|	return _ret; \
  |  |  |  |  163|    242|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  926|    242|	}
  927|       |
  928|  4.79k|	do   {
  929|  4.79k|		struct sc_apdu apdu;
  930|  4.79k|		struct sc_file *file = NULL;
  931|  4.79k|		unsigned char rbuf[SC_MAX_APDU_BUFFER_SIZE];
  932|  4.79k|		size_t pathlen = lpath.len;
  933|       |
  934|  4.79k|		sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0x00, 0x00);
  ------------------
  |  |  294|  4.79k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  935|       |
  936|  4.79k|		if (card->type != SC_CARD_TYPE_IASECC_GEMALTO
  ------------------
  |  Branch (936:7): [True: 2.92k, False: 1.86k]
  ------------------
  937|  2.92k|				&& card->type != SC_CARD_TYPE_IASECC_OBERTHUR
  ------------------
  |  Branch (937:8): [True: 1.64k, False: 1.28k]
  ------------------
  938|  1.64k|				&& card->type != SC_CARD_TYPE_IASECC_SAGEM
  ------------------
  |  Branch (938:8): [True: 337, False: 1.30k]
  ------------------
  939|    337|				&& card->type != SC_CARD_TYPE_IASECC_AMOS
  ------------------
  |  Branch (939:8): [True: 337, False: 0]
  ------------------
  940|    337|				&& card->type != SC_CARD_TYPE_IASECC_MI
  ------------------
  |  Branch (940:8): [True: 337, False: 0]
  ------------------
  941|    337|				&& card->type != SC_CARD_TYPE_IASECC_MI2
  ------------------
  |  Branch (941:8): [True: 337, False: 0]
  ------------------
  942|    337|				&& !iasecc_is_cpx(card)) {
  ------------------
  |  Branch (942:8): [True: 0, False: 337]
  ------------------
  943|      0|			rv = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  944|      0|			LOG_TEST_GOTO_ERR(ctx, rv, "Unsupported card");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  945|      0|		}
  946|       |
  947|  4.79k|		if (lpath.type == SC_PATH_TYPE_FILE_ID)   {
  ------------------
  |  |  117|  4.79k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (947:7): [True: 256, False: 4.54k]
  ------------------
  948|    256|			apdu.p1 = 0x02;
  949|    256|			if (card->type == SC_CARD_TYPE_IASECC_OBERTHUR)
  ------------------
  |  Branch (949:8): [True: 228, False: 28]
  ------------------
  950|    228|				apdu.p1 = 0x01;
  951|    256|			if (card->type == SC_CARD_TYPE_IASECC_OBERTHUR ||
  ------------------
  |  Branch (951:8): [True: 228, False: 28]
  ------------------
  952|     28|			    card->type == SC_CARD_TYPE_IASECC_AMOS ||
  ------------------
  |  Branch (952:8): [True: 0, False: 28]
  ------------------
  953|     28|			    card->type == SC_CARD_TYPE_IASECC_MI ||
  ------------------
  |  Branch (953:8): [True: 0, False: 28]
  ------------------
  954|     28|			    card->type == SC_CARD_TYPE_IASECC_MI2 ||
  ------------------
  |  Branch (954:8): [True: 0, False: 28]
  ------------------
  955|     28|			    card->type == SC_CARD_TYPE_IASECC_GEMALTO ||
  ------------------
  |  Branch (955:8): [True: 3, False: 25]
  ------------------
  956|     25|			    iasecc_is_cpx(card)
  ------------------
  |  Branch (956:8): [True: 8, False: 17]
  ------------------
  957|    256|			    )   {
  958|    239|				apdu.p2 = 0x04;
  959|    239|			}
  960|    256|		}
  961|  4.54k|		else if (lpath.type == SC_PATH_TYPE_FROM_CURRENT)  {
  ------------------
  |  |  122|  4.54k|#define SC_PATH_TYPE_FROM_CURRENT	4
  ------------------
  |  Branch (961:12): [True: 2.63k, False: 1.90k]
  ------------------
  962|  2.63k|			apdu.p1 = 0x09;
  963|  2.63k|			if (card->type == SC_CARD_TYPE_IASECC_OBERTHUR ||
  ------------------
  |  Branch (963:8): [True: 408, False: 2.22k]
  ------------------
  964|  2.22k|			    card->type == SC_CARD_TYPE_IASECC_AMOS ||
  ------------------
  |  Branch (964:8): [True: 0, False: 2.22k]
  ------------------
  965|  2.22k|			    card->type == SC_CARD_TYPE_IASECC_MI ||
  ------------------
  |  Branch (965:8): [True: 0, False: 2.22k]
  ------------------
  966|  2.22k|			    card->type == SC_CARD_TYPE_IASECC_MI2 ||
  ------------------
  |  Branch (966:8): [True: 0, False: 2.22k]
  ------------------
  967|  2.22k|			    card->type == SC_CARD_TYPE_IASECC_GEMALTO ||
  ------------------
  |  Branch (967:8): [True: 1.35k, False: 870]
  ------------------
  968|  2.01k|			    iasecc_is_cpx(card)) {
  ------------------
  |  Branch (968:8): [True: 251, False: 619]
  ------------------
  969|  2.01k|				apdu.p2 = 0x04;
  970|  2.01k|			}
  971|  2.63k|		}
  972|  1.90k|		else if (lpath.type == SC_PATH_TYPE_PARENT)   {
  ------------------
  |  |  123|  1.90k|#define SC_PATH_TYPE_PARENT		5
  ------------------
  |  Branch (972:12): [True: 0, False: 1.90k]
  ------------------
  973|      0|			apdu.p1 = 0x03;
  974|      0|			pathlen = 0;
  975|      0|			apdu.cse = SC_APDU_CASE_2_SHORT;
  ------------------
  |  |  292|      0|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  976|      0|		}
  977|  1.90k|		else if (lpath.type == SC_PATH_TYPE_DF_NAME)   {
  ------------------
  |  |  118|  1.90k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (977:12): [True: 1.90k, False: 0]
  ------------------
  978|  1.90k|			apdu.p1 = 0x04;
  979|  1.90k|			if (card->type == SC_CARD_TYPE_IASECC_AMOS ||
  ------------------
  |  Branch (979:8): [True: 0, False: 1.90k]
  ------------------
  980|  1.90k|			    card->type == SC_CARD_TYPE_IASECC_MI2 ||
  ------------------
  |  Branch (980:8): [True: 0, False: 1.90k]
  ------------------
  981|  1.90k|			    card->type == SC_CARD_TYPE_IASECC_OBERTHUR ||
  ------------------
  |  Branch (981:8): [True: 648, False: 1.25k]
  ------------------
  982|  1.25k|			    card->type == SC_CARD_TYPE_IASECC_GEMALTO ||
  ------------------
  |  Branch (982:8): [True: 510, False: 749]
  ------------------
  983|  1.23k|			    iasecc_is_cpx(card)) {
  ------------------
  |  Branch (983:8): [True: 78, False: 671]
  ------------------
  984|  1.23k|				apdu.p2 = 0x04;
  985|  1.23k|			}
  986|  1.90k|		}
  987|      0|		else   {
  988|      0|			sc_log(ctx, "Invalid PATH type: 0x%X", lpath.type);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  989|      0|			rv = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  990|      0|			LOG_TEST_GOTO_ERR(ctx, rv, "iasecc_select_file() invalid PATH type");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  991|      0|		}
  992|       |
  993|  4.90k|		for (ii=0; ii<2; ii++)   {
  ------------------
  |  Branch (993:14): [True: 4.90k, False: 0]
  ------------------
  994|  4.90k|			apdu.lc = pathlen;
  995|  4.90k|			apdu.data = lpath.value;
  996|  4.90k|			apdu.datalen = pathlen;
  997|       |
  998|  4.90k|			apdu.resp = rbuf;
  999|  4.90k|			apdu.resplen = sizeof(rbuf);
 1000|  4.90k|			apdu.le = 256;
 1001|       |
 1002|  4.90k|			rv = sc_transmit_apdu(card, &apdu);
 1003|  4.90k|			LOG_TEST_GOTO_ERR(ctx, rv, "APDU transmit failed");
  ------------------
  |  |  184|  4.90k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  4.90k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  4.90k|	int _ret = (r); \
  |  |  |  |  178|  4.90k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 86, False: 4.81k]
  |  |  |  |  ------------------
  |  |  |  |  179|     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
  |  |  |  |  ------------------
  |  |  |  |  180|     86|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     86|		goto err; \
  |  |  |  |  182|     86|	} \
  |  |  |  |  183|  4.90k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 4.81k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1004|  4.81k|			rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1005|  4.81k|			if (rv == SC_ERROR_INCORRECT_PARAMETERS &&
  ------------------
  |  |   55|  9.63k|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
  |  Branch (1005:8): [True: 162, False: 4.65k]
  ------------------
 1006|    162|					lpath.type == SC_PATH_TYPE_DF_NAME && apdu.p2 == 0x00)   {
  ------------------
  |  |  118|  4.97k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (1006:6): [True: 124, False: 38]
  |  Branch (1006:44): [True: 106, False: 18]
  ------------------
 1007|    106|				sc_log(ctx, "Warning: SC_ERROR_INCORRECT_PARAMETERS for SC_PATH_TYPE_DF_NAME, try again with P2=0x0C");
  ------------------
  |  |   71|    106|#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|    106|				apdu.p2 = 0x0C;
 1009|    106|				continue;
 1010|    106|			}
 1011|       |
 1012|  4.71k|			if (ii)   {
  ------------------
  |  Branch (1012:8): [True: 106, False: 4.60k]
  ------------------
 1013|       |				/* 'SELECT AID' do not returned FCP. Try to emulate. */
 1014|    106|				apdu.resplen = sizeof(rbuf);
 1015|    106|				rv = iasecc_emulate_fcp(ctx, &apdu);
 1016|    106|				LOG_TEST_GOTO_ERR(ctx, rv, "Failed to emulate DF FCP");
  ------------------
  |  |  184|    106|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    106|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    106|	int _ret = (r); \
  |  |  |  |  178|    106|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 106]
  |  |  |  |  ------------------
  |  |  |  |  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|    106|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 106]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1017|    106|			}
 1018|       |
 1019|  4.71k|			break;
 1020|  4.71k|		}
 1021|       |
 1022|  4.71k|		LOG_TEST_GOTO_ERR(ctx, rv, "iasecc_select_file() check SW failed");
  ------------------
  |  |  184|  4.71k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  4.71k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  4.71k|	int _ret = (r); \
  |  |  |  |  178|  4.71k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 1.86k, False: 2.84k]
  |  |  |  |  ------------------
  |  |  |  |  179|  1.86k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.86k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|  1.86k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|  1.86k|		goto err; \
  |  |  |  |  182|  1.86k|	} \
  |  |  |  |  183|  4.71k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 2.84k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1023|       |
 1024|  2.84k|		sc_log(ctx, "iasecc_select_file() apdu.resp %zu", apdu.resplen);
  ------------------
  |  |   71|  2.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__
  |  |  ------------------
  ------------------
 1025|  2.84k|		if (apdu.resplen)   {
  ------------------
  |  Branch (1025:7): [True: 1.56k, False: 1.27k]
  ------------------
 1026|  1.56k|			sc_log(ctx, "apdu.resp %02X:%02X:%02X...", apdu.resp[0], apdu.resp[1], apdu.resp[2]);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1027|       |
 1028|  1.56k|			switch (apdu.resp[0]) {
 1029|    168|			case 0x62:
  ------------------
  |  Branch (1029:4): [True: 168, False: 1.40k]
  ------------------
 1030|  1.49k|			case 0x6F:
  ------------------
  |  Branch (1030:4): [True: 1.33k, False: 238]
  ------------------
 1031|  1.49k|				file = sc_file_new();
 1032|  1.49k|				if (file == NULL) {
  ------------------
  |  Branch (1032:9): [True: 0, False: 1.49k]
  ------------------
 1033|      0|					if (file_out) {
  ------------------
  |  Branch (1033:10): [True: 0, False: 0]
  ------------------
 1034|      0|						sc_file_free(*file_out);
 1035|      0|						*file_out = NULL;
 1036|      0|					}
 1037|      0|					LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1038|      0|				}
 1039|  1.49k|				file->path = lpath;
 1040|       |
 1041|  1.49k|				rv = iasecc_process_fci(card, file, apdu.resp, apdu.resplen);
 1042|  1.49k|				if (rv) {
  ------------------
  |  Branch (1042:9): [True: 268, False: 1.23k]
  ------------------
 1043|    268|					sc_file_free(file);
 1044|    268|					if (file_out) {
  ------------------
  |  Branch (1044:10): [True: 60, False: 208]
  ------------------
 1045|     60|						sc_file_free(*file_out);
 1046|     60|						*file_out = NULL;
 1047|     60|					}
 1048|    268|					LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    268|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    268|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    268|	int _ret = r; \
  |  |  |  |  155|    268|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 268, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    268|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    268|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 268, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    268|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    268|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    268|	return _ret; \
  |  |  |  |  163|    268|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1049|    268|				}
 1050|  1.23k|				break;
 1051|  1.23k|			default:
  ------------------
  |  Branch (1051:4): [True: 70, False: 1.49k]
  ------------------
 1052|     70|				if (file_out) {
  ------------------
  |  Branch (1052:9): [True: 35, False: 35]
  ------------------
 1053|     35|					sc_file_free(*file_out);
 1054|     35|					*file_out = NULL;
 1055|     35|				}
 1056|     70|				LOG_FUNC_RETURN(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|     70|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     70|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     70|	int _ret = r; \
  |  |  |  |  155|     70|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 70, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     70|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     70|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 70, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     70|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     70|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     70|	return _ret; \
  |  |  |  |  163|     70|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1057|  1.56k|			}
 1058|       |
 1059|  1.23k|			sc_log(ctx, "FileType %i", file->type);
  ------------------
  |  |   71|  1.23k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1060|  1.23k|			if (file->type == SC_FILE_TYPE_DF)   {
  ------------------
  |  |  214|  1.23k|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (1060:8): [True: 179, False: 1.05k]
  ------------------
 1061|    179|				sc_invalidate_cache(card);
 1062|    179|				sc_file_dup(&prv->cache.current_df, file);
 1063|    179|				prv->cache.valid = 1;
 1064|    179|			}
 1065|  1.05k|			else   {
 1066|  1.05k|				sc_file_free(prv->cache.current_ef);
 1067|  1.05k|				sc_file_dup(&prv->cache.current_ef, file);
 1068|  1.05k|				prv->cache.valid = 1;
 1069|  1.05k|			}
 1070|       |
 1071|  1.23k|			if (file_out)   {
  ------------------
  |  Branch (1071:8): [True: 990, False: 241]
  ------------------
 1072|    990|				sc_file_free(*file_out);
 1073|    990|				*file_out = file;
 1074|    990|			}
 1075|    241|			else   {
 1076|    241|				sc_file_free(file);
 1077|    241|			}
 1078|  1.23k|		}
 1079|  1.27k|		else if (lpath.type == SC_PATH_TYPE_DF_NAME)   {
  ------------------
  |  |  118|  1.27k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (1079:12): [True: 443, False: 834]
  ------------------
 1080|    443|			sc_invalidate_cache(card);
 1081|    443|			prv->cache.valid = 1;
 1082|    443|		}
 1083|  2.84k|	} while(0);
  ------------------
  |  Branch (1083:10): [Folded, False: 2.50k]
  ------------------
 1084|       |
 1085|  2.50k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 2.50k]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1086|  1.99k|err:
 1087|  1.99k|	if (file_out) {
  ------------------
  |  Branch (1087:6): [True: 760, False: 1.23k]
  ------------------
 1088|    760|		sc_file_free(*file_out);
 1089|       |		*file_out = NULL;
 1090|    760|	}
 1091|  1.99k|	return rv;
 1092|  2.50k|}
card-iasecc.c:iasecc_emulate_fcp:
  828|    106|{
  829|    106|	unsigned char dummy_df_fcp[] = {
  830|    106|		0x62,0xFF,
  831|    106|			0x82,0x01,0x38,
  832|    106|			0x8A,0x01,0x05,
  833|    106|			0xA1,0x04,0x8C,0x02,0x02,0x00,
  834|    106|			0x84,0xFF,
  835|    106|				0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  836|    106|				0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
  837|    106|	};
  838|       |
  839|    106|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    106|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    106|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    106|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    106|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 106]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  840|       |
  841|    106|	if (apdu->p1 != 0x04)
  ------------------
  |  Branch (841:6): [True: 0, False: 106]
  ------------------
  842|    106|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "FCP emulation supported only for the DF-NAME selection type");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  843|    106|	if (apdu->datalen > 16)
  ------------------
  |  Branch (843:6): [True: 0, False: 106]
  ------------------
  844|    106|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid DF-NAME length");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  845|    106|	if (apdu->resplen < apdu->datalen + 16)
  ------------------
  |  Branch (845:6): [True: 0, False: 106]
  ------------------
  846|    106|		LOG_TEST_RET(ctx, SC_ERROR_BUFFER_TOO_SMALL, "not enough space for FCP data");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  847|       |
  848|    106|	memcpy(dummy_df_fcp + 16, apdu->data, apdu->datalen);
  849|    106|	dummy_df_fcp[15] = apdu->datalen;
  850|    106|	dummy_df_fcp[1] = apdu->datalen + 14;
  851|    106|	apdu->resplen = apdu->datalen + 16;
  852|    106|	memcpy(apdu->resp, dummy_df_fcp, apdu->resplen);
  853|       |
  854|    106|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    106|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    106|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    106|	int _ret = r; \
  |  |  |  |  155|    106|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 106, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    106|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 106]
  |  |  |  |  ------------------
  |  |  |  |  157|    106|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    106|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    106|	return _ret; \
  |  |  |  |  163|    106|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  855|    106|}
card-iasecc.c:iasecc_process_fci:
 1098|  1.49k|{
 1099|  1.49k|	struct sc_context *ctx = card->ctx;
 1100|  1.49k|	size_t taglen, offs, ii;
 1101|  1.49k|	int rv;
 1102|  1.49k|	const unsigned char *acls = NULL, *tag = NULL;
 1103|  1.49k|	unsigned char mask;
 1104|  1.49k|	unsigned char ops_DF[7] = {
 1105|  1.49k|		SC_AC_OP_DELETE, 0xFF, SC_AC_OP_ACTIVATE, SC_AC_OP_DEACTIVATE, 0xFF, SC_AC_OP_CREATE, 0xFF
  ------------------
  |  |  168|  1.49k|#define SC_AC_OP_DELETE			2
  ------------------
              		SC_AC_OP_DELETE, 0xFF, SC_AC_OP_ACTIVATE, SC_AC_OP_DEACTIVATE, 0xFF, SC_AC_OP_CREATE, 0xFF
  ------------------
  |  |  186|  1.49k|#define SC_AC_OP_ACTIVATE		20
  ------------------
              		SC_AC_OP_DELETE, 0xFF, SC_AC_OP_ACTIVATE, SC_AC_OP_DEACTIVATE, 0xFF, SC_AC_OP_CREATE, 0xFF
  ------------------
  |  |  187|  1.49k|#define SC_AC_OP_DEACTIVATE		21
  ------------------
              		SC_AC_OP_DELETE, 0xFF, SC_AC_OP_ACTIVATE, SC_AC_OP_DEACTIVATE, 0xFF, SC_AC_OP_CREATE, 0xFF
  ------------------
  |  |  169|  1.49k|#define SC_AC_OP_CREATE			3
  ------------------
 1106|  1.49k|	};
 1107|  1.49k|	unsigned char ops_EF[7] = {
 1108|  1.49k|		SC_AC_OP_DELETE, 0xFF, SC_AC_OP_ACTIVATE, SC_AC_OP_DEACTIVATE, 0xFF, SC_AC_OP_UPDATE, SC_AC_OP_READ
  ------------------
  |  |  168|  1.49k|#define SC_AC_OP_DELETE			2
  ------------------
              		SC_AC_OP_DELETE, 0xFF, SC_AC_OP_ACTIVATE, SC_AC_OP_DEACTIVATE, 0xFF, SC_AC_OP_UPDATE, SC_AC_OP_READ
  ------------------
  |  |  186|  1.49k|#define SC_AC_OP_ACTIVATE		20
  ------------------
              		SC_AC_OP_DELETE, 0xFF, SC_AC_OP_ACTIVATE, SC_AC_OP_DEACTIVATE, 0xFF, SC_AC_OP_UPDATE, SC_AC_OP_READ
  ------------------
  |  |  187|  1.49k|#define SC_AC_OP_DEACTIVATE		21
  ------------------
              		SC_AC_OP_DELETE, 0xFF, SC_AC_OP_ACTIVATE, SC_AC_OP_DEACTIVATE, 0xFF, SC_AC_OP_UPDATE, SC_AC_OP_READ
  ------------------
  |  |  189|  1.49k|#define SC_AC_OP_UPDATE			23
  ------------------
              		SC_AC_OP_DELETE, 0xFF, SC_AC_OP_ACTIVATE, SC_AC_OP_DEACTIVATE, 0xFF, SC_AC_OP_UPDATE, SC_AC_OP_READ
  ------------------
  |  |  188|  1.49k|#define SC_AC_OP_READ			22
  ------------------
 1109|  1.49k|	};
 1110|       |
 1111|  1.49k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  1.49k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.49k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.49k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.49k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.49k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1112|       |
 1113|  1.49k|	tag = sc_asn1_find_tag(ctx,  buf, buflen, 0x6F, &taglen);
 1114|  1.49k|	sc_log(ctx, "processing FCI: 0x6F tag %p", tag);
  ------------------
  |  |   71|  1.49k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1115|  1.49k|	if (tag != NULL) {
  ------------------
  |  Branch (1115:6): [True: 1.30k, False: 196]
  ------------------
 1116|  1.30k|		sc_log(ctx, "  FCP length %zu", taglen);
  ------------------
  |  |   71|  1.30k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1117|  1.30k|		buf = tag;
 1118|  1.30k|		buflen = taglen;
 1119|  1.30k|	}
 1120|       |
 1121|  1.49k|	tag = sc_asn1_find_tag(ctx,  buf, buflen, 0x62, &taglen);
 1122|  1.49k|	sc_log(ctx, "processing FCI: 0x62 tag %p", tag);
  ------------------
  |  |   71|  1.49k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1123|  1.49k|	if (tag != NULL) {
  ------------------
  |  Branch (1123:6): [True: 151, False: 1.34k]
  ------------------
 1124|    151|		sc_log(ctx, "  FCP length %zu", taglen);
  ------------------
  |  |   71|    151|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1125|    151|		buf = tag;
 1126|    151|		buflen = taglen;
 1127|    151|	}
 1128|       |
 1129|  1.49k|	rv = iso_ops->process_fci(card, file, buf, buflen);
 1130|  1.49k|	LOG_TEST_RET(ctx, rv, "ISO parse FCI 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: 0, False: 1.49k]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#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.49k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.49k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1131|       |/*
 1132|       |	Gemalto:  6F 19 80 02 02 ED 82 01 01 83 02 B0 01 88 00	8C 07 7B 17 17 17 17 17 00 8A 01 05 90 00
 1133|       |	Sagem:    6F 17 62 15 80 02 00 7D 82 01 01                   8C 02 01 00 83 02 2F 00 88 01 F0 8A 01 05 90 00
 1134|       |	Oberthur: 62 1B 80 02 05 DC 82 01 01 83 02 B0 01 88 00 A1 09 8C 07 7B 17 FF 17 17 17 00 8A 01 05 90 00
 1135|       |*/
 1136|       |
 1137|  1.49k|	sc_log(ctx, "iasecc_process_fci() type %i; let's parse file ACLs", file->type);
  ------------------
  |  |   71|  1.49k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1138|  1.49k|	tag = sc_asn1_find_tag(ctx, buf, buflen, IASECC_DOCP_TAG_ACLS, &taglen);
  ------------------
  |  |   39|  1.49k|#define IASECC_DOCP_TAG_ACLS			0xA1
  ------------------
 1139|  1.49k|	if (tag)
  ------------------
  |  Branch (1139:6): [True: 114, False: 1.38k]
  ------------------
 1140|    114|		acls = sc_asn1_find_tag(ctx, tag, taglen, IASECC_DOCP_TAG_ACLS_CONTACT, &taglen);
  ------------------
  |  |   40|    114|#define IASECC_DOCP_TAG_ACLS_CONTACT		0x8C
  ------------------
 1141|  1.38k|	else
 1142|  1.38k|		acls = sc_asn1_find_tag(ctx, buf, buflen, IASECC_DOCP_TAG_ACLS_CONTACT, &taglen);
  ------------------
  |  |   40|  1.38k|#define IASECC_DOCP_TAG_ACLS_CONTACT		0x8C
  ------------------
 1143|       |
 1144|  1.49k|	if (!acls)   {
  ------------------
  |  Branch (1144:6): [True: 268, False: 1.23k]
  ------------------
 1145|    268|		sc_log(ctx, "ACLs not found in data(%zu) %s", buflen, sc_dump_hex(buf, buflen));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1146|    268|		LOG_TEST_RET(ctx, SC_ERROR_OBJECT_NOT_FOUND, "ACLs tag missing");
  ------------------
  |  |  174|    268|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    268|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    268|	int _ret = (r); \
  |  |  |  |  168|    268|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 268, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    268|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    268|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    268|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    268|		return _ret; \
  |  |  |  |  172|    268|	} \
  |  |  |  |  173|    268|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1147|    268|	}
 1148|       |
 1149|  1.23k|	sc_log(ctx, "ACLs(%zu) '%s'", taglen, sc_dump_hex(acls, taglen));
  ------------------
  |  |   71|  1.23k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1150|  1.23k|	mask = 0x40, offs = 1;
 1151|  9.32k|	for (ii = 0; ii < 7; ii++, mask /= 2)  {
  ------------------
  |  Branch (1151:15): [True: 8.37k, False: 945]
  ------------------
 1152|  8.37k|		unsigned char op = file->type == SC_FILE_TYPE_DF ? ops_DF[ii] : ops_EF[ii];
  ------------------
  |  |  214|  8.37k|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (1152:22): [True: 1.16k, False: 7.21k]
  ------------------
 1153|       |
 1154|       |		/* avoid any access to acls[offs] beyond the taglen */
 1155|  8.37k|		if (offs >= taglen) {
  ------------------
  |  Branch (1155:7): [True: 286, False: 8.08k]
  ------------------
 1156|    286|			sc_log(ctx, "Warning: Invalid offset reached during ACL parsing");
  ------------------
  |  |   71|    286|#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|    286|			break;
 1158|    286|		}
 1159|  8.08k|		if (!(mask & acls[0]))
  ------------------
  |  Branch (1159:7): [True: 3.69k, False: 4.39k]
  ------------------
 1160|  3.69k|			continue;
 1161|       |
 1162|  4.39k|		sc_log(ctx, "ACLs mask 0x%X, offs %zu, op 0x%X, acls[offs] 0x%X", mask, offs, op, acls[offs]);
  ------------------
  |  |   71|  4.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__
  |  |  ------------------
  ------------------
 1163|  4.39k|		if (op == 0xFF)   {
  ------------------
  |  Branch (1163:7): [True: 1.28k, False: 3.11k]
  ------------------
 1164|  1.28k|			;
 1165|  1.28k|		}
 1166|  3.11k|		else if (acls[offs] == 0)   {
  ------------------
  |  Branch (1166:12): [True: 947, False: 2.16k]
  ------------------
 1167|    947|			sc_file_add_acl_entry(file, op, SC_AC_NONE, 0);
  ------------------
  |  |  150|    947|#define SC_AC_NONE			0x00000000
  ------------------
 1168|    947|		}
 1169|  2.16k|		else if (acls[offs] == 0xFF)   {
  ------------------
  |  Branch (1169:12): [True: 179, False: 1.98k]
  ------------------
 1170|    179|			sc_file_add_acl_entry(file, op, SC_AC_NEVER, 0);
  ------------------
  |  |  163|    179|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
 1171|    179|		}
 1172|  1.98k|		else if ((acls[offs] & IASECC_SCB_METHOD_MASK) == IASECC_SCB_METHOD_USER_AUTH)   {
  ------------------
  |  |   89|  1.98k|#define IASECC_SCB_METHOD_MASK		0x70
  ------------------
              		else if ((acls[offs] & IASECC_SCB_METHOD_MASK) == IASECC_SCB_METHOD_USER_AUTH)   {
  ------------------
  |  |   93|  1.98k|#define IASECC_SCB_METHOD_USER_AUTH	0x10
  ------------------
  |  Branch (1172:12): [True: 109, False: 1.87k]
  ------------------
 1173|    109|			sc_file_add_acl_entry(file, op, SC_AC_SEN, acls[offs] & IASECC_SCB_METHOD_MASK_REF);
  ------------------
  |  |  156|    109|#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|    109|#define IASECC_SCB_METHOD_MASK_REF	0x0F
  ------------------
 1174|    109|		}
 1175|  1.87k|		else if (acls[offs] & IASECC_SCB_METHOD_MASK)   {
  ------------------
  |  |   89|  1.87k|#define IASECC_SCB_METHOD_MASK		0x70
  ------------------
  |  Branch (1175:12): [True: 1.32k, False: 548]
  ------------------
 1176|  1.32k|			sc_file_add_acl_entry(file, op, SC_AC_SCB, acls[offs]);
  ------------------
  |  |  157|  1.32k|#define SC_AC_SCB                       0x00000040 /* IAS/ECC SCB byte. */
  ------------------
 1177|  1.32k|		}
 1178|    548|		else   {
 1179|    548|			sc_log(ctx, "Warning: non supported SCB method: %X", acls[offs]);
  ------------------
  |  |   71|    548|#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|    548|			sc_file_add_acl_entry(file, op, SC_AC_NEVER, 0);
  ------------------
  |  |  163|    548|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
 1181|    548|		}
 1182|       |
 1183|  4.39k|		offs++;
 1184|  4.39k|	}
 1185|       |
 1186|  1.23k|	LOG_FUNC_RETURN(ctx, 0);
  ------------------
  |  |  164|  1.23k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.23k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.23k|	int _ret = r; \
  |  |  |  |  155|  1.23k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.23k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.23k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 1.23k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.23k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.23k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|  1.23k|	return _ret; \
  |  |  |  |  163|  1.23k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1187|  1.23k|}
card-iasecc.c:iasecc_se_get_info_from_cache:
 1568|     74|{
 1569|     74|	struct iasecc_private_data *prv = (struct iasecc_private_data *)card->drv_data;
 1570|     74|	struct sc_context *ctx = card->ctx;
 1571|     74|	struct iasecc_se_info *si = NULL;
 1572|     74|	int rv;
 1573|       |
 1574|     74|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     74|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     74|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     74|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     74|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 74]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1575|       |
 1576|     74|	for(si = prv->se_info; si; si = si->next)   {
  ------------------
  |  Branch (1576:25): [True: 0, False: 74]
  ------------------
 1577|      0|		if (si->reference != se->reference)
  ------------------
  |  Branch (1577:7): [True: 0, False: 0]
  ------------------
 1578|      0|			continue;
 1579|      0|		if (!(prv->cache.valid && prv->cache.current_df) && si->df)
  ------------------
  |  Branch (1579:9): [True: 0, False: 0]
  |  Branch (1579:29): [True: 0, False: 0]
  |  Branch (1579:55): [True: 0, False: 0]
  ------------------
 1580|      0|			continue;
 1581|      0|		if (prv->cache.valid && prv->cache.current_df && !si->df)
  ------------------
  |  Branch (1581:7): [True: 0, False: 0]
  |  Branch (1581:27): [True: 0, False: 0]
  |  Branch (1581:52): [True: 0, False: 0]
  ------------------
 1582|      0|			continue;
 1583|      0|		if (prv->cache.valid && prv->cache.current_df && si->df)
  ------------------
  |  Branch (1583:7): [True: 0, False: 0]
  |  Branch (1583:27): [True: 0, False: 0]
  |  Branch (1583:52): [True: 0, False: 0]
  ------------------
 1584|      0|			if (memcmp(&prv->cache.current_df->path, &si->df->path, sizeof(struct sc_path)))
  ------------------
  |  Branch (1584:8): [True: 0, False: 0]
  ------------------
 1585|      0|				continue;
 1586|      0|		break;
 1587|      0|	}
 1588|       |
 1589|     74|	if (!si)
  ------------------
  |  Branch (1589:6): [True: 74, False: 0]
  ------------------
 1590|     74|		return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|     74|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
 1591|       |
 1592|      0|	memcpy(se, si, sizeof(struct iasecc_se_info));
 1593|       |
 1594|      0|	if (si->df)   {
  ------------------
  |  Branch (1594:6): [True: 0, False: 0]
  ------------------
 1595|      0|		sc_file_dup(&se->df, si->df);
 1596|      0|		if (se->df == NULL)
  ------------------
  |  Branch (1596:7): [True: 0, False: 0]
  ------------------
 1597|      0|			LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "Cannot duplicate current DF file");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1598|      0|	}
 1599|       |
 1600|      0|	rv = iasecc_docp_copy(ctx, &si->docp, &se->docp);
 1601|      0|	LOG_TEST_RET(ctx, rv, "Cannot make copy of DOCP");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1602|       |
 1603|      0|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1604|      0|}
card-iasecc.c:iasecc_se_cache_info:
 1525|     10|{
 1526|     10|	struct iasecc_private_data *prv = (struct iasecc_private_data *)card->drv_data;
 1527|     10|	struct sc_context *ctx = card->ctx;
 1528|     10|	struct iasecc_se_info *se_info = NULL, *si = NULL;
 1529|     10|	int rv;
 1530|       |
 1531|     10|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     10|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     10|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     10|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     10|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1532|       |
 1533|     10|	se_info = calloc(1, sizeof(struct iasecc_se_info));
 1534|     10|	if (!se_info)
  ------------------
  |  Branch (1534:6): [True: 0, False: 10]
  ------------------
 1535|     10|		LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "SE info allocation error");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1536|     10|	memcpy(se_info, se, sizeof(struct iasecc_se_info));
 1537|       |
 1538|     10|	if (prv->cache.valid && prv->cache.current_df) {
  ------------------
  |  Branch (1538:6): [True: 10, False: 0]
  |  Branch (1538:26): [True: 1, False: 9]
  ------------------
 1539|      1|		sc_file_dup(&se_info->df, prv->cache.current_df);
 1540|      1|		if (se_info->df == NULL)   {
  ------------------
  |  Branch (1540:7): [True: 0, False: 1]
  ------------------
 1541|      0|			free(se_info);
 1542|      0|			LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "Cannot duplicate current DF file");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1543|      0|		}
 1544|      1|	}
 1545|       |
 1546|     10|	rv = iasecc_docp_copy(ctx, &se->docp, &se_info->docp);
 1547|     10|	if (rv < 0)   {
  ------------------
  |  Branch (1547:6): [True: 0, False: 10]
  ------------------
 1548|      0|		free(se_info->df);
 1549|      0|		free(se_info);
 1550|      0|		LOG_TEST_RET(ctx, rv, "Cannot make copy of DOCP");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1551|      0|	}
 1552|       |
 1553|     10|	if (!prv->se_info)   {
  ------------------
  |  Branch (1553:6): [True: 10, False: 0]
  ------------------
 1554|     10|		prv->se_info = se_info;
 1555|     10|	}
 1556|      0|	else    {
 1557|      0|		for (si = prv->se_info; si->next; si = si->next)
  ------------------
  |  Branch (1557:27): [True: 0, False: 0]
  ------------------
 1558|      0|			;
 1559|      0|		si->next = se_info;
 1560|      0|	}
 1561|       |
 1562|     10|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1563|     10|}
card-iasecc.c:sc_get_driver:
 3591|  16.3k|{
 3592|  16.3k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 3593|       |
 3594|  16.3k|	if (!iso_ops)
  ------------------
  |  Branch (3594:6): [True: 1, False: 16.3k]
  ------------------
 3595|      1|		iso_ops = iso_drv->ops;
 3596|       |
 3597|  16.3k|	iasecc_ops = *iso_ops;
 3598|       |
 3599|  16.3k|	iasecc_ops.match_card = iasecc_match_card;
 3600|  16.3k|	iasecc_ops.init = iasecc_init;
 3601|  16.3k|	iasecc_ops.finish = iasecc_finish;
 3602|  16.3k|	iasecc_ops.read_binary = iasecc_read_binary;
 3603|       |	/*	write_binary: ISO7816 implementation works	*/
 3604|       |	/*	update_binary: ISO7816 implementation works	*/
 3605|  16.3k|	iasecc_ops.erase_binary = iasecc_erase_binary;
 3606|       |	/*	resize_binary	*/
 3607|       |	/* 	read_record: Untested	*/
 3608|       |	/*	write_record: Untested	*/
 3609|       |	/*	append_record: Untested	*/
 3610|       |	/*	update_record: Untested	*/
 3611|  16.3k|	iasecc_ops.select_file = iasecc_select_file;
 3612|       |	/*	get_response: Untested	*/
 3613|  16.3k|	iasecc_ops.get_challenge = iasecc_get_challenge;
 3614|  16.3k|	iasecc_ops.logout = iasecc_logout;
 3615|       |	/*	restore_security_env	*/
 3616|  16.3k|	iasecc_ops.set_security_env = iasecc_set_security_env;
 3617|  16.3k|	iasecc_ops.decipher = iasecc_decipher;
 3618|  16.3k|	iasecc_ops.compute_signature = iasecc_compute_signature;
 3619|  16.3k|	iasecc_ops.create_file = iasecc_create_file;
 3620|  16.3k|	iasecc_ops.delete_file = iasecc_delete_file;
 3621|       |	/*	list_files	*/
 3622|  16.3k|	iasecc_ops.check_sw = iasecc_check_sw;
 3623|  16.3k|	iasecc_ops.card_ctl = iasecc_card_ctl;
 3624|  16.3k|	iasecc_ops.process_fci = iasecc_process_fci;
 3625|       |	/*	construct_fci: Not needed	*/
 3626|  16.3k|	iasecc_ops.pin_cmd = iasecc_pin_cmd;
 3627|       |	/*	get_data: Not implemented	*/
 3628|       |	/*	put_data: Not implemented	*/
 3629|       |	/*	delete_record: Not implemented	*/
 3630|       |
 3631|  16.3k|	iasecc_ops.read_public_key = iasecc_read_public_key;
 3632|       |
 3633|  16.3k|	return &iasecc_drv;
 3634|  16.3k|}
card-iasecc.c:iasecc_match_card:
  353|  12.8k|{
  354|  12.8k|	struct sc_context *ctx = card->ctx;
  355|  12.8k|	int i;
  356|       |
  357|  12.8k|	i = _sc_match_atr(card, iasecc_known_atrs, &card->type);
  358|  12.8k|	if (i < 0)   {
  ------------------
  |  Branch (358:6): [True: 12.0k, False: 744]
  ------------------
  359|  12.0k|		sc_log(ctx, "card not matched");
  ------------------
  |  |   71|  12.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__
  |  |  ------------------
  ------------------
  360|  12.0k|		return 0;
  361|  12.0k|	}
  362|       |
  363|    744|	sc_log(ctx, "'%s' card matched", iasecc_known_atrs[i].name);
  ------------------
  |  |   71|    744|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  364|    744|	return 1;
  365|  12.8k|}
card-iasecc.c:iasecc_init:
  624|    744|{
  625|    744|	struct sc_context *ctx = card->ctx;
  626|    744|	struct iasecc_private_data *private_data = NULL;
  627|    744|	int rv = SC_ERROR_NO_CARD_SUPPORT;
  ------------------
  |  |   58|    744|#define SC_ERROR_NO_CARD_SUPPORT		-1208
  ------------------
  628|    744|	void *old_drv_data = card->drv_data;
  629|       |
  630|    744|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    744|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    744|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    744|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    744|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 744]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  631|    744|	private_data = (struct iasecc_private_data *) calloc(1, sizeof(struct iasecc_private_data));
  632|    744|	if (private_data == NULL)
  ------------------
  |  Branch (632:6): [True: 0, False: 744]
  ------------------
  633|    744|		LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  634|       |
  635|    744|	card->cla  = 0x00;
  636|    744|	card->drv_data = private_data;
  637|       |
  638|    744|	if (card->type == SC_CARD_TYPE_IASECC_GEMALTO)
  ------------------
  |  Branch (638:6): [True: 225, False: 519]
  ------------------
  639|    225|		rv = iasecc_init_gemalto(card);
  640|    519|	else if (card->type == SC_CARD_TYPE_IASECC_OBERTHUR)
  ------------------
  |  Branch (640:11): [True: 172, False: 347]
  ------------------
  641|    172|		rv = iasecc_init_oberthur(card);
  642|    347|	else if (card->type == SC_CARD_TYPE_IASECC_SAGEM)
  ------------------
  |  Branch (642:11): [True: 249, False: 98]
  ------------------
  643|    249|		rv = iasecc_init_amos_or_sagem(card);
  644|     98|	else if (card->type == SC_CARD_TYPE_IASECC_AMOS)
  ------------------
  |  Branch (644:11): [True: 0, False: 98]
  ------------------
  645|      0|		rv = iasecc_init_amos_or_sagem(card);
  646|     98|	else if (card->type == SC_CARD_TYPE_IASECC_MI)
  ------------------
  |  Branch (646:11): [True: 0, False: 98]
  ------------------
  647|      0|		rv = iasecc_init_amos_or_sagem(card);
  648|     98|	else if (iasecc_is_cpx(card))
  ------------------
  |  Branch (648:11): [True: 98, False: 0]
  ------------------
  649|     98|		rv = iasecc_init_cpx(card);
  650|      0|	else {
  651|      0|		LOG_TEST_GOTO_ERR(ctx, SC_ERROR_INVALID_CARD, "");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  652|      0|	}
  653|       |
  654|       |
  655|    744|	if (!rv)   {
  ------------------
  |  Branch (655:6): [True: 474, False: 270]
  ------------------
  656|    474|		if (card->ef_atr && card->ef_atr->aid.len)   {
  ------------------
  |  Branch (656:7): [True: 474, False: 0]
  |  Branch (656:23): [True: 30, False: 444]
  ------------------
  657|     30|			struct sc_path path;
  658|       |
  659|     30|			memset(&path, 0, sizeof(struct sc_path));
  660|     30|			path.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|     30|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  661|     30|			memcpy(path.value, card->ef_atr->aid.value, card->ef_atr->aid.len);
  662|     30|			path.len = card->ef_atr->aid.len;
  663|       |
  664|     30|			rv = iasecc_select_file(card, &path, NULL);
  665|     30|			sc_log(ctx, "Select ECC ROOT with the AID from EF.ATR: rv %i", rv);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  666|     30|			LOG_TEST_GOTO_ERR(ctx, rv, "Select EF.ATR AID failed");
  ------------------
  |  |  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: 5, False: 25]
  |  |  |  |  ------------------
  |  |  |  |  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|     30|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 25]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  667|     30|		}
  668|       |
  669|    469|		iasecc_get_serialnr(card, NULL);
  670|    469|	}
  671|       |
  672|    739|#ifdef ENABLE_SM
  673|    739|	card->sm_ctx.ops.read_binary = _iasecc_sm_read_binary;
  674|    739|	card->sm_ctx.ops.update_binary = _iasecc_sm_update_binary;
  675|    739|#endif
  676|       |
  677|    739|	if (!rv && card->ef_atr && card->ef_atr->aid.len)   {
  ------------------
  |  Branch (677:6): [True: 469, False: 270]
  |  Branch (677:13): [True: 469, False: 0]
  |  Branch (677:29): [True: 25, False: 444]
  ------------------
  678|     25|		sc_log(ctx, "EF.ATR(aid:'%s')", sc_dump_hex(card->ef_atr->aid.value, card->ef_atr->aid.len));
  ------------------
  |  |   71|     25|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  679|     25|	}
  680|       |
  681|    744|err:
  682|    744|	if (rv < 0) {
  ------------------
  |  Branch (682:6): [True: 275, False: 469]
  ------------------
  683|    275|		sc_invalidate_cache(card);
  684|    275|		free(private_data);
  685|    275|		card->drv_data = old_drv_data;
  686|    469|	} else {
  687|    469|		free(old_drv_data);
  688|    469|	}
  689|       |
  690|    744|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    744|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    744|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    744|	int _ret = r; \
  |  |  |  |  155|    744|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 744, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    744|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    275|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 275, False: 469]
  |  |  |  |  ------------------
  |  |  |  |  157|    744|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    744|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    744|	return _ret; \
  |  |  |  |  163|    744|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  691|    744|}
card-iasecc.c:iasecc_init_gemalto:
  419|    225|{
  420|    225|	struct sc_context *ctx = card->ctx;
  421|    225|	struct sc_path path;
  422|    225|	unsigned int flags;
  423|    225|	int rv = 0;
  424|       |
  425|    225|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    225|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    225|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    225|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    225|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 225]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  426|       |
  427|    225|	flags = IASECC_CARD_DEFAULT_FLAGS;
  ------------------
  |  |   53|    225|#define IASECC_CARD_DEFAULT_FLAGS ( 0			\
  |  |   54|    225|		| SC_ALGORITHM_ONBOARD_KEY_GEN		\
  |  |  ------------------
  |  |  |  |   93|    225|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  |  |  ------------------
  |  |   55|    225|		| SC_ALGORITHM_RSA_PAD_ISO9796		\
  |  |  ------------------
  |  |  |  |  106|    225|#define SC_ALGORITHM_RSA_PAD_ISO9796	0x00000008
  |  |  ------------------
  |  |   56|    225|		| SC_ALGORITHM_RSA_PAD_PKCS1		\
  |  |  ------------------
  |  |  |  |  111|    225|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|    225|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  |  |  ------------------
  |  |  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|    225|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   57|    225|		| SC_ALGORITHM_RSA_HASH_NONE		\
  |  |  ------------------
  |  |  |  |  133|    225|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  |  |   58|    225|		| SC_ALGORITHM_RSA_HASH_SHA1		\
  |  |  ------------------
  |  |  |  |  134|    225|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  ------------------
  |  |   59|    225|		| SC_ALGORITHM_RSA_HASH_SHA256)
  |  |  ------------------
  |  |  |  |  138|    225|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  |  |  ------------------
  ------------------
  428|       |
  429|    225|	card->caps = IASECC_CARD_DEFAULT_CAPS;
  ------------------
  |  |   61|    225|#define IASECC_CARD_DEFAULT_CAPS ( 0 			\
  |  |   62|    225|		| SC_CARD_CAP_RNG			\
  |  |  ------------------
  |  |  |  |  550|    225|#define SC_CARD_CAP_RNG			0x00000004
  |  |  ------------------
  |  |   63|    225|		| SC_CARD_CAP_APDU_EXT			\
  |  |  ------------------
  |  |  |  |  547|    225|#define SC_CARD_CAP_APDU_EXT		0x00000001
  |  |  ------------------
  |  |   64|    225|		| SC_CARD_CAP_USE_FCI_AC		\
  |  |  ------------------
  |  |  |  |  557|    225|#define SC_CARD_CAP_USE_FCI_AC		0x00000010
  |  |  ------------------
  |  |   65|    225|		| SC_CARD_CAP_ISO7816_PIN_INFO)
  |  |  ------------------
  |  |  |  |  553|    225|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  |  |  ------------------
  ------------------
  430|       |
  431|    225|	sc_format_path("3F00", &path);
  432|    225|	if (SC_SUCCESS != sc_select_file(card, &path, NULL)) {
  ------------------
  |  |   28|    225|#define SC_SUCCESS				0
  ------------------
  |  Branch (432:6): [True: 211, False: 14]
  ------------------
  433|       |		/* Result ignored*/
  434|    211|		sc_log(card->ctx, "Warning, MF select failed");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  435|    211|	}
  436|       |
  437|    225|	rv = iasecc_parse_ef_atr(card);
  438|    225|	sc_log(ctx, "rv %i", rv);
  ------------------
  |  |   71|    225|#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|    225|	if (rv == SC_ERROR_FILE_NOT_FOUND)   {
  ------------------
  |  |   51|    225|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (439:6): [True: 5, False: 220]
  ------------------
  440|      5|		sc_log(ctx, "Select MF");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  441|      5|		rv = iasecc_select_mf(card, NULL);
  442|      5|		sc_log(ctx, "rv %i", rv);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  443|      5|		LOG_TEST_RET(ctx, rv, "MF selection 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: 3, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  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|      5|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  444|       |
  445|      2|		rv = iasecc_parse_ef_atr(card);
  446|      2|		sc_log(ctx, "rv %i", rv);
  ------------------
  |  |   71|      2|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  447|      2|	}
  448|    222|	sc_log(ctx, "rv %i", rv);
  ------------------
  |  |   71|    222|#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|    222|	LOG_TEST_RET(ctx, rv, "Cannot read/parse EF.ATR");
  ------------------
  |  |  174|    222|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    222|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    222|	int _ret = (r); \
  |  |  |  |  168|    222|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 38, False: 184]
  |  |  |  |  ------------------
  |  |  |  |  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|    222|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 184]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  450|       |
  451|    184|	_sc_card_add_rsa_alg(card, 1024, flags, 0x10001);
  452|    184|	_sc_card_add_rsa_alg(card, 2048, flags, 0x10001);
  453|       |
  454|    184|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    184|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    184|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    184|	int _ret = r; \
  |  |  |  |  155|    184|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 184, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    184|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 184]
  |  |  |  |  ------------------
  |  |  |  |  157|    184|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    184|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    184|	return _ret; \
  |  |  |  |  163|    184|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  455|    184|}
card-iasecc.c:iasecc_parse_ef_atr:
  369|    864|{
  370|    864|	struct sc_context *ctx = card->ctx;
  371|    864|	struct iasecc_private_data *pdata = (struct iasecc_private_data *) card->drv_data;
  372|    864|	struct iasecc_version *version = &pdata->version;
  373|    864|	struct iasecc_io_buffer_sizes *sizes = &pdata->max_sizes;
  374|    864|	int rv;
  375|       |
  376|    864|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    864|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    864|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    864|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    864|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 864]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  377|    864|	rv = sc_parse_ef_atr(card);
  378|    864|	LOG_TEST_RET(ctx, rv, "MF selection error");
  ------------------
  |  |  174|    864|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    864|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    864|	int _ret = (r); \
  |  |  |  |  168|    864|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 297, False: 567]
  |  |  |  |  ------------------
  |  |  |  |  169|    297|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    297|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    297|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    297|		return _ret; \
  |  |  |  |  172|    297|	} \
  |  |  |  |  173|    864|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 567]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  379|       |
  380|    567|	if (card->ef_atr->pre_issuing_len < 4)
  ------------------
  |  Branch (380:6): [True: 73, False: 494]
  ------------------
  381|    567|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid pre-issuing data");
  ------------------
  |  |  174|     73|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     73|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     73|	int _ret = (r); \
  |  |  |  |  168|     73|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 73, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     73|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     73|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     73|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     73|		return _ret; \
  |  |  |  |  172|     73|	} \
  |  |  |  |  173|     73|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  382|       |
  383|    494|	version->ic_manufacturer =	card->ef_atr->pre_issuing[0];
  384|    494|	version->ic_type =		card->ef_atr->pre_issuing[1];
  385|    494|	version->os_version =		card->ef_atr->pre_issuing[2];
  386|    494|	version->iasecc_version =	card->ef_atr->pre_issuing[3];
  387|    494|	sc_log(ctx, "EF.ATR: IC manufacturer/type %X/%X, OS/IasEcc versions %X/%X",
  ------------------
  |  |   71|    494|#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|    494|		version->ic_manufacturer, version->ic_type, version->os_version, version->iasecc_version);
  389|       |
  390|    494|	if (card->ef_atr->issuer_data_len < 16)
  ------------------
  |  Branch (390:6): [True: 19, False: 475]
  ------------------
  391|    494|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid issuer data");
  ------------------
  |  |  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: 19, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|     19|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  392|       |
  393|    475|	sizes->send =	 card->ef_atr->issuer_data[2] * 0x100 + card->ef_atr->issuer_data[3];
  394|    475|	sizes->send_sc = card->ef_atr->issuer_data[6] * 0x100 + card->ef_atr->issuer_data[7];
  395|    475|	sizes->recv =	 card->ef_atr->issuer_data[10] * 0x100 + card->ef_atr->issuer_data[11];
  396|    475|	sizes->recv_sc = card->ef_atr->issuer_data[14] * 0x100 + card->ef_atr->issuer_data[15];
  397|       |
  398|    475|	sc_log(ctx, "EF.ATR: IO Buffer Size send/sc %zd/%zd recv/sc %zd/%zd",
  ------------------
  |  |   71|    475|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  399|    475|			sizes->send, sizes->send_sc, sizes->recv, sizes->recv_sc);
  400|       |
  401|    475|	card->max_send_size = sizes->send;
  402|    475|	card->max_recv_size = sizes->recv;
  403|       |
  404|       |	/* Most of the card producers interpret 'send' values as "maximum APDU data size".
  405|       |	 * Oberthur strictly follows specification and interpret these values as "maximum APDU command size".
  406|       |	 * Here we need 'data size'.
  407|       |	 */
  408|    475|	if (card->max_send_size > 0xFF)
  ------------------
  |  Branch (408:6): [True: 170, False: 305]
  ------------------
  409|    170|		card->max_send_size -= 5;
  410|       |
  411|    475|	sc_log(ctx, "EF.ATR: max send/recv sizes %zX/%zX", card->max_send_size, card->max_recv_size);
  ------------------
  |  |   71|    475|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  412|       |
  413|    475|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    475|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    475|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    475|	int _ret = r; \
  |  |  |  |  155|    475|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 475, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    475|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 475]
  |  |  |  |  ------------------
  |  |  |  |  157|    475|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    475|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    475|	return _ret; \
  |  |  |  |  163|    475|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  414|    475|}
card-iasecc.c:iasecc_init_oberthur:
  488|    172|{
  489|    172|	struct sc_context *ctx = card->ctx;
  490|    172|	unsigned int flags;
  491|    172|	int rv = 0;
  492|       |
  493|    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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  494|       |
  495|    172|	flags = IASECC_CARD_DEFAULT_FLAGS;
  ------------------
  |  |   53|    172|#define IASECC_CARD_DEFAULT_FLAGS ( 0			\
  |  |   54|    172|		| SC_ALGORITHM_ONBOARD_KEY_GEN		\
  |  |  ------------------
  |  |  |  |   93|    172|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  |  |  ------------------
  |  |   55|    172|		| SC_ALGORITHM_RSA_PAD_ISO9796		\
  |  |  ------------------
  |  |  |  |  106|    172|#define SC_ALGORITHM_RSA_PAD_ISO9796	0x00000008
  |  |  ------------------
  |  |   56|    172|		| SC_ALGORITHM_RSA_PAD_PKCS1		\
  |  |  ------------------
  |  |  |  |  111|    172|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|    172|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  |  |  ------------------
  |  |  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|    172|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   57|    172|		| SC_ALGORITHM_RSA_HASH_NONE		\
  |  |  ------------------
  |  |  |  |  133|    172|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  |  |   58|    172|		| SC_ALGORITHM_RSA_HASH_SHA1		\
  |  |  ------------------
  |  |  |  |  134|    172|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  ------------------
  |  |   59|    172|		| SC_ALGORITHM_RSA_HASH_SHA256)
  |  |  ------------------
  |  |  |  |  138|    172|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  |  |  ------------------
  ------------------
  496|       |
  497|    172|	_sc_card_add_rsa_alg(card, 1024, flags, 0x10001);
  498|    172|	_sc_card_add_rsa_alg(card, 2048, flags, 0x10001);
  499|       |
  500|    172|	card->caps = IASECC_CARD_DEFAULT_CAPS;
  ------------------
  |  |   61|    172|#define IASECC_CARD_DEFAULT_CAPS ( 0 			\
  |  |   62|    172|		| SC_CARD_CAP_RNG			\
  |  |  ------------------
  |  |  |  |  550|    172|#define SC_CARD_CAP_RNG			0x00000004
  |  |  ------------------
  |  |   63|    172|		| SC_CARD_CAP_APDU_EXT			\
  |  |  ------------------
  |  |  |  |  547|    172|#define SC_CARD_CAP_APDU_EXT		0x00000001
  |  |  ------------------
  |  |   64|    172|		| SC_CARD_CAP_USE_FCI_AC		\
  |  |  ------------------
  |  |  |  |  557|    172|#define SC_CARD_CAP_USE_FCI_AC		0x00000010
  |  |  ------------------
  |  |   65|    172|		| SC_CARD_CAP_ISO7816_PIN_INFO)
  |  |  ------------------
  |  |  |  |  553|    172|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  |  |  ------------------
  ------------------
  501|       |
  502|    172|	iasecc_parse_ef_atr(card);
  503|       |
  504|       |	/* if we fail to select CM, */
  505|    172|	if (gp_select_card_manager(card)) {
  ------------------
  |  Branch (505:6): [True: 63, False: 109]
  ------------------
  506|     63|		gp_select_isd_rid(card);
  507|     63|	}
  508|       |
  509|    172|	rv = iasecc_oberthur_match(card);
  510|    172|	LOG_TEST_RET(ctx, rv, "unknown Oberthur's IAS/ECC card");
  ------------------
  |  |  174|    172|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    172|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    172|	int _ret = (r); \
  |  |  |  |  168|    172|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 172]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|    172|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 172]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  511|       |
  512|    172|	rv = iasecc_select_mf(card, NULL);
  513|    172|	LOG_TEST_RET(ctx, rv, "MF selection error");
  ------------------
  |  |  174|    172|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    172|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    172|	int _ret = (r); \
  |  |  |  |  168|    172|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 57, False: 115]
  |  |  |  |  ------------------
  |  |  |  |  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|    172|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 115]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  514|       |
  515|    115|	rv = iasecc_parse_ef_atr(card);
  516|    115|	LOG_TEST_RET(ctx, rv, "EF.ATR read or parse error");
  ------------------
  |  |  174|    115|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    115|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    115|	int _ret = (r); \
  |  |  |  |  168|    115|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 36, False: 79]
  |  |  |  |  ------------------
  |  |  |  |  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|    115|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 79]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  517|       |
  518|     79|	sc_log(ctx, "EF.ATR(aid:'%s')", sc_dump_hex(card->ef_atr->aid.value, card->ef_atr->aid.len));
  ------------------
  |  |   71|     79|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  519|     79|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|     79|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     79|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     79|	int _ret = r; \
  |  |  |  |  155|     79|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 79, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     79|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 79]
  |  |  |  |  ------------------
  |  |  |  |  157|     79|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     79|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     79|	return _ret; \
  |  |  |  |  163|     79|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  520|     79|}
card-iasecc.c:iasecc_oberthur_match:
  460|    172|{
  461|    172|	struct sc_context *ctx = card->ctx;
  462|    172|	unsigned char *hist = card->reader->atr_info.hist_bytes;
  463|       |
  464|    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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  465|       |
  466|    172|	if (*hist != 0x80 || ((*(hist+1)&0xF0) != 0xF0))
  ------------------
  |  Branch (466:6): [True: 0, False: 172]
  |  Branch (466:23): [True: 0, False: 172]
  ------------------
  467|    172|		LOG_FUNC_RETURN(ctx, SC_ERROR_OBJECT_NOT_FOUND);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  468|       |
  469|    172|	sc_log_hex(ctx, "AID in historical_bytes", hist + 2, *(hist+1) & 0x0F);
  ------------------
  |  |  129|    172|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|    172|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  470|       |
  471|    172|	if (memcmp(hist + 2, OberthurIASECC_AID.value, *(hist+1) & 0x0F))
  ------------------
  |  Branch (471:6): [True: 0, False: 172]
  ------------------
  472|    172|		LOG_FUNC_RETURN(ctx, SC_ERROR_RECORD_NOT_FOUND);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  473|       |
  474|    172|	if (!card->ef_atr)
  ------------------
  |  Branch (474:6): [True: 134, False: 38]
  ------------------
  475|    134|		card->ef_atr = calloc(1, sizeof(struct sc_ef_atr));
  476|    172|	if (!card->ef_atr)
  ------------------
  |  Branch (476:6): [True: 0, False: 172]
  ------------------
  477|    172|		LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  478|       |
  479|    172|	memcpy(card->ef_atr->aid.value, OberthurIASECC_AID.value, OberthurIASECC_AID.len);
  480|    172|	card->ef_atr->aid.len = OberthurIASECC_AID.len;
  481|       |
  482|    172|	LOG_FUNC_RETURN(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  483|    172|}
card-iasecc.c:iasecc_init_amos_or_sagem:
  550|    249|{
  551|    249|	struct sc_context *ctx = card->ctx;
  552|    249|	unsigned int flags;
  553|    249|	int rv = 0;
  554|       |
  555|    249|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    249|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    249|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    249|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    249|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 249]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  556|       |
  557|    249|	flags = IASECC_CARD_DEFAULT_FLAGS;
  ------------------
  |  |   53|    249|#define IASECC_CARD_DEFAULT_FLAGS ( 0			\
  |  |   54|    249|		| SC_ALGORITHM_ONBOARD_KEY_GEN		\
  |  |  ------------------
  |  |  |  |   93|    249|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  |  |  ------------------
  |  |   55|    249|		| SC_ALGORITHM_RSA_PAD_ISO9796		\
  |  |  ------------------
  |  |  |  |  106|    249|#define SC_ALGORITHM_RSA_PAD_ISO9796	0x00000008
  |  |  ------------------
  |  |   56|    249|		| SC_ALGORITHM_RSA_PAD_PKCS1		\
  |  |  ------------------
  |  |  |  |  111|    249|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|    249|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  |  |  ------------------
  |  |  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|    249|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   57|    249|		| SC_ALGORITHM_RSA_HASH_NONE		\
  |  |  ------------------
  |  |  |  |  133|    249|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  |  |   58|    249|		| SC_ALGORITHM_RSA_HASH_SHA1		\
  |  |  ------------------
  |  |  |  |  134|    249|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  ------------------
  |  |   59|    249|		| SC_ALGORITHM_RSA_HASH_SHA256)
  |  |  ------------------
  |  |  |  |  138|    249|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  |  |  ------------------
  ------------------
  558|       |
  559|    249|	_sc_card_add_rsa_alg(card, 1024, flags, 0x10001);
  560|    249|	_sc_card_add_rsa_alg(card, 2048, flags, 0x10001);
  561|       |
  562|    249|	card->caps = IASECC_CARD_DEFAULT_CAPS;
  ------------------
  |  |   61|    249|#define IASECC_CARD_DEFAULT_CAPS ( 0 			\
  |  |   62|    249|		| SC_CARD_CAP_RNG			\
  |  |  ------------------
  |  |  |  |  550|    249|#define SC_CARD_CAP_RNG			0x00000004
  |  |  ------------------
  |  |   63|    249|		| SC_CARD_CAP_APDU_EXT			\
  |  |  ------------------
  |  |  |  |  547|    249|#define SC_CARD_CAP_APDU_EXT		0x00000001
  |  |  ------------------
  |  |   64|    249|		| SC_CARD_CAP_USE_FCI_AC		\
  |  |  ------------------
  |  |  |  |  557|    249|#define SC_CARD_CAP_USE_FCI_AC		0x00000010
  |  |  ------------------
  |  |   65|    249|		| SC_CARD_CAP_ISO7816_PIN_INFO)
  |  |  ------------------
  |  |  |  |  553|    249|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  |  |  ------------------
  ------------------
  563|       |
  564|    249|	if (card->type == SC_CARD_TYPE_IASECC_MI)   {
  ------------------
  |  Branch (564:6): [True: 0, False: 249]
  ------------------
  565|      0|		rv = iasecc_mi_match(card);
  566|      0|		if (rv)
  ------------------
  |  Branch (566:7): [True: 0, False: 0]
  ------------------
  567|      0|			card->type = SC_CARD_TYPE_IASECC_MI2;
  568|      0|		else
  569|      0|			LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  570|      0|	}
  571|       |
  572|    249|	rv = iasecc_parse_ef_atr(card);
  573|    249|	if (rv == SC_ERROR_FILE_NOT_FOUND)   {
  ------------------
  |  |   51|    249|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (573:6): [True: 5, False: 244]
  ------------------
  574|      5|		rv = iasecc_select_mf(card, NULL);
  575|      5|		LOG_TEST_RET(ctx, rv, "MF selection 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  576|       |
  577|      3|		rv = iasecc_parse_ef_atr(card);
  578|      3|	}
  579|    247|	LOG_TEST_RET(ctx, rv, "IASECC: ATR parse failed");
  ------------------
  |  |  174|    247|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    247|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    247|	int _ret = (r); \
  |  |  |  |  168|    247|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 58, False: 189]
  |  |  |  |  ------------------
  |  |  |  |  169|     58|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     58|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     58|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     58|		return _ret; \
  |  |  |  |  172|     58|	} \
  |  |  |  |  173|    247|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 189]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  580|       |
  581|    189|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    189|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    189|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    189|	int _ret = r; \
  |  |  |  |  155|    189|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 189, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    189|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 189]
  |  |  |  |  ------------------
  |  |  |  |  157|    189|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    189|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    189|	return _ret; \
  |  |  |  |  163|    189|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  582|    189|}
card-iasecc.c:iasecc_init_cpx:
  600|     98|{
  601|     98|	struct sc_context *ctx = card->ctx;
  602|     98|	unsigned int flags;
  603|     98|	int rv = 0;
  604|       |
  605|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  606|       |
  607|     98|	card->caps = IASECC_CARD_DEFAULT_CAPS;
  ------------------
  |  |   61|     98|#define IASECC_CARD_DEFAULT_CAPS ( 0 			\
  |  |   62|     98|		| SC_CARD_CAP_RNG			\
  |  |  ------------------
  |  |  |  |  550|     98|#define SC_CARD_CAP_RNG			0x00000004
  |  |  ------------------
  |  |   63|     98|		| SC_CARD_CAP_APDU_EXT			\
  |  |  ------------------
  |  |  |  |  547|     98|#define SC_CARD_CAP_APDU_EXT		0x00000001
  |  |  ------------------
  |  |   64|     98|		| SC_CARD_CAP_USE_FCI_AC		\
  |  |  ------------------
  |  |  |  |  557|     98|#define SC_CARD_CAP_USE_FCI_AC		0x00000010
  |  |  ------------------
  |  |   65|     98|		| SC_CARD_CAP_ISO7816_PIN_INFO)
  |  |  ------------------
  |  |  |  |  553|     98|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  |  |  ------------------
  ------------------
  608|       |
  609|     98|	flags = IASECC_CARD_DEFAULT_FLAGS;
  ------------------
  |  |   53|     98|#define IASECC_CARD_DEFAULT_FLAGS ( 0			\
  |  |   54|     98|		| SC_ALGORITHM_ONBOARD_KEY_GEN		\
  |  |  ------------------
  |  |  |  |   93|     98|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  |  |  ------------------
  |  |   55|     98|		| SC_ALGORITHM_RSA_PAD_ISO9796		\
  |  |  ------------------
  |  |  |  |  106|     98|#define SC_ALGORITHM_RSA_PAD_ISO9796	0x00000008
  |  |  ------------------
  |  |   56|     98|		| SC_ALGORITHM_RSA_PAD_PKCS1		\
  |  |  ------------------
  |  |  |  |  111|     98|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|     98|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  |  |  ------------------
  |  |  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|     98|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   57|     98|		| SC_ALGORITHM_RSA_HASH_NONE		\
  |  |  ------------------
  |  |  |  |  133|     98|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  |  |   58|     98|		| SC_ALGORITHM_RSA_HASH_SHA1		\
  |  |  ------------------
  |  |  |  |  134|     98|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  ------------------
  |  |   59|     98|		| SC_ALGORITHM_RSA_HASH_SHA256)
  |  |  ------------------
  |  |  |  |  138|     98|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  |  |  ------------------
  ------------------
  610|       |
  611|     98|	_sc_card_add_rsa_alg(card, 512, flags, 0);
  612|     98|	_sc_card_add_rsa_alg(card, 1024, flags, 0);
  613|     98|	_sc_card_add_rsa_alg(card, 2048, flags, 0);
  614|       |
  615|     98|	rv = iasecc_parse_ef_atr(card);
  616|     98|	LOG_TEST_RET(ctx, rv, "Parse EF.ATR");
  ------------------
  |  |  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: 76, False: 22]
  |  |  |  |  ------------------
  |  |  |  |  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|     98|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  617|       |
  618|     22|	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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  619|     22|}
card-iasecc.c:iasecc_get_serialnr:
 2464|    732|{
 2465|    732|	struct sc_context *ctx = card->ctx;
 2466|    732|	struct sc_iin *iin = &card->serialnr.iin;
 2467|    732|	struct sc_apdu apdu;
 2468|    732|	unsigned char rbuf[0xC0];
 2469|    732|	size_t ii, offs, len;
 2470|    732|	int rv;
 2471|       |
 2472|    732|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    732|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    732|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    732|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    732|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 732]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2473|    732|	if (card->serialnr.len)
  ------------------
  |  Branch (2473:6): [True: 7, False: 725]
  ------------------
 2474|      7|		goto end;
 2475|       |
 2476|    725|	memset(&card->serialnr, 0, sizeof(card->serialnr));
 2477|       |
 2478|    725|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xB0, 0x80 | IASECC_SFI_EF_SN, 0);
  ------------------
  |  |  292|    725|#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|    725|#define IASECC_SFI_EF_SN	0x1C
  ------------------
 2479|    725|	apdu.le = sizeof(rbuf);
 2480|    725|	apdu.resp = rbuf;
 2481|    725|	apdu.resplen = sizeof(rbuf);
 2482|       |
 2483|    725|	rv = sc_transmit_apdu(card, &apdu);
 2484|    725|	LOG_TEST_RET(ctx, rv, "APDU transmit failed");
  ------------------
  |  |  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: 15, False: 710]
  |  |  |  |  ------------------
  |  |  |  |  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|    725|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 710]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2485|    710|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 2486|    710|	LOG_TEST_RET(ctx, rv, "Get 'serial number' data failed");
  ------------------
  |  |  174|    710|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    710|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    710|	int _ret = (r); \
  |  |  |  |  168|    710|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 500, False: 210]
  |  |  |  |  ------------------
  |  |  |  |  169|    500|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    500|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    500|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    500|		return _ret; \
  |  |  |  |  172|    500|	} \
  |  |  |  |  173|    710|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 210]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2487|       |
 2488|    210|	if (apdu.resplen < 2 || rbuf[0] != ISO7812_PAN_SN_TAG || rbuf[1] > (apdu.resplen-2))
  ------------------
  |  |   29|    295|#define ISO7812_PAN_SN_TAG	0x5A
  ------------------
  |  Branch (2488:6): [True: 125, False: 85]
  |  Branch (2488:26): [True: 64, False: 21]
  |  Branch (2488:59): [True: 6, False: 15]
  ------------------
 2489|    210|		LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "serial number parse error");
  ------------------
  |  |  174|    195|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    195|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    195|	int _ret = (r); \
  |  |  |  |  168|    195|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 195, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    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
  |  |  |  |  ------------------
  |  |  |  |  170|    195|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    195|		return _ret; \
  |  |  |  |  172|    195|	} \
  |  |  |  |  173|    195|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2490|     15|	len = rbuf[1];
 2491|       |
 2492|     15|	iin->mii = (rbuf[2] >> 4) & 0x0F;
 2493|       |
 2494|     15|	iin->country = 0;
 2495|     60|	for (ii=5; ii<8; ii++)   {
  ------------------
  |  Branch (2495:13): [True: 45, False: 15]
  ------------------
 2496|     45|		iin->country *= 10;
 2497|     45|		iin->country += (rbuf[ii/2] >> ((ii & 0x01) ? 0 : 4)) & 0x0F;
  ------------------
  |  Branch (2497:35): [True: 30, False: 15]
  ------------------
 2498|     45|	}
 2499|       |
 2500|     15|	iin->issuer_id = 0;
 2501|     45|	for (ii=8; ii<10; ii++)   {
  ------------------
  |  Branch (2501:13): [True: 30, False: 15]
  ------------------
 2502|     30|		iin->issuer_id *= 10;
 2503|     30|		iin->issuer_id += (rbuf[ii/2] >> (ii & 0x01 ? 0 : 4)) & 0x0F;
  ------------------
  |  Branch (2503:37): [True: 15, False: 15]
  ------------------
 2504|     30|	}
 2505|       |
 2506|       |	/* Copy the serial number from the last 8 bytes (at most) */
 2507|     15|	offs = len > 8 ? len - 8 : 0;
  ------------------
  |  Branch (2507:9): [True: 4, False: 11]
  ------------------
 2508|     15|	if (card->type == SC_CARD_TYPE_IASECC_SAGEM)   {
  ------------------
  |  Branch (2508:6): [True: 7, False: 8]
  ------------------
 2509|       |		/* 5A 0A 92 50 00 20 10 10 25 00 01 3F */
 2510|       |		/*            00 02 01 01 02 50 00 13  */
 2511|     28|		for (ii=0; ii < len - offs; ii++)
  ------------------
  |  Branch (2511:14): [True: 21, False: 7]
  ------------------
 2512|     21|			*(card->serialnr.value + ii) = ((rbuf[ii + offs + 1] & 0x0F) << 4)
 2513|     21|				+ ((rbuf[ii + offs + 2] & 0xF0) >> 4) ;
 2514|      7|		card->serialnr.len = ii;
 2515|      7|	}
 2516|      8|	else   {
 2517|     50|		for (ii=0; ii < len - offs; ii++)
  ------------------
  |  Branch (2517:14): [True: 42, False: 8]
  ------------------
 2518|     42|			*(card->serialnr.value + ii) = rbuf[ii + offs + 2];
 2519|      8|		card->serialnr.len = ii;
 2520|      8|	}
 2521|       |
 2522|     15|	do  {
 2523|     15|		char txt[0x200];
 2524|       |
 2525|     78|		for (ii=0;ii<card->serialnr.len;ii++)
  ------------------
  |  Branch (2525:13): [True: 63, False: 15]
  ------------------
 2526|     63|			sprintf(txt + ii*2, "%02X", *(card->serialnr.value + ii));
 2527|       |
 2528|     15|		sc_log(ctx, "serial number '%s'; mii %i; country %i; issuer_id %li", txt, iin->mii, iin->country, iin->issuer_id);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2529|     15|	} while(0);
  ------------------
  |  Branch (2529:10): [Folded, False: 15]
  ------------------
 2530|       |
 2531|     22|end:
 2532|     22|	if (serial)
  ------------------
  |  Branch (2532:6): [True: 7, False: 15]
  ------------------
 2533|      7|		memcpy(serial, &card->serialnr, sizeof(*serial));
 2534|       |
 2535|     22|	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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2536|     22|}
card-iasecc.c:_iasecc_sm_read_binary:
  760|     91|{
  761|     91|	struct iasecc_private_data *prv = (struct iasecc_private_data *)card->drv_data;
  762|     91|	struct sc_context *ctx = card->ctx;
  763|     91|	const struct sc_acl_entry *entry = NULL;
  764|     91|	int rv;
  765|       |
  766|     91|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     91|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     91|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     91|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     91|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 91]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  767|     91|	sc_log(ctx, "iasecc_sm_read_binary() card:%p offs:%i count:%zu ", card, offs, count);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  768|     91|	if (offs > 0x7fff)
  ------------------
  |  Branch (768:6): [True: 0, False: 91]
  ------------------
  769|     91|		LOG_TEST_RET(ctx, SC_ERROR_OFFSET_TOO_LARGE, "Invalid arguments");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  770|       |
  771|     91|	if (count == 0)
  ------------------
  |  Branch (771:6): [True: 0, False: 91]
  ------------------
  772|      0|		return 0;
  773|       |
  774|     91|	if (prv->cache.valid && prv->cache.current_ef) {
  ------------------
  |  Branch (774:6): [True: 91, False: 0]
  |  Branch (774:26): [True: 88, False: 3]
  ------------------
  775|     88|		entry = sc_file_get_acl_entry(prv->cache.current_ef, SC_AC_OP_READ);
  ------------------
  |  |  188|     88|#define SC_AC_OP_READ			22
  ------------------
  776|     88|		if (!entry)
  ------------------
  |  Branch (776:7): [True: 2, False: 86]
  ------------------
  777|     88|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  778|       |
  779|     86|		sc_log(ctx, "READ method/reference %X/%X", entry->method, entry->key_ref);
  ------------------
  |  |   71|     86|#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|     86|		if ((entry->method == SC_AC_SCB) && (entry->key_ref & IASECC_SCB_METHOD_SM))   {
  ------------------
  |  |  157|     86|#define SC_AC_SCB                       0x00000040 /* IAS/ECC SCB byte. */
  ------------------
              		if ((entry->method == SC_AC_SCB) && (entry->key_ref & IASECC_SCB_METHOD_SM))   {
  ------------------
  |  |   91|     75|#define IASECC_SCB_METHOD_SM		0x40
  ------------------
  |  Branch (780:7): [True: 75, False: 11]
  |  Branch (780:39): [True: 69, False: 6]
  ------------------
  781|     69|			unsigned char se_num = entry->key_ref & IASECC_SCB_METHOD_MASK_REF;
  ------------------
  |  |   90|     69|#define IASECC_SCB_METHOD_MASK_REF	0x0F
  ------------------
  782|       |
  783|     69|			rv = iasecc_sm_read_binary(card, se_num, offs, buff, count);
  784|     69|			LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  785|     69|		}
  786|     86|	}
  787|       |
  788|     20|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     20|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     20|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     20|	int _ret = r; \
  |  |  |  |  155|     20|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 20, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     20|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  |  |  157|     20|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     20|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     20|	return _ret; \
  |  |  |  |  163|     20|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  789|     20|}
card-iasecc.c:_iasecc_sm_update_binary:
  795|      4|{
  796|      4|	struct iasecc_private_data *prv = (struct iasecc_private_data *)card->drv_data;
  797|      4|	struct sc_context *ctx = card->ctx;
  798|      4|	const struct sc_acl_entry *entry = NULL;
  799|      4|	int rv;
  800|       |
  801|      4|	if (count == 0)
  ------------------
  |  Branch (801:6): [True: 0, False: 4]
  ------------------
  802|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  803|       |
  804|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  805|      4|	sc_log(ctx, "iasecc_sm_read_binary() card:%p offs:%i count:%zu ", card, offs, count);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  806|       |
  807|      4|	if (prv->cache.valid && prv->cache.current_ef) {
  ------------------
  |  Branch (807:6): [True: 4, False: 0]
  |  Branch (807:26): [True: 3, False: 1]
  ------------------
  808|      3|		entry = sc_file_get_acl_entry(prv->cache.current_ef, SC_AC_OP_UPDATE);
  ------------------
  |  |  189|      3|#define SC_AC_OP_UPDATE			23
  ------------------
  809|      3|		if (!entry)
  ------------------
  |  Branch (809:7): [True: 1, False: 2]
  ------------------
  810|      3|			LOG_TEST_RET(ctx, SC_ERROR_OBJECT_NOT_FOUND, "iasecc_sm_update() 'UPDATE' ACL not present");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  811|       |
  812|      2|		sc_log(ctx, "UPDATE method/reference %X/%X", entry->method, entry->key_ref);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  813|      2|		if (entry->method == SC_AC_SCB && (entry->key_ref & IASECC_SCB_METHOD_SM))   {
  ------------------
  |  |  157|      4|#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 (813:7): [True: 0, False: 2]
  |  Branch (813:37): [True: 0, False: 0]
  ------------------
  814|      0|			unsigned char se_num = entry->key_ref & IASECC_SCB_METHOD_MASK_REF;
  ------------------
  |  |   90|      0|#define IASECC_SCB_METHOD_MASK_REF	0x0F
  ------------------
  815|       |
  816|      0|			rv = iasecc_sm_update_binary(card, se_num, offs, buff, count);
  817|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  818|      0|		}
  819|      2|	}
  820|       |
  821|      3|	LOG_FUNC_RETURN(ctx, 0);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  822|      3|}
card-iasecc.c:iasecc_finish:
 1414|    469|{
 1415|    469|	struct sc_context *ctx = card->ctx;
 1416|    469|	struct iasecc_private_data *private_data = (struct iasecc_private_data *)card->drv_data;
 1417|    469|	struct iasecc_se_info *se_info = private_data->se_info, *next;
 1418|       |
 1419|    469|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    469|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    469|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    469|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    469|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 469]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1420|       |
 1421|    469|	sc_invalidate_cache(card);
 1422|       |
 1423|    479|	while (se_info)   {
  ------------------
  |  Branch (1423:9): [True: 10, False: 469]
  ------------------
 1424|     10|		sc_file_free(se_info->df);
 1425|     10|		next = se_info->next;
 1426|     10|		free(se_info);
 1427|     10|		se_info = next;
 1428|     10|	}
 1429|       |
 1430|    469|	free(card->drv_data);
 1431|    469|	card->drv_data = NULL;
 1432|       |
 1433|    469|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    469|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    469|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    469|	int _ret = r; \
  |  |  |  |  155|    469|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 469, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    469|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 469]
  |  |  |  |  ------------------
  |  |  |  |  157|    469|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    469|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    469|	return _ret; \
  |  |  |  |  163|    469|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1434|    469|}
card-iasecc.c:iasecc_read_binary:
  697|  1.90k|{
  698|  1.90k|	struct sc_context *ctx = card->ctx;
  699|  1.90k|	struct sc_apdu apdu;
  700|  1.90k|	int rv;
  701|       |
  702|  1.90k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  1.90k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.90k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.90k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.90k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.90k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  703|  1.90k|	sc_log(ctx, "iasecc_read_binary(card:%p) offs %i; count %zu", card, offs, count);
  ------------------
  |  |   71|  1.90k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  704|  1.90k|	if (offs > 0x7fff) {
  ------------------
  |  Branch (704:6): [True: 1, False: 1.90k]
  ------------------
  705|      1|		sc_log(ctx, "invalid EF offset: 0x%X > 0x7FFF", offs);
  ------------------
  |  |   71|      1|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  706|      1|		return SC_ERROR_OFFSET_TOO_LARGE;
  ------------------
  |  |   96|      1|#define SC_ERROR_OFFSET_TOO_LARGE		-1415
  ------------------
  707|      1|	}
  708|       |
  709|  1.90k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xB0, (offs >> 8) & 0x7F, offs & 0xFF);
  ------------------
  |  |  292|  1.90k|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  710|  1.90k|	apdu.le = count < 0x100 ? count : 0x100;
  ------------------
  |  Branch (710:12): [True: 91, False: 1.80k]
  ------------------
  711|  1.90k|	apdu.resplen = count;
  712|  1.90k|	apdu.resp = buf;
  713|       |
  714|  1.90k|	rv = sc_transmit_apdu(card, &apdu);
  715|  1.90k|	LOG_TEST_RET(ctx, rv, "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: 28, False: 1.87k]
  |  |  |  |  ------------------
  |  |  |  |  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|  1.90k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.87k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  716|  1.87k|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  717|  1.87k|	LOG_TEST_RET(ctx, rv, "iasecc_read_binary() failed");
  ------------------
  |  |  174|  1.87k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.87k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.87k|	int _ret = (r); \
  |  |  |  |  168|  1.87k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 604, False: 1.26k]
  |  |  |  |  ------------------
  |  |  |  |  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|  1.87k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.26k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  718|  1.26k|	sc_log(ctx, "iasecc_read_binary() apdu.resplen %zu", apdu.resplen);
  ------------------
  |  |   71|  1.26k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  719|       |
  720|  1.26k|	if (apdu.resplen == IASECC_READ_BINARY_LENGTH_MAX && apdu.resplen < count)   {
  ------------------
  |  |   76|  2.53k|#define IASECC_READ_BINARY_LENGTH_MAX	0xE7
  ------------------
  |  Branch (720:6): [True: 31, False: 1.23k]
  |  Branch (720:55): [True: 30, False: 1]
  ------------------
  721|     30|		rv = iasecc_read_binary(card, (int)(offs + apdu.resplen), buf + apdu.resplen, count - apdu.resplen, flags);
  722|     30|		if (rv != SC_ERROR_WRONG_LENGTH)   {
  ------------------
  |  |   56|     30|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
  |  Branch (722:7): [True: 29, False: 1]
  ------------------
  723|     29|			LOG_TEST_RET(ctx, rv, "iasecc_read_binary() read tail 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: 10, False: 19]
  |  |  |  |  ------------------
  |  |  |  |  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|     29|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 19]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  724|     19|			apdu.resplen += rv;
  725|     19|		}
  726|     30|	}
  727|       |
  728|  1.25k|	LOG_FUNC_RETURN(ctx, (int)apdu.resplen);
  ------------------
  |  |  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: 46, False: 1.21k]
  |  |  |  |  ------------------
  |  |  |  |  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|  1.21k|	} else { \
  |  |  |  |  159|  1.21k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  1.21k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  1.21k|	} \
  |  |  |  |  162|  1.25k|	return _ret; \
  |  |  |  |  163|  1.25k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  729|  1.25k|}
card-iasecc.c:iasecc_sdo_get_data:
 2848|    204|{
 2849|    204|	struct sc_context *ctx = card->ctx;
 2850|    204|	int rv, sdo_tag;
 2851|       |
 2852|    204|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    204|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    204|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    204|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    204|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 204]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2853|       |
 2854|    204|	sdo_tag = iasecc_sdo_tag_from_class(sdo->sdo_class);
 2855|       |
 2856|    204|	rv = iasecc_sdo_get_tagged_data(card, sdo_tag, sdo);
 2857|       |	/* When there is no public data 'GET DATA' returns error */
 2858|    204|	if (rv != SC_ERROR_INCORRECT_PARAMETERS)
  ------------------
  |  |   55|    204|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
  |  Branch (2858:6): [True: 196, False: 8]
  ------------------
 2859|    204|		LOG_TEST_RET(ctx, rv, "cannot parse ECC SDO data");
  ------------------
  |  |  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: 195, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  169|    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
  |  |  |  |  ------------------
  |  |  |  |  170|    195|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    195|		return _ret; \
  |  |  |  |  172|    195|	} \
  |  |  |  |  173|    196|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2860|       |
 2861|      9|	rv = iasecc_sdo_get_tagged_data(card, IASECC_DOCP_TAG, sdo);
  ------------------
  |  |   31|      9|#define IASECC_DOCP_TAG				0xA0
  ------------------
 2862|      9|	LOG_TEST_RET(ctx, rv, "cannot parse ECC DOCP data");
  ------------------
  |  |  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: 9, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|      9|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2863|       |
 2864|      0|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2865|      0|}
card-iasecc.c:iasecc_sdo_tag_from_class:
 2749|    204|{
 2750|    204|	switch (sdo_class & ~IASECC_OBJECT_REF_LOCAL)   {
  ------------------
  |  |   59|    204|#define IASECC_OBJECT_REF_LOCAL		0x80
  ------------------
  |  Branch (2750:10): [True: 204, False: 0]
  ------------------
 2751|    177|	case IASECC_SDO_CLASS_CHV:
  ------------------
  |  |   98|    177|#define IASECC_SDO_CLASS_CHV		0x01
  ------------------
  |  Branch (2751:2): [True: 177, False: 27]
  ------------------
 2752|    177|		return IASECC_SDO_CHV_TAG;
  ------------------
  |  |   63|    177|#define IASECC_SDO_CHV_TAG		0x7F41
  ------------------
 2753|     20|	case IASECC_SDO_CLASS_RSA_PRIVATE:
  ------------------
  |  |  100|     20|#define IASECC_SDO_CLASS_RSA_PRIVATE	0x10
  ------------------
  |  Branch (2753:2): [True: 20, False: 184]
  ------------------
 2754|     20|		return IASECC_SDO_PRVKEY_TAG;
  ------------------
  |  |   68|     20|#define IASECC_SDO_PRVKEY_TAG			0x7F48
  ------------------
 2755|      7|	case IASECC_SDO_CLASS_RSA_PUBLIC:
  ------------------
  |  |  101|      7|#define IASECC_SDO_CLASS_RSA_PUBLIC	0x20
  ------------------
  |  Branch (2755:2): [True: 7, False: 197]
  ------------------
 2756|      7|		return IASECC_SDO_PUBKEY_TAG;
  ------------------
  |  |   76|      7|#define IASECC_SDO_PUBKEY_TAG			0x7F49
  ------------------
 2757|      0|	case IASECC_SDO_CLASS_SE:
  ------------------
  |  |  102|      0|#define IASECC_SDO_CLASS_SE		0x7B
  ------------------
  |  Branch (2757:2): [True: 0, False: 204]
  ------------------
 2758|      0|		return IASECC_SDO_CLASS_SE;
  ------------------
  |  |  102|      0|#define IASECC_SDO_CLASS_SE		0x7B
  ------------------
 2759|      0|	case IASECC_SDO_CLASS_KEYSET:
  ------------------
  |  |   99|      0|#define IASECC_SDO_CLASS_KEYSET		0x0A
  ------------------
  |  Branch (2759:2): [True: 0, False: 204]
  ------------------
 2760|      0|		return IASECC_SDO_KEYSET_TAG;
  ------------------
  |  |   83|      0|#define IASECC_SDO_KEYSET_TAG			0xA2
  ------------------
 2761|    204|	}
 2762|       |
 2763|      0|	return -1;
 2764|    204|}
card-iasecc.c:iasecc_sdo_get_tagged_data:
 2769|    213|{
 2770|    213|	struct sc_context *ctx = card->ctx;
 2771|    213|	struct sc_apdu apdu;
 2772|    213|	unsigned char sbuf[0x100];
 2773|    213|	size_t offs = sizeof(sbuf) - 1;
 2774|    213|	unsigned char rbuf[0x400];
 2775|    213|	int rv;
 2776|       |
 2777|    213|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    213|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    213|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    213|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    213|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 213]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2778|       |
 2779|    213|	sc_log(ctx, "sdo_tag=0x%x sdo_ref=0x%x sdo_class=0x%x", sdo_tag,
  ------------------
  |  |   71|    213|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2780|    213|			sdo->sdo_ref, sdo->sdo_class);
 2781|       |
 2782|       |	/* XXX: for the CPx, the SDO are available from some specific path */
 2783|    213|	if (iasecc_is_cpx(card)) {
  ------------------
  |  Branch (2783:6): [True: 37, False: 176]
  ------------------
 2784|     37|		struct sc_path path;
 2785|     37|		char *path_str = NULL;
 2786|     37|		switch(sdo_tag) {
 2787|     11|			case IASECC_SDO_PRVKEY_TAG:
  ------------------
  |  |   68|     11|#define IASECC_SDO_PRVKEY_TAG			0x7F48
  ------------------
  |  Branch (2787:4): [True: 11, False: 26]
  ------------------
 2788|       |			/* APDU 00 CB 3F FF 0B 4D 09 70 07 BF 90 02 03 7F 48 80 */
 2789|     11|			path_str = "3F00:0001";
 2790|     11|			break;
 2791|     15|			case IASECC_SDO_CHV_TAG:
  ------------------
  |  |   63|     15|#define IASECC_SDO_CHV_TAG		0x7F41
  ------------------
  |  Branch (2791:4): [True: 15, False: 22]
  ------------------
 2792|       |			/* APDU 00 CB 3F FF 0B 4D 09 70 07 BF 81 01 03 7F 41 80 */
 2793|     15|			path_str = "3F00";
 2794|     15|			break;
 2795|     11|			default:
  ------------------
  |  Branch (2795:4): [True: 11, False: 26]
  ------------------
 2796|     11|			path_str = NULL;
 2797|     11|			break;
 2798|     37|		}
 2799|     37|		if (path_str) {
  ------------------
  |  Branch (2799:7): [True: 26, False: 11]
  ------------------
 2800|     26|			sc_log(ctx, "Warning: Enforce the path=%s", path_str);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2801|     26|			sc_format_path(path_str, &path);
 2802|     26|			rv = iasecc_select_file(card, &path, NULL);
 2803|     26|			LOG_TEST_RET(ctx, rv, "path 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: 20, False: 6]
  |  |  |  |  ------------------
  |  |  |  |  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|     26|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2804|     26|		}
 2805|     37|	}
 2806|       |
 2807|    193|	sbuf[offs--] = 0x80;
 2808|    193|	sbuf[offs--] = sdo_tag & 0xFF;
 2809|    193|	if ((sdo_tag >> 8) & 0xFF)
  ------------------
  |  Branch (2809:6): [True: 184, False: 9]
  ------------------
 2810|    184|		sbuf[offs--] = (sdo_tag >> 8) & 0xFF;
 2811|    193|	sbuf[offs] = sizeof(sbuf) - offs - 1;
 2812|    193|	offs--;
 2813|       |
 2814|    193|	sbuf[offs--] = sdo->sdo_ref & 0x9F;
 2815|    193|	sbuf[offs--] = sdo->sdo_class | IASECC_OBJECT_REF_LOCAL;
  ------------------
  |  |   59|    193|#define IASECC_OBJECT_REF_LOCAL		0x80
  ------------------
 2816|    193|	sbuf[offs--] = IASECC_SDO_TAG_HEADER;
  ------------------
  |  |   27|    193|#define IASECC_SDO_TAG_HEADER	0xBF
  ------------------
 2817|       |
 2818|    193|	sbuf[offs] = sizeof(sbuf) - offs - 1;
 2819|    193|	offs--;
 2820|    193|	sbuf[offs--] = IASECC_SDO_TEMPLATE_TAG;
  ------------------
  |  |   29|    193|#define IASECC_SDO_TEMPLATE_TAG	0x70
  ------------------
 2821|       |
 2822|    193|	sbuf[offs] = sizeof(sbuf) - offs - 1;
 2823|    193|	offs--;
 2824|    193|	sbuf[offs] = 0x4D;
 2825|       |
 2826|    193|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xCB, 0x3F, 0xFF);
  ------------------
  |  |  294|    193|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
 2827|    193|	apdu.data = sbuf + offs;
 2828|    193|	apdu.datalen = sizeof(sbuf) - offs;
 2829|    193|	apdu.lc = sizeof(sbuf) - offs;
 2830|    193|	apdu.resp = rbuf;
 2831|    193|	apdu.resplen = sizeof(rbuf);
 2832|    193|	apdu.le = 0x100;
 2833|       |
 2834|    193|	rv = sc_transmit_apdu(card, &apdu);
 2835|    193|	LOG_TEST_RET(ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|    193|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    193|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    193|	int _ret = (r); \
  |  |  |  |  168|    193|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 187]
  |  |  |  |  ------------------
  |  |  |  |  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|    193|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 187]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2836|    187|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 2837|    187|	LOG_TEST_RET(ctx, rv, "SDO get data error");
  ------------------
  |  |  174|    187|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    187|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    187|	int _ret = (r); \
  |  |  |  |  168|    187|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 44, False: 143]
  |  |  |  |  ------------------
  |  |  |  |  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|    187|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 143]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2838|       |
 2839|    143|	rv = iasecc_sdo_parse(card, apdu.resp, apdu.resplen, sdo);
 2840|    143|	LOG_TEST_RET(ctx, rv, "cannot parse SDO data");
  ------------------
  |  |  174|    143|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    143|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    143|	int _ret = (r); \
  |  |  |  |  168|    143|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 142, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  169|    142|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    142|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    142|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    142|		return _ret; \
  |  |  |  |  172|    142|	} \
  |  |  |  |  173|    143|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2841|       |
 2842|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2843|      1|}
card-iasecc.c:iasecc_create_file:
 1311|     45|{
 1312|     45|	struct iasecc_private_data *prv = (struct iasecc_private_data *)card->drv_data;
 1313|     45|	struct sc_context *ctx = card->ctx;
 1314|     45|	struct sc_apdu apdu;
 1315|     45|	const struct sc_acl_entry *entry = NULL;
 1316|     45|	unsigned char sbuf[0x100];
 1317|     45|	size_t sbuf_len;
 1318|     45|	int rv;
 1319|       |
 1320|     45|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     45|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1321|       |
 1322|     45|	if (file->type != SC_FILE_TYPE_WORKING_EF)
  ------------------
  |  |  216|     45|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (1322:6): [True: 2, False: 43]
  ------------------
 1323|     45|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Creation of the file with of this type is not supported");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1324|       |
 1325|     43|	rv = iasecc_fcp_encode(card, file, sbuf + 2, sizeof(sbuf)-2);
 1326|     43|	LOG_TEST_RET(ctx, rv, "FCP encode error");
  ------------------
  |  |  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: 19, False: 24]
  |  |  |  |  ------------------
  |  |  |  |  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|     43|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 24]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1327|     24|	sbuf_len = rv;
 1328|       |
 1329|     24|	sbuf[0] = IASECC_FCP_TAG;
  ------------------
  |  |   46|     24|#define IASECC_FCP_TAG			0x62
  ------------------
 1330|     24|	sbuf[1] = sbuf_len;
 1331|       |
 1332|     24|	if (prv->cache.valid && prv->cache.current_df) {
  ------------------
  |  Branch (1332:6): [True: 24, False: 0]
  |  Branch (1332:26): [True: 19, False: 5]
  ------------------
 1333|     19|		entry = sc_file_get_acl_entry(prv->cache.current_df, SC_AC_OP_CREATE);
  ------------------
  |  |  169|     19|#define SC_AC_OP_CREATE			3
  ------------------
 1334|     19|		if (!entry)
  ------------------
  |  Branch (1334:7): [True: 10, False: 9]
  ------------------
 1335|     19|			LOG_TEST_RET(ctx, SC_ERROR_OBJECT_NOT_FOUND, "iasecc_create_file() 'CREATE' ACL not present");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1336|       |
 1337|      9|		sc_log(ctx, "iasecc_create_file() 'CREATE' method/reference %X/%X", entry->method, entry->key_ref);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1338|      9|		sc_log(ctx, "iasecc_create_file() create data: '%s'", sc_dump_hex(sbuf, sbuf_len + 2));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1339|      9|		if (entry->method == SC_AC_SCB && (entry->key_ref & IASECC_SCB_METHOD_SM))   {
  ------------------
  |  |  157|     18|#define SC_AC_SCB                       0x00000040 /* IAS/ECC SCB byte. */
  ------------------
              		if (entry->method == SC_AC_SCB && (entry->key_ref & IASECC_SCB_METHOD_SM))   {
  ------------------
  |  |   91|      5|#define IASECC_SCB_METHOD_SM		0x40
  ------------------
  |  Branch (1339:7): [True: 5, False: 4]
  |  Branch (1339:37): [True: 2, False: 3]
  ------------------
 1340|      2|                        rv = iasecc_sm_create_file(card, entry->key_ref & IASECC_SCB_METHOD_MASK_REF, sbuf, sbuf_len + 2);
  ------------------
  |  |   90|      2|#define IASECC_SCB_METHOD_MASK_REF	0x0F
  ------------------
 1341|      2|                        LOG_TEST_RET(ctx, rv, "iasecc_create_file() SM create file 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1342|       |
 1343|      0|                        rv = iasecc_select_file(card, &file->path, NULL);
 1344|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1345|       |
 1346|      0|		}
 1347|      9|	}
 1348|       |
 1349|     12|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE0, 0, 0);
  ------------------
  |  |  293|     12|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1350|     12|	apdu.data = sbuf;
 1351|     12|	apdu.datalen = sbuf_len + 2;
 1352|     12|	apdu.lc = sbuf_len + 2;
 1353|       |
 1354|     12|	rv = sc_transmit_apdu(card, &apdu);
 1355|     12|	LOG_TEST_RET(ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|     12|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     12|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     12|	int _ret = (r); \
  |  |  |  |  168|     12|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 11]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|     12|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 11]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1356|     11|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1357|     11|	LOG_TEST_RET(ctx, rv, "iasecc_create_file() create file 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1358|       |
 1359|     10|	rv = iasecc_select_file(card, &file->path, NULL);
 1360|     10|	LOG_TEST_RET(ctx, rv, "Cannot select newly created file");
  ------------------
  |  |  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: 3, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  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|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1361|       |
 1362|      7|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1363|      7|}
card-iasecc.c:iasecc_fcp_encode:
 1192|     43|{
 1193|     43|	struct sc_context *ctx = card->ctx;
 1194|     43|	unsigned char buf[0x80], type;
 1195|     43|	unsigned char  ops[7] = {
 1196|     43|		SC_AC_OP_DELETE, 0xFF, SC_AC_OP_ACTIVATE, SC_AC_OP_DEACTIVATE, 0xFF, SC_AC_OP_UPDATE, SC_AC_OP_READ
  ------------------
  |  |  168|     43|#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|     43|#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|     43|#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|     43|#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|     43|#define SC_AC_OP_READ			22
  ------------------
 1197|     43|	};
 1198|     43|	unsigned char smbs[8];
 1199|     43|	size_t ii, amb, offs = 0, mask, nn_smb;
 1200|       |
 1201|     43|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     43|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     43|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     43|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     43|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 43]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1202|       |
 1203|     43|	if (file->type == SC_FILE_TYPE_DF)
  ------------------
  |  |  214|     43|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (1203:6): [True: 0, False: 43]
  ------------------
 1204|      0|		type = IASECC_FCP_TYPE_DF;
  ------------------
  |  |   57|      0|#define IASECC_FCP_TYPE_DF	0x38
  ------------------
 1205|     43|	else
 1206|     43|		type = IASECC_FCP_TYPE_EF;
  ------------------
  |  |   56|     43|#define IASECC_FCP_TYPE_EF	0x01
  ------------------
 1207|       |
 1208|     43|	buf[offs++] = IASECC_FCP_TAG_SIZE;
  ------------------
  |  |   47|     43|#define IASECC_FCP_TAG_SIZE		0x80
  ------------------
 1209|     43|	buf[offs++] = 2;
 1210|     43|	buf[offs++] = (file->size >> 8) & 0xFF;
 1211|     43|	buf[offs++] = file->size & 0xFF;
 1212|       |
 1213|     43|	buf[offs++] = IASECC_FCP_TAG_TYPE;
  ------------------
  |  |   48|     43|#define IASECC_FCP_TAG_TYPE		0x82
  ------------------
 1214|     43|	buf[offs++] = 1;
 1215|     43|	buf[offs++] = type;
 1216|       |
 1217|     43|	buf[offs++] = IASECC_FCP_TAG_FID;
  ------------------
  |  |   49|     43|#define IASECC_FCP_TAG_FID		0x83
  ------------------
 1218|     43|	buf[offs++] = 2;
 1219|     43|	buf[offs++] = (file->id >> 8) & 0xFF;
 1220|     43|	buf[offs++] = file->id & 0xFF;
 1221|       |
 1222|     43|	buf[offs++] = IASECC_FCP_TAG_SFID;
  ------------------
  |  |   51|     43|#define IASECC_FCP_TAG_SFID		0x88
  ------------------
 1223|     43|	buf[offs++] = 0;
 1224|       |
 1225|     43|	amb = 0, mask = 0x40, nn_smb = 0;
 1226|    222|	for (ii = 0; ii < sizeof(ops); ii++, mask >>= 1) {
  ------------------
  |  Branch (1226:15): [True: 198, False: 24]
  ------------------
 1227|    198|		const struct sc_acl_entry *entry;
 1228|       |
 1229|    198|		if (ops[ii]==0xFF)
  ------------------
  |  Branch (1229:7): [True: 52, False: 146]
  ------------------
 1230|     52|			continue;
 1231|       |
 1232|    146|		entry = sc_file_get_acl_entry(file, ops[ii]);
 1233|    146|		if (!entry)
  ------------------
  |  Branch (1233:7): [True: 0, False: 146]
  ------------------
 1234|      0|			continue;
 1235|       |
 1236|    146|		sc_log(ctx, "method %X; reference %X", entry->method, entry->key_ref);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1237|    146|		if (entry->method == SC_AC_NEVER)
  ------------------
  |  |  163|    146|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (1237:7): [True: 18, False: 128]
  ------------------
 1238|     18|			continue;
 1239|    128|		else if (entry->method == SC_AC_NONE)
  ------------------
  |  |  150|    128|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (1239:12): [True: 93, False: 35]
  ------------------
 1240|     93|			smbs[nn_smb++] = 0x00;
 1241|     35|		else if (entry->method == SC_AC_CHV)
  ------------------
  |  |  151|     35|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (1241:12): [True: 8, False: 27]
  ------------------
 1242|      8|			smbs[nn_smb++] = entry->key_ref | IASECC_SCB_METHOD_USER_AUTH;
  ------------------
  |  |   93|      8|#define IASECC_SCB_METHOD_USER_AUTH	0x10
  ------------------
 1243|     27|		else if (entry->method == SC_AC_SEN)
  ------------------
  |  |  156|     27|#define SC_AC_SEN                       0x00000020 /* Security Environment. */
  ------------------
  |  Branch (1243:12): [True: 1, False: 26]
  ------------------
 1244|      1|			smbs[nn_smb++] = entry->key_ref | IASECC_SCB_METHOD_USER_AUTH;
  ------------------
  |  |   93|      1|#define IASECC_SCB_METHOD_USER_AUTH	0x10
  ------------------
 1245|     26|		else if (entry->method == SC_AC_SCB)
  ------------------
  |  |  157|     26|#define SC_AC_SCB                       0x00000040 /* IAS/ECC SCB byte. */
  ------------------
  |  Branch (1245:12): [True: 1, False: 25]
  ------------------
 1246|      1|			smbs[nn_smb++] = entry->key_ref;
 1247|     25|		else if (entry->method == SC_AC_PRO)
  ------------------
  |  |  153|     25|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  |  Branch (1247:12): [True: 6, False: 19]
  ------------------
 1248|      6|			smbs[nn_smb++] = entry->key_ref | IASECC_SCB_METHOD_SM;
  ------------------
  |  |   91|      6|#define IASECC_SCB_METHOD_SM		0x40
  ------------------
 1249|     19|		else
 1250|     19|			LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Non supported AC method");
  ------------------
  |  |  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: 19, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|     19|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1251|       |
 1252|    109|		amb |= mask;
 1253|    109|		sc_log(ctx, "%zu: AMB %zX; nn_smb %zu", ii, amb, nn_smb);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1254|    109|	}
 1255|       |
 1256|       |	/* TODO: Encode contactless ACLs and life cycle status for all IAS/ECC cards */
 1257|     24|	if (card->type == SC_CARD_TYPE_IASECC_SAGEM ||
  ------------------
  |  Branch (1257:6): [True: 10, False: 14]
  ------------------
 1258|     14|			card->type == SC_CARD_TYPE_IASECC_AMOS )  {
  ------------------
  |  Branch (1258:4): [True: 0, False: 14]
  ------------------
 1259|     10|		unsigned char status = 0;
 1260|       |
 1261|     10|		buf[offs++] = IASECC_FCP_TAG_ACLS;
  ------------------
  |  |   52|     10|#define IASECC_FCP_TAG_ACLS		0xA1
  ------------------
 1262|     10|		buf[offs++] = 2*(2 + 1 + nn_smb);
 1263|       |
 1264|     10|		buf[offs++] = IASECC_FCP_TAG_ACLS_CONTACT;
  ------------------
  |  |   53|     10|#define IASECC_FCP_TAG_ACLS_CONTACT	0x8C
  ------------------
 1265|     10|		buf[offs++] = nn_smb + 1;
 1266|     10|		buf[offs++] = amb;
 1267|     10|		memcpy(buf + offs, smbs, nn_smb);
 1268|     10|		offs += nn_smb;
 1269|       |
 1270|       |		/* Same ACLs for contactless */
 1271|     10|		buf[offs++] = IASECC_FCP_TAG_ACLS_CONTACTLESS;
  ------------------
  |  |   54|     10|#define IASECC_FCP_TAG_ACLS_CONTACTLESS	0x9C
  ------------------
 1272|     10|		buf[offs++] = nn_smb + 1;
 1273|     10|		buf[offs++] = amb;
 1274|     10|		memcpy(buf + offs, smbs, nn_smb);
 1275|     10|		offs += nn_smb;
 1276|       |
 1277|     10|		if (file->status == SC_FILE_STATUS_ACTIVATED)
  ------------------
  |  |  236|     10|#define SC_FILE_STATUS_ACTIVATED	0x00 /* ISO7816-4: Operational state (activated)   (5, 7) */
  ------------------
  |  Branch (1277:7): [True: 10, False: 0]
  ------------------
 1278|     10|			status = 0x05;
 1279|      0|		else if (file->status == SC_FILE_STATUS_CREATION)
  ------------------
  |  |  240|      0|#define SC_FILE_STATUS_CREATION		0x02 /* ISO7816-4: Creation state, (1) */
  ------------------
  |  Branch (1279:12): [True: 0, False: 0]
  ------------------
 1280|      0|			status = 0x01;
 1281|       |
 1282|     10|		if (status)   {
  ------------------
  |  Branch (1282:7): [True: 10, False: 0]
  ------------------
 1283|     10|			buf[offs++] = 0x8A;
 1284|     10|			buf[offs++] = 0x01;
 1285|     10|			buf[offs++] = status;
 1286|     10|		}
 1287|     10|	}
 1288|     14|	else   {
 1289|     14|		buf[offs++] = IASECC_FCP_TAG_ACLS;
  ------------------
  |  |   52|     14|#define IASECC_FCP_TAG_ACLS		0xA1
  ------------------
 1290|     14|		buf[offs++] = 2 + 1 + nn_smb;
 1291|       |
 1292|     14|		buf[offs++] = IASECC_FCP_TAG_ACLS_CONTACT;
  ------------------
  |  |   53|     14|#define IASECC_FCP_TAG_ACLS_CONTACT	0x8C
  ------------------
 1293|     14|		buf[offs++] = nn_smb + 1;
 1294|     14|		buf[offs++] = amb;
 1295|     14|		memcpy(buf + offs, smbs, nn_smb);
 1296|     14|		offs += nn_smb;
 1297|     14|	}
 1298|       |
 1299|     24|	if (out)   {
  ------------------
  |  Branch (1299:6): [True: 24, False: 0]
  ------------------
 1300|     24|		if (out_len < offs)
  ------------------
  |  Branch (1300:7): [True: 0, False: 24]
  ------------------
 1301|     24|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1302|     24|		memcpy(out, buf, offs);
 1303|     24|	}
 1304|       |
 1305|     24|	LOG_FUNC_RETURN(ctx, (int)offs);
  ------------------
  |  |  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: 0, False: 24]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     24|	} 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|     24|	return _ret; \
  |  |  |  |  163|     24|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1306|     24|}
card-iasecc.c:iasecc_delete_file:
 1439|     29|{
 1440|     29|	struct sc_context *ctx = card->ctx;
 1441|     29|	const struct sc_acl_entry *entry = NULL;
 1442|     29|	struct sc_apdu apdu;
 1443|     29|	struct sc_file *file = NULL;
 1444|     29|	int rv;
 1445|       |
 1446|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1447|       |
 1448|     29|	rv = iasecc_select_file(card, path, &file);
 1449|     29|	if (rv == SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|     29|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (1449:6): [True: 1, False: 28]
  ------------------
 1450|     29|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1451|     28|	LOG_TEST_RET(ctx, rv, "Cannot select file to delete");
  ------------------
  |  |  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: 3, False: 25]
  |  |  |  |  ------------------
  |  |  |  |  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|     28|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 25]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1452|       |
 1453|     25|	entry = sc_file_get_acl_entry(file, SC_AC_OP_DELETE);
  ------------------
  |  |  168|     25|#define SC_AC_OP_DELETE			2
  ------------------
 1454|     25|	if (!entry) {
  ------------------
  |  Branch (1454:6): [True: 2, False: 23]
  ------------------
 1455|      2|		sc_file_free(file);
 1456|      2|		LOG_TEST_RET(ctx, SC_ERROR_OBJECT_NOT_FOUND, "Cannot delete file: no 'DELETE' acl");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1457|      2|	}
 1458|       |
 1459|     23|	sc_log(ctx, "DELETE method/reference %X/%X", entry->method, entry->key_ref);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1460|     23|	if (entry->method == SC_AC_SCB && (entry->key_ref & IASECC_SCB_METHOD_SM))   {
  ------------------
  |  |  157|     46|#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 (1460:6): [True: 14, False: 9]
  |  Branch (1460:36): [True: 2, False: 12]
  ------------------
 1461|      2|		unsigned char se_num = entry->key_ref & IASECC_SCB_METHOD_MASK_REF;
  ------------------
  |  |   90|      2|#define IASECC_SCB_METHOD_MASK_REF	0x0F
  ------------------
 1462|      2|		rv = iasecc_sm_delete_file(card, se_num, file->id);
 1463|      2|		sc_file_free(file);
 1464|      2|	}
 1465|     21|	else   {
 1466|     21|		struct iasecc_private_data *prv = (struct iasecc_private_data *)card->drv_data;
 1467|     21|		sc_file_free(file);
 1468|     21|		sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0xE4, 0x00, 0x00);
  ------------------
  |  |  291|     21|#define SC_APDU_CASE_1			0x01
  ------------------
 1469|       |
 1470|     21|		rv = sc_transmit_apdu(card, &apdu);
 1471|     21|		LOG_TEST_RET(ctx, rv, "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: 1, False: 20]
  |  |  |  |  ------------------
  |  |  |  |  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|     21|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1472|     20|		rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1473|     20|		LOG_TEST_RET(ctx, rv, "Delete file failed");
  ------------------
  |  |  174|     20|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     20|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     20|	int _ret = (r); \
  |  |  |  |  168|     20|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 18]
  |  |  |  |  ------------------
  |  |  |  |  169|      2|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      2|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      2|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      2|		return _ret; \
  |  |  |  |  172|      2|	} \
  |  |  |  |  173|     20|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 18]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1474|       |
 1475|     18|		if (prv->cache.valid) {
  ------------------
  |  Branch (1475:7): [True: 18, False: 0]
  ------------------
 1476|     18|			sc_file_free(prv->cache.current_ef);
 1477|     18|		}
 1478|     18|		prv->cache.current_ef = NULL;
 1479|     18|	}
 1480|       |
 1481|     20|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1482|     20|}
card-iasecc.c:iasecc_check_sw:
 1487|  11.3k|{
 1488|  11.3k|	if (sw1 == 0x62 && sw2 == 0x82)
  ------------------
  |  Branch (1488:6): [True: 2.27k, False: 9.04k]
  |  Branch (1488:21): [True: 2.22k, False: 47]
  ------------------
 1489|  2.22k|		return SC_SUCCESS;
  ------------------
  |  |   28|  2.22k|#define SC_SUCCESS				0
  ------------------
 1490|       |
 1491|  9.09k|	return iso_ops->check_sw(card, sw1, sw2);
 1492|  11.3k|}
card-iasecc.c:iasecc_card_ctl:
 2973|    790|{
 2974|    790|	struct sc_context *ctx = card->ctx;
 2975|    790|	struct iasecc_sdo *sdo = (struct iasecc_sdo *) ptr;
 2976|       |
 2977|    790|	switch (cmd) {
  ------------------
  |  Branch (2977:10): [True: 291, False: 499]
  ------------------
 2978|    263|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (2978:2): [True: 263, False: 527]
  ------------------
 2979|    263|		return iasecc_get_serialnr(card, (struct sc_serial_number *)ptr);
 2980|      0|	case SC_CARDCTL_IASECC_SDO_CREATE:
  ------------------
  |  Branch (2980:2): [True: 0, False: 790]
  ------------------
 2981|      0|		sc_log(ctx, "CMD SC_CARDCTL_IASECC_SDO_CREATE: sdo_class %X", sdo->sdo_class);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2982|      0|		return iasecc_sdo_create(card, (struct iasecc_sdo *) ptr);
 2983|      0|	case SC_CARDCTL_IASECC_SDO_DELETE:
  ------------------
  |  Branch (2983:2): [True: 0, False: 790]
  ------------------
 2984|      0|		sc_log(ctx, "CMD SC_CARDCTL_IASECC_SDO_DELETE: sdo_class %X", sdo->sdo_class);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2985|      0|		return iasecc_sdo_delete(card, (struct iasecc_sdo *) ptr);
 2986|      0|	case SC_CARDCTL_IASECC_SDO_PUT_DATA:
  ------------------
  |  Branch (2986:2): [True: 0, False: 790]
  ------------------
 2987|      0|		sc_log(ctx, "CMD SC_CARDCTL_IASECC_SDO_PUT_DATA: sdo_class %X", sdo->sdo_class);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2988|      0|		return iasecc_sdo_put_data(card, (struct iasecc_sdo_update *) ptr);
 2989|      0|	case SC_CARDCTL_IASECC_SDO_KEY_RSA_PUT_DATA:
  ------------------
  |  Branch (2989:2): [True: 0, False: 790]
  ------------------
 2990|      0|		sc_log(ctx, "CMD SC_CARDCTL_IASECC_SDO_KEY_RSA_PUT_DATA");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2991|      0|		return iasecc_sdo_key_rsa_put_data(card, (struct iasecc_sdo_rsa_update *) ptr);
 2992|     11|	case SC_CARDCTL_IASECC_SDO_GET_DATA:
  ------------------
  |  Branch (2992:2): [True: 11, False: 779]
  ------------------
 2993|     11|		sc_log(ctx, "CMD SC_CARDCTL_IASECC_SDO_GET_DATA: sdo_class %X", sdo->sdo_class);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2994|     11|		return iasecc_sdo_get_data(card, (struct iasecc_sdo *) ptr);
 2995|      0|	case SC_CARDCTL_IASECC_SDO_GENERATE:
  ------------------
  |  Branch (2995:2): [True: 0, False: 790]
  ------------------
 2996|      0|		sc_log(ctx, "CMD SC_CARDCTL_IASECC_SDO_GET_DATA: sdo_class %X", sdo->sdo_class);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2997|      0|		return iasecc_sdo_generate(card, (struct iasecc_sdo *) ptr);
 2998|      0|	case SC_CARDCTL_GET_SE_INFO:
  ------------------
  |  Branch (2998:2): [True: 0, False: 790]
  ------------------
 2999|      0|		sc_log(ctx, "CMD SC_CARDCTL_GET_SE_INFO: sdo_class %X", sdo->sdo_class);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3000|      0|		return iasecc_se_get_info(card, (struct iasecc_se_info *) ptr);
 3001|      1|	case SC_CARDCTL_GET_CHV_REFERENCE_IN_SE:
  ------------------
  |  Branch (3001:2): [True: 1, False: 789]
  ------------------
 3002|      1|		sc_log(ctx, "CMD SC_CARDCTL_GET_CHV_REFERENCE_IN_SE");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3003|      1|		return iasecc_get_chv_reference_from_se(card, (int *)ptr);
 3004|     16|	case SC_CARDCTL_IASECC_GET_FREE_KEY_REFERENCE:
  ------------------
  |  Branch (3004:2): [True: 16, False: 774]
  ------------------
 3005|     16|		sc_log(ctx, "CMD SC_CARDCTL_IASECC_GET_FREE_KEY_REFERENCE");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3006|     16|		return iasecc_get_free_reference(card, (struct iasecc_ctl_get_free_reference *)ptr);
 3007|    790|	}
 3008|    499|	return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    499|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 3009|    790|}
card-iasecc.c:iasecc_get_chv_reference_from_se:
 2942|      1|{
 2943|      1|	struct sc_context *ctx = card->ctx;
 2944|      1|	struct iasecc_se_info se;
 2945|      1|	struct sc_crt crt;
 2946|      1|	int rv;
 2947|       |
 2948|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2949|       |
 2950|      1|	if (!se_reference)
  ------------------
  |  Branch (2950:6): [True: 0, False: 1]
  ------------------
 2951|      1|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2952|       |
 2953|      1|	memset(&se, 0, sizeof(se));
 2954|      1|	se.reference = *se_reference;
 2955|       |
 2956|      1|	rv = iasecc_se_get_info(card, &se);
 2957|      1|	LOG_TEST_RET(ctx, rv, "get SE info 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2958|       |
 2959|      0|	memset(&crt, 0, sizeof(crt));
 2960|      0|	crt.tag = IASECC_CRT_TAG_AT;
  ------------------
  |  |  104|      0|#define IASECC_CRT_TAG_AT	0xA4
  ------------------
 2961|      0|	crt.usage = IASECC_UQB_AT_USER_PASSWORD;
  ------------------
  |  |  130|      0|#define IASECC_UQB_AT_USER_PASSWORD		0x08
  ------------------
 2962|       |
 2963|      0|	rv = iasecc_se_get_crt(card, &se, &crt);
 2964|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2965|       |
 2966|      0|	sc_file_free(se.df);
 2967|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2968|      0|}
card-iasecc.c:iasecc_get_free_reference:
 3483|     16|{
 3484|     16|	struct sc_context *ctx = card->ctx;
 3485|     16|	struct iasecc_sdo *sdo = NULL;
 3486|     16|	int idx, rv;
 3487|       |
 3488|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3489|       |
 3490|     16|	if ((ctl_data->key_size % 0x40) || ctl_data->index < 1 || (ctl_data->index > IASECC_OBJECT_REF_MAX))
  ------------------
  |  |   63|     16|#define IASECC_OBJECT_REF_MAX	0x1F
  ------------------
  |  Branch (3490:6): [True: 0, False: 16]
  |  Branch (3490:37): [True: 0, False: 16]
  |  Branch (3490:60): [True: 0, False: 16]
  ------------------
 3491|     16|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3492|       |
 3493|     16|	sc_log(ctx, "get reference for key(index:%i,usage:%X,access:%X)", ctl_data->index, ctl_data->usage, ctl_data->access);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3494|       |	/* TODO: when looking for the slot for the signature keys, check also PSO_SIGNATURE ACL */
 3495|     16|	for (idx = ctl_data->index; idx <= IASECC_OBJECT_REF_MAX; idx++)   {
  ------------------
  |  |   63|     16|#define IASECC_OBJECT_REF_MAX	0x1F
  ------------------
  |  Branch (3495:30): [True: 16, False: 0]
  ------------------
 3496|     16|		unsigned char sdo_tag[3] = {
 3497|     16|			IASECC_SDO_TAG_HEADER, IASECC_OBJECT_REF_LOCAL | IASECC_SDO_CLASS_RSA_PRIVATE, idx
  ------------------
  |  |   27|     16|#define IASECC_SDO_TAG_HEADER	0xBF
  ------------------
              			IASECC_SDO_TAG_HEADER, IASECC_OBJECT_REF_LOCAL | IASECC_SDO_CLASS_RSA_PRIVATE, idx
  ------------------
  |  |   59|     16|#define IASECC_OBJECT_REF_LOCAL		0x80
  ------------------
              			IASECC_SDO_TAG_HEADER, IASECC_OBJECT_REF_LOCAL | IASECC_SDO_CLASS_RSA_PRIVATE, idx
  ------------------
  |  |  100|     16|#define IASECC_SDO_CLASS_RSA_PRIVATE	0x10
  ------------------
 3498|     16|		};
 3499|     16|		size_t sz;
 3500|       |
 3501|     16|		if (sdo)
  ------------------
  |  Branch (3501:7): [True: 0, False: 16]
  ------------------
 3502|      0|			iasecc_sdo_free(card, sdo);
 3503|       |
 3504|     16|		rv = iasecc_sdo_allocate_and_parse(card, sdo_tag, 3, &sdo);
 3505|     16|		LOG_TEST_RET(ctx, rv, "cannot parse SDO data");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3506|       |
 3507|     16|		rv = iasecc_sdo_get_data(card, sdo);
 3508|     16|		if (rv == SC_ERROR_DATA_OBJECT_NOT_FOUND)   {
  ------------------
  |  |   66|     16|#define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
  ------------------
  |  Branch (3508:7): [True: 7, False: 9]
  ------------------
 3509|      7|			iasecc_sdo_free(card, sdo);
 3510|       |
 3511|      7|			sc_log(ctx, "found empty key slot %i", idx);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3512|      7|			break;
 3513|      9|		} else if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|      9|#define SC_SUCCESS				0
  ------------------
  |  Branch (3513:14): [True: 9, False: 0]
  ------------------
 3514|      9|			iasecc_sdo_free(card, sdo);
 3515|       |
 3516|      9|			sc_log(ctx, "get new key reference failed");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3517|      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|      9|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 9, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      9|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      9|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      9|	return _ret; \
  |  |  |  |  163|      9|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3518|      9|		}
 3519|       |
 3520|      0|		if (sdo->docp.size.size < 2)
  ------------------
  |  Branch (3520:7): [True: 0, False: 0]
  ------------------
 3521|      0|			continue;
 3522|      0|		sz = *(sdo->docp.size.value + 0) * 0x100 + *(sdo->docp.size.value + 1);
 3523|      0|		sc_log(ctx, "SDO(idx:%i) size %zu; key_size %zu", idx, sz, ctl_data->key_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__
  |  |  ------------------
  ------------------
 3524|       |
 3525|      0|		if (sz != ctl_data->key_size / 8)   {
  ------------------
  |  Branch (3525:7): [True: 0, False: 0]
  ------------------
 3526|      0|			sc_log(ctx, "key index %i ignored: different key sizes %zu/%zu",
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3527|      0|					idx, sz, ctl_data->key_size / 8);
 3528|      0|			continue;
 3529|      0|		}
 3530|       |
 3531|      0|		if (sdo->docp.non_repudiation.value)   {
  ------------------
  |  Branch (3531:7): [True: 0, False: 0]
  ------------------
 3532|      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__
  |  |  ------------------
  ------------------
 3533|      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 (3533:8): [True: 0, False: 0]
  |  Branch (3533:68): [True: 0, False: 0]
  ------------------
 3534|      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__
  |  |  ------------------
  ------------------
 3535|      0|				continue;
 3536|      0|			}
 3537|       |
 3538|      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 (3538:8): [True: 0, False: 0]
  |  Branch (3538:69): [True: 0, False: 0]
  ------------------
 3539|      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__
  |  |  ------------------
  ------------------
 3540|      0|				continue;
 3541|      0|			}
 3542|      0|		}
 3543|       |
 3544|      0|		if (ctl_data->access & SC_PKCS15_PRKEY_ACCESS_LOCAL)   {
  ------------------
  |  |  320|      0|#define SC_PKCS15_PRKEY_ACCESS_LOCAL		0x10
  ------------------
  |  Branch (3544:7): [True: 0, False: 0]
  ------------------
 3545|      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 (3545:8): [True: 0, False: 0]
  ------------------
 3546|      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__
  |  |  ------------------
  ------------------
 3547|      0|				continue;
 3548|      0|			}
 3549|      0|		}
 3550|      0|		else   {
 3551|      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 (3551:8): [True: 0, False: 0]
  ------------------
 3552|      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__
  |  |  ------------------
  ------------------
 3553|      0|				continue;
 3554|      0|			}
 3555|      0|		}
 3556|       |
 3557|      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 (3557:7): [True: 0, False: 0]
  |  Branch (3557:67): [True: 0, False: 0]
  ------------------
 3558|      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 (3558:8): [True: 0, False: 0]
  ------------------
 3559|      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__
  |  |  ------------------
  ------------------
 3560|      0|				continue;
 3561|      0|			}
 3562|      0|		}
 3563|      0|		else if (ctl_data->usage & SC_PKCS15_PRKEY_USAGE_SIGN)   {
  ------------------
  |  |  307|      0|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
  |  Branch (3563:12): [True: 0, False: 0]
  ------------------
 3564|      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 (3564:8): [True: 0, False: 0]
  ------------------
 3565|      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__
  |  |  ------------------
  ------------------
 3566|      0|				continue;
 3567|      0|			}
 3568|      0|		}
 3569|       |
 3570|      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 (3570:7): [True: 0, False: 0]
  ------------------
 3571|      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 (3571:8): [True: 0, False: 0]
  ------------------
 3572|      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__
  |  |  ------------------
  ------------------
 3573|      0|				continue;
 3574|      0|			}
 3575|      0|		}
 3576|       |
 3577|      0|		break;
 3578|      0|	}
 3579|       |
 3580|      7|	ctl_data->index = idx;
 3581|       |
 3582|      7|	if (idx > IASECC_OBJECT_REF_MAX)
  ------------------
  |  |   63|      7|#define IASECC_OBJECT_REF_MAX	0x1F
  ------------------
  |  Branch (3582:6): [True: 0, False: 7]
  ------------------
 3583|      7|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3584|       |
 3585|      7|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|      7|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      7|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      7|	int _ret = r; \
  |  |  |  |  155|      7|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 7, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      7|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  157|      7|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      7|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      7|	return _ret; \
  |  |  |  |  163|      7|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3586|      7|}
card-iasecc.c:iasecc_pin_cmd:
 2428|    213|{
 2429|    213|	struct sc_context *ctx = card->ctx;
 2430|    213|	int rv;
 2431|       |
 2432|    213|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    213|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    213|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    213|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    213|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 213]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2433|    213|	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|    213|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2434|    213|			data->cmd, data->pin_type, data->pin_reference,
 2435|    213|			data->pin1.data, data->pin1.len, data->pin2.data, data->pin2.len);
 2436|       |
 2437|    213|	switch (data->cmd)   {
 2438|      7|	case SC_PIN_CMD_VERIFY:
  ------------------
  |  |  415|      7|#define SC_PIN_CMD_VERIFY	0
  ------------------
  |  Branch (2438:2): [True: 7, False: 206]
  ------------------
 2439|      7|		rv = iasecc_pin_verify(card, data);
 2440|      7|		break;
 2441|      0|	case SC_PIN_CMD_CHANGE:
  ------------------
  |  |  416|      0|#define SC_PIN_CMD_CHANGE	1
  ------------------
  |  Branch (2441:2): [True: 0, False: 213]
  ------------------
 2442|      0|		if (data->pin_type == SC_AC_AUT)
  ------------------
  |  |  154|      0|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  |  Branch (2442:7): [True: 0, False: 0]
  ------------------
 2443|      0|			rv = iasecc_keyset_change(card, data);
 2444|      0|		else
 2445|      0|			rv = iasecc_pin_change(card, data);
 2446|      0|		break;
 2447|      0|	case SC_PIN_CMD_UNBLOCK:
  ------------------
  |  |  417|      0|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (2447:2): [True: 0, False: 213]
  ------------------
 2448|      0|		rv = iasecc_pin_reset(card, data);
 2449|      0|		break;
 2450|    206|	case SC_PIN_CMD_GET_INFO:
  ------------------
  |  |  418|    206|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (2450:2): [True: 206, False: 7]
  ------------------
 2451|    206|		rv = iasecc_pin_get_info(card, data);
 2452|    206|		break;
 2453|      0|	default:
  ------------------
  |  Branch (2453:2): [True: 0, False: 213]
  ------------------
 2454|      0|		sc_log(ctx, "Other pin commands not supported yet: 0x%X", data->cmd);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2455|      0|		rv = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 2456|    213|	}
 2457|       |
 2458|    213|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    213|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    213|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    213|	int _ret = r; \
  |  |  |  |  155|    213|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 213, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    213|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    213|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    213|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    213|	return _ret; \
  |  |  |  |  163|    213|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2459|    213|}
card-iasecc.c:iasecc_pin_verify:
 1923|      7|{
 1924|      7|	struct sc_context *ctx = card->ctx;
 1925|      7|	unsigned type = data->pin_type;
 1926|      7|	unsigned reference = data->pin_reference;
 1927|      7|	struct sc_pin_cmd_data pin_cmd;
 1928|      7|	struct iasecc_pin_policy policy;
 1929|      7|	int tries_before_verify = -1;
 1930|      7|	int rv;
 1931|       |
 1932|      7|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1933|      7|	sc_log(ctx, "Verify PIN(type:%X,ref:%i,data(len:%zu,%p)",
  ------------------
  |  |   71|      7|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1934|      7|			type, reference, data->pin1.len, data->pin1.data);
 1935|       |
 1936|      7|	if (type == SC_AC_AUT)   {
  ------------------
  |  |  154|      7|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  |  Branch (1936:6): [True: 0, False: 7]
  ------------------
 1937|      0|		rv =  iasecc_sm_external_authentication(card, reference, &data->pin1.tries_left);
 1938|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1939|      0|	}
 1940|       |
 1941|      7|	if (type == SC_AC_SCB)   {
  ------------------
  |  |  157|      7|#define SC_AC_SCB                       0x00000040 /* IAS/ECC SCB byte. */
  ------------------
  |  Branch (1941:6): [True: 7, False: 0]
  ------------------
 1942|      7|		if (reference & IASECC_SCB_METHOD_USER_AUTH)   {
  ------------------
  |  |   93|      7|#define IASECC_SCB_METHOD_USER_AUTH	0x10
  ------------------
  |  Branch (1942:7): [True: 1, False: 6]
  ------------------
 1943|      1|			type = SC_AC_SEN;
  ------------------
  |  |  156|      1|#define SC_AC_SEN                       0x00000020 /* Security Environment. */
  ------------------
 1944|      1|			reference = reference & IASECC_SCB_METHOD_MASK_REF;
  ------------------
  |  |   90|      1|#define IASECC_SCB_METHOD_MASK_REF	0x0F
  ------------------
 1945|      1|		}
 1946|      7|	}
 1947|       |
 1948|      7|	if (type == SC_AC_SEN)   {
  ------------------
  |  |  156|      7|#define SC_AC_SEN                       0x00000020 /* Security Environment. */
  ------------------
  |  Branch (1948:6): [True: 1, False: 6]
  ------------------
 1949|      1|		type = SC_AC_CHV;
  ------------------
  |  |  151|      1|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1950|      1|		rv = iasecc_se_at_to_chv_reference(card, reference,  &reference);
 1951|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1952|      1|	}
 1953|       |
 1954|      6|	if (type != SC_AC_CHV)   {
  ------------------
  |  |  151|      6|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (1954:6): [True: 6, False: 0]
  ------------------
 1955|      6|		sc_log(ctx, "Do not try to verify non CHV PINs");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1956|      6|		LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1957|      6|	}
 1958|       |
 1959|      0|	pin_cmd = *data;
 1960|      0|	pin_cmd.pin_type = SC_AC_CHV;
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1961|      0|	pin_cmd.pin_reference = reference;
 1962|      0|	pin_cmd.cmd = SC_PIN_CMD_VERIFY;
  ------------------
  |  |  415|      0|#define SC_PIN_CMD_VERIFY	0
  ------------------
 1963|       |
 1964|      0|	rv = iasecc_pin_get_status(card, &pin_cmd);
 1965|      0|	if (data->pin1.data && !data->pin1.len)
  ------------------
  |  Branch (1965:6): [True: 0, False: 0]
  |  Branch (1965:25): [True: 0, False: 0]
  ------------------
 1966|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1967|       |
 1968|      0|	if (!rv)   {
  ------------------
  |  Branch (1968:6): [True: 0, False: 0]
  ------------------
 1969|      0|		if (pin_cmd.pin1.logged_in & SC_PIN_STATE_LOGGED_IN)
  ------------------
  |  |  432|      0|#define SC_PIN_STATE_LOGGED_IN  2
  ------------------
  |  Branch (1969:7): [True: 0, False: 0]
  ------------------
 1970|      0|			if (iasecc_chv_cache_is_verified(card, &pin_cmd))
  ------------------
  |  Branch (1970:8): [True: 0, False: 0]
  ------------------
 1971|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1972|      0|	}
 1973|      0|	else if (rv != SC_ERROR_SECURITY_STATUS_NOT_SATISFIED)   {
  ------------------
  |  |   61|      0|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
  |  Branch (1973:11): [True: 0, False: 0]
  ------------------
 1974|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1975|      0|	}
 1976|       |
 1977|      0|	iasecc_chv_cache_clean(card, &pin_cmd);
 1978|       |
 1979|      0|	rv = iasecc_pin_merge_policy(card, &pin_cmd, &pin_cmd.pin1, &policy);
 1980|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1981|       |
 1982|       |	/* PIN-pads work best with fixed-size lengths. Use PIN padding when length is available. */
 1983|      0|	if (pin_cmd.flags & SC_PIN_CMD_USE_PINPAD) {
  ------------------
  |  |  421|      0|#define SC_PIN_CMD_USE_PINPAD		0x0001
  ------------------
  |  Branch (1983:6): [True: 0, False: 0]
  ------------------
 1984|      0|		tries_before_verify = pin_cmd.pin1.tries_left;
 1985|      0|		if (policy.stored_length > 0)
  ------------------
  |  Branch (1985:7): [True: 0, False: 0]
  ------------------
 1986|      0|			iasecc_set_pin_padding(&pin_cmd, &pin_cmd.pin1, policy.stored_length);
 1987|      0|	}
 1988|       |
 1989|      0|	rv = iasecc_chv_verify(card, &pin_cmd, policy.scbs);
 1990|       |
 1991|       |	/*
 1992|       |	 * Detect and log PIN-pads which don't handle variable-length PIN - special case where they
 1993|       |	 * forward the CHV verify command with Lc = 0 to the card, without updating Lc. An IAS-ECC
 1994|       |	 * card responds to this command by returning the number of attempts left, without
 1995|       |	 * decreasing the counter.
 1996|       |	 */
 1997|      0|	if ((pin_cmd.flags & SC_PIN_CMD_USE_PINPAD) && !(pin_cmd.flags & SC_PIN_CMD_NEED_PADDING)) {
  ------------------
  |  |  421|      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)) {
  ------------------
  |  |  422|      0|#define SC_PIN_CMD_NEED_PADDING		0x0002
  ------------------
  |  Branch (1997:6): [True: 0, False: 0]
  |  Branch (1997:49): [True: 0, False: 0]
  ------------------
 1998|      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 (1998:7): [True: 0, False: 0]
  |  Branch (1998:44): [True: 0, False: 0]
  ------------------
 1999|      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]
  |  |  ------------------
  ------------------
 2000|      0|				    "PIN-pad reader does not support variable-length PIN");
 2001|      0|		}
 2002|      0|	}
 2003|       |
 2004|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2005|       |
 2006|      0|	rv = iasecc_chv_cache_verified(card, &pin_cmd);
 2007|       |
 2008|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2009|      0|}
card-iasecc.c:iasecc_se_at_to_chv_reference:
 1859|      1|{
 1860|      1|	struct sc_context *ctx = card->ctx;
 1861|      1|	struct iasecc_se_info se;
 1862|      1|	struct sc_crt crt;
 1863|      1|	int rv;
 1864|       |
 1865|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1866|      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__
  |  |  ------------------
  ------------------
 1867|       |
 1868|      1|	if (reference > IASECC_SE_REF_MAX)
  ------------------
  |  |   66|      1|#define IASECC_SE_REF_MAX	0x0F
  ------------------
  |  Branch (1868:6): [True: 0, False: 1]
  ------------------
 1869|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1870|       |
 1871|      1|	memset(&se, 0, sizeof(se));
 1872|      1|	se.reference = reference;
 1873|       |
 1874|      1|	rv = iasecc_se_get_info(card, &se);
 1875|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1876|       |
 1877|      0|	memset(&crt, 0, sizeof(crt));
 1878|      0|	crt.tag = IASECC_CRT_TAG_AT;
  ------------------
  |  |  104|      0|#define IASECC_CRT_TAG_AT	0xA4
  ------------------
 1879|      0|	crt.usage = IASECC_UQB_AT_USER_PASSWORD;
  ------------------
  |  |  130|      0|#define IASECC_UQB_AT_USER_PASSWORD		0x08
  ------------------
 1880|       |
 1881|      0|	rv = iasecc_se_get_crt(card, &se, &crt);
 1882|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1883|       |
 1884|      0|	if (chv_reference)
  ------------------
  |  Branch (1884:6): [True: 0, False: 0]
  ------------------
 1885|      0|		*chv_reference = crt.refs[0];
 1886|       |
 1887|      0|	sc_file_free(se.df);
 1888|       |
 1889|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1890|      0|}
card-iasecc.c:iasecc_pin_get_status:
 1895|    206|{
 1896|    206|	struct sc_context *ctx = card->ctx;
 1897|    206|	struct sc_pin_cmd_data info;
 1898|    206|	int rv;
 1899|       |
 1900|    206|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    206|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    206|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    206|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    206|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 206]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1901|       |
 1902|    206|	if (data->pin_type != SC_AC_CHV)
  ------------------
  |  |  151|    206|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (1902:6): [True: 0, False: 206]
  ------------------
 1903|    206|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "PIN type is not supported for status");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1904|       |
 1905|    206|	memset(&info, 0, sizeof(info));
 1906|    206|	info.cmd = SC_PIN_CMD_GET_INFO;
  ------------------
  |  |  418|    206|#define SC_PIN_CMD_GET_INFO	3
  ------------------
 1907|    206|	info.pin_type = data->pin_type;
 1908|    206|	info.pin_reference = data->pin_reference;
 1909|       |
 1910|    206|	rv = iso_ops->pin_cmd(card, &info);
 1911|    206|	LOG_TEST_RET(ctx, rv, "Failed to get PIN info");
  ------------------
  |  |  174|    206|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    206|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    206|	int _ret = (r); \
  |  |  |  |  168|    206|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 23, False: 183]
  |  |  |  |  ------------------
  |  |  |  |  169|     23|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     23|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     23|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     23|		return _ret; \
  |  |  |  |  172|     23|	} \
  |  |  |  |  173|    206|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 183]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1912|       |
 1913|    183|	data->pin1.max_tries = info.pin1.max_tries;
 1914|    183|	data->pin1.tries_left = info.pin1.tries_left;
 1915|    183|	data->pin1.logged_in = info.pin1.logged_in;
 1916|       |
 1917|    183|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1918|    183|}
card-iasecc.c:iasecc_pin_get_policy:
 2014|    183|{
 2015|    183|	struct iasecc_private_data *prv = (struct iasecc_private_data *)card->drv_data;
 2016|    183|	struct sc_context *ctx = card->ctx;
 2017|    183|	struct sc_file *save_current_df = NULL, *save_current_ef = NULL;
 2018|    183|	struct iasecc_sdo sdo;
 2019|    183|	struct sc_path path;
 2020|    183|	int rv;
 2021|       |
 2022|    183|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    183|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    183|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    183|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    183|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 183]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2023|    183|	sc_log(ctx, "iasecc_pin_get_policy(card:%p)", card);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2024|       |
 2025|    183|	if (data->pin_type != SC_AC_CHV)   {
  ------------------
  |  |  151|    183|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (2025:6): [True: 0, False: 183]
  ------------------
 2026|      0|		sc_log(ctx, "PIN policy only available for CHV type");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2027|      0|		LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2028|      0|	}
 2029|       |
 2030|    183|	if (prv->cache.valid && prv->cache.current_df) {
  ------------------
  |  Branch (2030:6): [True: 183, False: 0]
  |  Branch (2030:26): [True: 18, False: 165]
  ------------------
 2031|     18|		sc_file_dup(&save_current_df, prv->cache.current_df);
 2032|     18|		if (save_current_df == NULL) {
  ------------------
  |  Branch (2032:7): [True: 0, False: 18]
  ------------------
 2033|      0|			rv = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2034|      0|			sc_log(ctx, "Cannot duplicate current DF file");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2035|      0|			goto err;
 2036|      0|		}
 2037|     18|	}
 2038|       |
 2039|    183|	if (prv->cache.valid && prv->cache.current_ef) {
  ------------------
  |  Branch (2039:6): [True: 183, False: 0]
  |  Branch (2039:26): [True: 15, False: 168]
  ------------------
 2040|     15|		sc_file_dup(&save_current_ef, prv->cache.current_ef);
 2041|     15|		if (save_current_ef == NULL) {
  ------------------
  |  Branch (2041:7): [True: 0, False: 15]
  ------------------
 2042|      0|			rv = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2043|      0|			sc_log(ctx, "Cannot duplicate current EF file");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2044|      0|			goto err;
 2045|      0|		}
 2046|     15|	}
 2047|       |
 2048|    183|	if (!(data->pin_reference & IASECC_OBJECT_REF_LOCAL) && prv->cache.valid && prv->cache.current_df) {
  ------------------
  |  |   59|    183|#define IASECC_OBJECT_REF_LOCAL		0x80
  ------------------
  |  Branch (2048:6): [True: 183, False: 0]
  |  Branch (2048:58): [True: 183, False: 0]
  |  Branch (2048:78): [True: 18, False: 165]
  ------------------
 2049|     18|		sc_format_path("3F00", &path);
 2050|     18|		path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|     18|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
 2051|     18|		rv = iasecc_select_file(card, &path, NULL);
 2052|     18|		LOG_TEST_GOTO_ERR(ctx, rv, "Unable to select MF");
  ------------------
  |  |  184|     18|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     18|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     18|	int _ret = (r); \
  |  |  |  |  178|     18|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 6, False: 12]
  |  |  |  |  ------------------
  |  |  |  |  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|     18|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2053|     18|	}
 2054|       |
 2055|    177|	memset(&sdo, 0, sizeof(sdo));
 2056|    177|	sdo.sdo_class = IASECC_SDO_CLASS_CHV;
  ------------------
  |  |   98|    177|#define IASECC_SDO_CLASS_CHV		0x01
  ------------------
 2057|       |
 2058|    177|	sdo.sdo_ref = data->pin_reference & ~IASECC_OBJECT_REF_LOCAL;
  ------------------
  |  |   59|    177|#define IASECC_OBJECT_REF_LOCAL		0x80
  ------------------
 2059|       |
 2060|    177|	sc_log(ctx, "iasecc_pin_get_policy() reference %i", sdo.sdo_ref);
  ------------------
  |  |   71|    177|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2061|       |
 2062|    177|	rv = iasecc_sdo_get_data(card, &sdo);
 2063|    177|	LOG_TEST_GOTO_ERR(ctx, rv, "Cannot get SDO PIN data");
  ------------------
  |  |  184|    177|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    177|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    177|	int _ret = (r); \
  |  |  |  |  178|    177|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 177, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|    177|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    177|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    177|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    177|		goto err; \
  |  |  |  |  182|    177|	} \
  |  |  |  |  183|    177|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2064|       |
 2065|      0|	if (sdo.docp.acls_contact.size == 0) {
  ------------------
  |  Branch (2065:6): [True: 0, False: 0]
  ------------------
 2066|      0|		rv = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 2067|      0|		sc_log(ctx, "Extremely strange ... there is no ACLs");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2068|      0|		goto err;
 2069|      0|	}
 2070|       |
 2071|      0|	sc_log(ctx, "iasecc_pin_get_policy() sdo.docp.size.size %zu", sdo.docp.size.size);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2072|       |
 2073|      0|	memcpy(pin->scbs, sdo.docp.scbs, sizeof(pin->scbs));
 2074|       |
 2075|      0|	pin->min_length = (sdo.data.chv.size_min.value ? *sdo.data.chv.size_min.value : -1);
  ------------------
  |  Branch (2075:21): [True: 0, False: 0]
  ------------------
 2076|      0|	pin->max_length = (sdo.data.chv.size_max.value ? *sdo.data.chv.size_max.value : -1);
  ------------------
  |  Branch (2076:21): [True: 0, False: 0]
  ------------------
 2077|      0|	pin->tries_maximum = (sdo.docp.tries_maximum.value ? *sdo.docp.tries_maximum.value : -1);
  ------------------
  |  Branch (2077:24): [True: 0, False: 0]
  ------------------
 2078|      0|	pin->tries_remaining = (sdo.docp.tries_remaining.value ? *sdo.docp.tries_remaining.value : -1);
  ------------------
  |  Branch (2078:26): [True: 0, False: 0]
  ------------------
 2079|      0|	if (sdo.docp.size.value && sdo.docp.size.size <= sizeof(int)) {
  ------------------
  |  Branch (2079:6): [True: 0, False: 0]
  |  Branch (2079:29): [True: 0, False: 0]
  ------------------
 2080|      0|		unsigned int n = 0;
 2081|      0|		unsigned int i;
 2082|      0|		for (i=0; i<sdo.docp.size.size; i++)
  ------------------
  |  Branch (2082:13): [True: 0, False: 0]
  ------------------
 2083|      0|			n = (n << 8) + *(sdo.docp.size.value + i);
 2084|      0|		pin->stored_length = n;
 2085|      0|	} else {
 2086|      0|		pin->stored_length = -1;
 2087|      0|	}
 2088|       |
 2089|      0|	sc_log(ctx, "PIN policy: size max/min %i/%i, tries max/left %i/%i",
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2090|      0|	       pin->max_length, pin->min_length, pin->tries_maximum, pin->tries_remaining);
 2091|      0|	iasecc_sdo_free_fields(card, &sdo);
 2092|       |
 2093|      0|	if (save_current_df)   {
  ------------------
  |  Branch (2093:6): [True: 0, False: 0]
  ------------------
 2094|      0|		sc_log(ctx, "iasecc_pin_get_policy() restore current DF");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2095|      0|		rv = iasecc_select_file(card, &save_current_df->path, NULL);
 2096|      0|		LOG_TEST_GOTO_ERR(ctx, rv, "Cannot return to saved DF");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2097|      0|	}
 2098|       |
 2099|      0|	if (save_current_ef)   {
  ------------------
  |  Branch (2099:6): [True: 0, False: 0]
  ------------------
 2100|      0|		sc_log(ctx, "iasecc_pin_get_policy() restore current EF");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2101|      0|		rv = iasecc_select_file(card, &save_current_ef->path, NULL);
 2102|      0|		LOG_TEST_GOTO_ERR(ctx, rv, "Cannot return to saved EF");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2103|      0|	}
 2104|       |
 2105|    183|err:
 2106|    183|	sc_file_free(save_current_df);
 2107|    183|	sc_file_free(save_current_ef);
 2108|       |
 2109|    183|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    183|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    183|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    183|	int _ret = r; \
  |  |  |  |  155|    183|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 183, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    183|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    183|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 183, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    183|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    183|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    183|	return _ret; \
  |  |  |  |  163|    183|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2110|    183|}
card-iasecc.c:iasecc_pin_get_info:
 2115|    206|{
 2116|    206|	struct sc_context *ctx = card->ctx;
 2117|    206|	struct iasecc_pin_policy policy;
 2118|    206|	int rv;
 2119|       |
 2120|    206|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    206|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    206|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    206|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    206|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 206]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2121|    206|	sc_log(ctx, "iasecc_pin_get_info(card:%p)", card);
  ------------------
  |  |   71|    206|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2122|       |
 2123|       |	/*
 2124|       |	 * Get PIN status first and thereafter update with info from PIN policy, when available.
 2125|       |	 * The first one is typically used for the PIN verification status and number of remaining
 2126|       |	 * tries, and the second one for the maximum tries. If a field is present in both, the
 2127|       |	 * policy takes precedence.
 2128|       |	 */
 2129|    206|	rv = iasecc_pin_get_status(card, data);
 2130|    206|	LOG_TEST_RET(ctx, rv, "Failed to get PIN status");
  ------------------
  |  |  174|    206|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    206|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    206|	int _ret = (r); \
  |  |  |  |  168|    206|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 23, False: 183]
  |  |  |  |  ------------------
  |  |  |  |  169|     23|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     23|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     23|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     23|		return _ret; \
  |  |  |  |  172|     23|	} \
  |  |  |  |  173|    206|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 183]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2131|       |
 2132|    183|	rv = iasecc_pin_get_policy(card, data, &policy);
 2133|    183|	LOG_TEST_RET(ctx, rv, "Failed to get PIN policy");
  ------------------
  |  |  174|    183|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    183|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    183|	int _ret = (r); \
  |  |  |  |  168|    183|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 183, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    183|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    183|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    183|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    183|		return _ret; \
  |  |  |  |  172|    183|	} \
  |  |  |  |  173|    183|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2134|       |
 2135|       |	/*
 2136|       |	 * We only care about the tries_xxx fields in the PIN policy, since the other ones are not
 2137|       |	 * commonly expected or used in a SC_PIN_CMD_GET_INFO response.	Note that max_tries is
 2138|       |	 * always taken from the policy, since it is never expected to be available in status (it
 2139|       |	 * is set to -1 when not available in policy).
 2140|       |	 */
 2141|      0|	data->pin1.max_tries = policy.tries_maximum;
 2142|      0|	if (policy.tries_remaining >= 0)
  ------------------
  |  Branch (2142:6): [True: 0, False: 0]
  ------------------
 2143|      0|		data->pin1.tries_left = policy.tries_remaining;
 2144|       |
 2145|      0|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2146|      0|}

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

sc_get_isoApplet_driver:
 1295|  16.3k|{
 1296|  16.3k|	return sc_get_driver();
 1297|  16.3k|}
card-isoApplet.c:sc_get_driver:
 1259|  16.3k|{
 1260|  16.3k|	sc_card_driver_t *iso_drv = sc_get_iso7816_driver();
 1261|       |
 1262|  16.3k|	if(iso_ops == NULL)
  ------------------
  |  Branch (1262:5): [True: 1, False: 16.3k]
  ------------------
 1263|      1|	{
 1264|      1|		iso_ops = iso_drv->ops;
 1265|      1|	}
 1266|       |
 1267|  16.3k|	isoApplet_ops = *iso_drv->ops;
 1268|       |
 1269|  16.3k|	isoApplet_ops.match_card = isoApplet_match_card;
 1270|  16.3k|	isoApplet_ops.init = isoApplet_init;
 1271|  16.3k|	isoApplet_ops.finish = isoApplet_finish;
 1272|       |
 1273|  16.3k|	isoApplet_ops.card_ctl = isoApplet_card_ctl;
 1274|       |
 1275|  16.3k|	isoApplet_ops.create_file = isoApplet_create_file;
 1276|  16.3k|	isoApplet_ops.process_fci = isoApplet_process_fci;
 1277|  16.3k|	isoApplet_ops.set_security_env = isoApplet_set_security_env;
 1278|  16.3k|	isoApplet_ops.compute_signature = isoApplet_compute_signature;
 1279|  16.3k|	isoApplet_ops.get_challenge = isoApplet_get_challenge;
 1280|  16.3k|	isoApplet_ops.card_reader_lock_obtained = isoApplet_card_reader_lock_obtained;
 1281|  16.3k|	isoApplet_ops.logout = isoApplet_logout;
 1282|       |
 1283|       |	/* unsupported functions */
 1284|  16.3k|	isoApplet_ops.write_binary = NULL;
 1285|  16.3k|	isoApplet_ops.read_record = NULL;
 1286|  16.3k|	isoApplet_ops.write_record = NULL;
 1287|  16.3k|	isoApplet_ops.append_record = NULL;
 1288|  16.3k|	isoApplet_ops.update_record = NULL;
 1289|  16.3k|	isoApplet_ops.restore_security_env = NULL;
 1290|       |
 1291|  16.3k|	return &isoApplet_drv;
 1292|  16.3k|}
card-isoApplet.c:isoApplet_match_card:
  111|  3.65k|{
  112|  3.65k|	int rv;
  113|       |
  114|  3.65k|	rv = iso7816_select_aid(card, isoApplet_aid, sizeof(isoApplet_aid), NULL, NULL);
  115|  3.65k|	if(rv != SC_SUCCESS)
  ------------------
  |  |   28|  3.65k|#define SC_SUCCESS				0
  ------------------
  |  Branch (115:5): [True: 3.44k, False: 201]
  ------------------
  116|  3.44k|	{
  117|  3.44k|		return 0;
  118|  3.44k|	}
  119|       |
  120|    201|	return 1;
  121|  3.65k|}
card-isoApplet.c:isoApplet_init:
  155|    201|{
  156|    201|	int i, r;
  157|    201|	unsigned int major_version = 0;
  158|    201|	unsigned long flags = 0;
  159|    201|	unsigned long ext_flags = 0;
  160|    201|	struct isoApplet_drv_data *drvdata;
  161|       |
  162|    201|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    201|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    201|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    201|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    201|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 201]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  163|       |
  164|    201|	drvdata=calloc(1, sizeof(*drvdata));
  165|    201|	if (!drvdata)
  ------------------
  |  Branch (165:6): [True: 0, False: 201]
  ------------------
  166|    201|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  167|       |
  168|    201|	card->drv_data = drvdata;
  169|    201|	card->cla = 0x00;
  170|       |
  171|       |	/* Obtain applet version and specific features */
  172|    201|	r = isoApplet_get_info(card, drvdata);
  173|    201|	LOG_TEST_GOTO_ERR(card->ctx, r, "Error obtaining information about applet.");
  ------------------
  |  |  184|    201|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    201|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    201|	int _ret = (r); \
  |  |  |  |  178|    201|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 11, False: 190]
  |  |  |  |  ------------------
  |  |  |  |  179|     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
  |  |  |  |  ------------------
  |  |  |  |  180|     11|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     11|		goto err; \
  |  |  |  |  182|     11|	} \
  |  |  |  |  183|    201|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 190]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  174|       |
  175|    190|	major_version = drvdata->isoapplet_version & 0xFF00;
  176|    190|	if(major_version != (ISOAPPLET_VERSION_V0 & 0xFF00) && major_version != (ISOAPPLET_VERSION_V1 & 0xFF00))
  ------------------
  |  |   36|    190|#define ISOAPPLET_VERSION_V0 0x0006
  ------------------
              	if(major_version != (ISOAPPLET_VERSION_V0 & 0xFF00) && major_version != (ISOAPPLET_VERSION_V1 & 0xFF00))
  ------------------
  |  |   37|     20|#define ISOAPPLET_VERSION_V1 0x0100
  ------------------
  |  Branch (176:5): [True: 20, False: 170]
  |  Branch (176:57): [True: 17, False: 3]
  ------------------
  177|     17|	{
  178|     17|		sc_log(card->ctx, "IsoApplet: Mismatching major API version. Not proceeding. "
  ------------------
  |  |   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__
  |  |  ------------------
  |  |               #define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |  180|     17|			   ISOAPPLET_VERSION_V0, ISOAPPLET_VERSION_V1, drvdata->isoapplet_version);
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|     17|#define ISOAPPLET_VERSION_V0 0x0006
  |  |  |  |  ------------------
  |  |  |  |               			   ISOAPPLET_VERSION_V0, ISOAPPLET_VERSION_V1, drvdata->isoapplet_version);
  |  |  |  |  ------------------
  |  |  |  |  |  |   37|     17|#define ISOAPPLET_VERSION_V1 0x0100
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  179|     17|			   "API versions: Driver (%04X or %04X), applet (%04X). Please update accordingly.",
  180|     17|			   ISOAPPLET_VERSION_V0, ISOAPPLET_VERSION_V1, drvdata->isoapplet_version);
  181|     17|		r = SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|     17|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  182|     17|		goto err;
  183|     17|	}
  184|    173|	else if(drvdata->isoapplet_version != ISOAPPLET_VERSION_V0 && drvdata->isoapplet_version != ISOAPPLET_VERSION_V1)
  ------------------
  |  |   36|    346|#define ISOAPPLET_VERSION_V0 0x0006
  ------------------
              	else if(drvdata->isoapplet_version != ISOAPPLET_VERSION_V0 && drvdata->isoapplet_version != ISOAPPLET_VERSION_V1)
  ------------------
  |  |   37|    172|#define ISOAPPLET_VERSION_V1 0x0100
  ------------------
  |  Branch (184:10): [True: 172, False: 1]
  |  Branch (184:64): [True: 170, False: 2]
  ------------------
  185|    170|	{
  186|    170|		sc_log(card->ctx, "IsoApplet: Mismatching minor version. Proceeding anyway. "
  ------------------
  |  |   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__
  |  |  ------------------
  |  |               #define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |  189|    170|			   ISOAPPLET_VERSION_V0, ISOAPPLET_VERSION_V1, drvdata->isoapplet_version);
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|    170|#define ISOAPPLET_VERSION_V0 0x0006
  |  |  |  |  ------------------
  |  |  |  |               			   ISOAPPLET_VERSION_V0, ISOAPPLET_VERSION_V1, drvdata->isoapplet_version);
  |  |  |  |  ------------------
  |  |  |  |  |  |   37|    170|#define ISOAPPLET_VERSION_V1 0x0100
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  187|    170|			   "API versions: Driver (%04X or %04X), applet (%04X). "
  188|    170|			   "Please update accordingly whenever possible.",
  189|    170|			   ISOAPPLET_VERSION_V0, ISOAPPLET_VERSION_V1, drvdata->isoapplet_version);
  190|    170|	}
  191|       |
  192|    173|	if(drvdata->isoapplet_features & ISOAPPLET_API_FEATURE_EXT_APDU)
  ------------------
  |  |   39|    173|#define ISOAPPLET_API_FEATURE_EXT_APDU 0x01
  ------------------
  |  Branch (192:5): [True: 4, False: 169]
  ------------------
  193|      4|		card->caps |=  SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  547|      4|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  194|    173|	if(drvdata->isoapplet_features & ISOAPPLET_API_FEATURE_SECURE_RANDOM)
  ------------------
  |  |   40|    173|#define ISOAPPLET_API_FEATURE_SECURE_RANDOM 0x02
  ------------------
  |  Branch (194:5): [True: 6, False: 167]
  ------------------
  195|      6|		card->caps |=  SC_CARD_CAP_RNG;
  ------------------
  |  |  550|      6|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  196|    173|	if(drvdata->isoapplet_version <= 0x0005
  ------------------
  |  Branch (196:5): [True: 144, False: 29]
  ------------------
  197|     29|			|| drvdata->isoapplet_features & ISOAPPLET_API_FEATURE_ECC)
  ------------------
  |  |   41|     29|#define ISOAPPLET_API_FEATURE_ECC 0x04
  ------------------
  |  Branch (197:7): [True: 7, False: 22]
  ------------------
  198|    151|	{
  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|    151|		flags = 0;
  206|    151|		if (major_version == (ISOAPPLET_VERSION_V0 & 0xFF00)) {
  ------------------
  |  |   36|    151|#define ISOAPPLET_VERSION_V0 0x0006
  ------------------
  |  Branch (206:7): [True: 149, False: 2]
  ------------------
  207|    149|			flags |= SC_ALGORITHM_ECDSA_HASH_SHA1;
  ------------------
  |  |  176|    149|#define SC_ALGORITHM_ECDSA_HASH_SHA1		SC_ALGORITHM_RSA_HASH_SHA1
  |  |  ------------------
  |  |  |  |  134|    149|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  ------------------
  ------------------
  208|    149|		} else { // ISOAPPLET_VERSION_V1
  209|      2|			flags |= SC_ALGORITHM_ECDSA_RAW;
  ------------------
  |  |  174|      2|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
  210|      2|			flags |= SC_ALGORITHM_ECDSA_HASH_NONE;
  ------------------
  |  |  175|      2|#define SC_ALGORITHM_ECDSA_HASH_NONE		SC_ALGORITHM_RSA_HASH_NONE
  |  |  ------------------
  |  |  |  |  133|      2|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  ------------------
  211|      2|		}
  212|    151|		flags |= SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|    151|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  213|    151|		ext_flags = SC_ALGORITHM_EXT_EC_UNCOMPRESES;
  ------------------
  |  |  202|    151|#define SC_ALGORITHM_EXT_EC_UNCOMPRESES  0x00000010
  ------------------
  214|    151|		ext_flags |=  SC_ALGORITHM_EXT_EC_NAMEDCURVE;
  ------------------
  |  |  201|    151|#define SC_ALGORITHM_EXT_EC_NAMEDCURVE   0x00000008
  ------------------
  215|    151|		ext_flags |= SC_ALGORITHM_EXT_EC_F_P;
  ------------------
  |  |  198|    151|#define SC_ALGORITHM_EXT_EC_F_P          0x00000001
  ------------------
  216|  1.66k|		for (i=0; ec_curves[i].oid.value[0] >= 0; i++)
  ------------------
  |  Branch (216:13): [True: 1.51k, False: 151]
  ------------------
  217|  1.51k|		{
  218|  1.51k|			if(drvdata->isoapplet_version >= ec_curves[i].min_applet_version)
  ------------------
  |  Branch (218:7): [True: 1.22k, False: 288]
  ------------------
  219|  1.22k|				_sc_card_add_ec_alg(card, ec_curves[i].size, flags, ext_flags, &ec_curves[i].oid);
  220|  1.51k|		}
  221|    151|	}
  222|       |
  223|       |	/* RSA */
  224|    173|	flags = 0;
  225|    173|	flags |= SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |  111|    173|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|    173|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|    173|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  226|    173|	flags |= SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  133|    173|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  227|    173|	if(drvdata->isoapplet_features & ISOAPPLET_API_FEATURE_RSA_PSS) {
  ------------------
  |  |   42|    173|#define ISOAPPLET_API_FEATURE_RSA_PSS 0x08
  ------------------
  |  Branch (227:5): [True: 5, False: 168]
  ------------------
  228|      5|		flags |= SC_ALGORITHM_RSA_PAD_PSS;
  ------------------
  |  |  107|      5|#define SC_ALGORITHM_RSA_PAD_PSS	0x00000010 /* PKCS#1 v2.0 PSS */
  ------------------
  229|      5|	}
  230|       |	/* Key-generation: */
  231|    173|	flags |= SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|    173|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  232|       |	/* Modulus lengths: */
  233|    173|	_sc_card_add_rsa_alg(card, 2048, flags, 0);
  234|    173|	if (drvdata->isoapplet_features & ISOAPPLET_API_FEATURE_RSA_4096) {
  ------------------
  |  |   43|    173|#define ISOAPPLET_API_FEATURE_RSA_4096 0x20
  ------------------
  |  Branch (234:6): [True: 6, False: 167]
  ------------------
  235|      6|		_sc_card_add_rsa_alg(card, 4096, flags, 0);
  236|      6|	}
  237|       |
  238|    173|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    173|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    173|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    173|	int _ret = r; \
  |  |  |  |  155|    173|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 173, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    173|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 173]
  |  |  |  |  ------------------
  |  |  |  |  157|    173|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    173|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    173|	return _ret; \
  |  |  |  |  163|    173|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  239|     28|err:
  240|     28|	free(drvdata);
  241|     28|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     28|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     28|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     28|	int _ret = r; \
  |  |  |  |  155|     28|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 28, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     28|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     28|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 28, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     28|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     28|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     28|	return _ret; \
  |  |  |  |  163|     28|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  242|     28|}
card-isoApplet.c:isoApplet_get_info:
  124|    201|isoApplet_get_info(sc_card_t * card, struct isoApplet_drv_data * drvdata) {
  125|    201|	u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
  126|    201|	int rv;
  127|    201|	sc_context_t * ctx = card->ctx;
  128|       |
  129|    201|	rv = sc_get_data(card, 0x0101, rbuf, 3);
  130|    201|	if(rv == SC_ERROR_INS_NOT_SUPPORTED) {
  ------------------
  |  |   54|    201|#define SC_ERROR_INS_NOT_SUPPORTED		-1204
  ------------------
  |  Branch (130:5): [True: 23, False: 178]
  ------------------
  131|       |		/* INS not supported. This is an older IsoApplet that might return the
  132|       |		 * applet information upon selection. For backward compatibility, try this. */
  133|     23|		size_t rlen = sizeof(rbuf);
  134|     23|		rv = iso7816_select_aid(card, isoApplet_aid, sizeof(isoApplet_aid), rbuf, &rlen);
  135|     23|		LOG_TEST_RET(ctx, rv, "Error selecting applet.");
  ------------------
  |  |  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: 5, False: 18]
  |  |  |  |  ------------------
  |  |  |  |  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|     23|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 18]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  136|     18|		rv = (int)rlen;
  137|     18|	}
  138|       |
  139|    196|	if (rv < 0) {
  ------------------
  |  Branch (139:6): [True: 6, False: 190]
  ------------------
  140|      6|		LOG_TEST_RET(ctx, rv, "Card returned error.");
  ------------------
  |  |  174|      6|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      6|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      6|	int _ret = (r); \
  |  |  |  |  168|      6|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      6|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      6|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      6|		return _ret; \
  |  |  |  |  172|      6|	} \
  |  |  |  |  173|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  141|      6|	}
  142|       |
  143|       |	/* Fill up drvdata */
  144|    190|	if(rv >= 3)
  ------------------
  |  Branch (144:5): [True: 49, False: 141]
  ------------------
  145|     49|	{
  146|     49|		drvdata->isoapplet_version = rbuf[0] << 8 | rbuf[1];
  147|     49|		drvdata->isoapplet_features = rbuf[2];
  148|     49|	}
  149|       |
  150|    190|	return SC_SUCCESS;
  ------------------
  |  |   28|    190|#define SC_SUCCESS				0
  ------------------
  151|    196|}
card-isoApplet.c:isoApplet_finish:
   97|    173|{
   98|    173|	struct isoApplet_drv_data *drvdata=DRVDATA(card);
  ------------------
  |  |   59|    173|#define DRVDATA(card)	((struct isoApplet_drv_data *) ((card)->drv_data))
  ------------------
   99|       |
  100|    173|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    173|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    173|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    173|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    173|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 173]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  101|    173|	if (drvdata)
  ------------------
  |  Branch (101:6): [True: 173, False: 0]
  ------------------
  102|    173|	{
  103|    173|		free(drvdata);
  104|    173|		card->drv_data=NULL;
  105|    173|	}
  106|    173|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    173|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    173|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    173|	int _ret = r; \
  |  |  |  |  155|    173|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 173, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    173|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 173]
  |  |  |  |  ------------------
  |  |  |  |  157|    173|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    173|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    173|	return _ret; \
  |  |  |  |  163|    173|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  107|    173|}
card-isoApplet.c:isoApplet_card_ctl:
 1037|    419|{
 1038|    419|	int r = 0;
 1039|       |
 1040|    419|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    419|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    419|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    419|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    419|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 419]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1041|    419|	switch (cmd)
 1042|    419|	{
 1043|     42|	case SC_CARDCTL_ISOAPPLET_GENERATE_KEY:
  ------------------
  |  Branch (1043:2): [True: 42, False: 377]
  ------------------
 1044|     42|		r = isoApplet_ctl_generate_key(card,
 1045|     42|		                               (sc_cardctl_isoApplet_genkey_t *) ptr);
 1046|     42|		break;
 1047|      0|	case SC_CARDCTL_ISOAPPLET_IMPORT_KEY:
  ------------------
  |  Branch (1047:2): [True: 0, False: 419]
  ------------------
 1048|      0|		r = isoApplet_ctl_import_key(card,
 1049|      0|		                             (sc_cardctl_isoApplet_import_key_t *) ptr);
 1050|      0|		break;
 1051|    377|	default:
  ------------------
  |  Branch (1051:2): [True: 377, False: 42]
  ------------------
 1052|    377|		r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    377|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1053|    419|	}
 1054|    419|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    419|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    419|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    419|	int _ret = r; \
  |  |  |  |  155|    419|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 419, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    419|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    419|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 419, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    419|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    419|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    419|	return _ret; \
  |  |  |  |  163|    419|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1055|    419|}
card-isoApplet.c:isoApplet_ctl_generate_key:
  528|     42|{
  529|     42|	int r;
  530|     42|	sc_apdu_t apdu;
  531|     42|	u8 rbuf[SC_MAX_EXT_APDU_RESP_SIZE];
  532|     42|	u8 sbuf[SC_MAX_EXT_APDU_DATA_SIZE];
  533|     42|	u8 *p;
  534|     42|	const u8 *inner_tag_value;
  535|     42|	const u8 *outer_tag_value;
  536|     42|	unsigned int tag;
  537|     42|	size_t outer_tag_len;
  538|     42|	size_t inner_tag_len;
  539|     42|	unsigned int cla;
  540|     42|	size_t sz;
  541|       |
  542|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  543|       |
  544|       |	/* MANAGE SECURITY ENVIRONMENT (SET). Set the algorithm and key references. */
  545|     42|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x22, 0x41, 0x00);
  ------------------
  |  |  293|     42|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  546|       |
  547|     42|	p = sbuf;
  548|     42|	*p++ = 0x80; /* algorithm reference */
  549|     42|	*p++ = 0x01;
  550|     42|	*p++ = args->algorithm_ref;
  551|       |
  552|     42|	*p++ = 0x84; /* Private key reference */
  553|     42|	*p++ = 0x01;
  554|     42|	*p++ = args->priv_key_ref;
  555|       |
  556|     42|	sz = p - sbuf;
  557|     42|	p = NULL;
  558|       |
  559|     42|	apdu.lc = sz;
  560|     42|	apdu.datalen = sz;
  561|     42|	apdu.data = sbuf;
  562|       |
  563|     42|	r = sc_transmit_apdu(card, &apdu);
  564|     42|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     42|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     42|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     42|	int _ret = (r); \
  |  |  |  |  168|     42|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 39]
  |  |  |  |  ------------------
  |  |  |  |  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|     42|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 39]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  565|       |
  566|     39|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  567|     39|	LOG_TEST_RET(card->ctx, r, "Card returned error");
  ------------------
  |  |  174|     39|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     39|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     39|	int _ret = (r); \
  |  |  |  |  168|     39|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 22, False: 17]
  |  |  |  |  ------------------
  |  |  |  |  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|     39|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 17]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  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|     17|	if(args->algorithm_ref == SC_ISOAPPLET_ALG_REF_EC_GEN)
  ------------------
  |  |  993|     17|#define SC_ISOAPPLET_ALG_REF_EC_GEN 0xEC
  ------------------
  |  Branch (578:5): [True: 17, False: 0]
  ------------------
  579|     17|	{
  580|     17|		sc_format_apdu(card, &apdu, SC_APDU_CASE_4, 0x46, 0x00, 0x00);
  ------------------
  |  |  303|     17|#define SC_APDU_CASE_4			0x24
  ------------------
  581|     17|		apdu.data = sbuf;
  582|     17|		p = sbuf;
  583|     17|		r = isoApplet_put_ec_params(card, &args->pubkey.ec.params, p, sizeof(sbuf), &p);
  584|     17|		LOG_TEST_RET(card->ctx, r, "Error composing EC params.");
  ------------------
  |  |  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: 0, False: 17]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|     17|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 17]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  585|     17|		apdu.datalen = p - sbuf;
  586|     17|		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|     17|		if ((apdu.datalen > 255) && !(card->caps & SC_CARD_CAP_APDU_EXT))
  ------------------
  |  |  547|      0|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (589:7): [True: 0, False: 17]
  |  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|     17|	}
  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|     17|	apdu.resp = rbuf;
  600|     17|	apdu.resplen = sizeof(rbuf);
  601|     17|	if (card->caps & SC_CARD_CAP_APDU_EXT) {
  ------------------
  |  |  547|     17|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (601:6): [True: 1, False: 16]
  ------------------
  602|      1|		apdu.le = apdu.resplen;
  603|     16|	} else {
  604|     16|		apdu.le = 256;
  605|     16|	}
  606|     17|	r = sc_transmit_apdu(card, &apdu);
  607|     17|	LOG_TEST_RET(card->ctx, r, "APDU transmit 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: 1, False: 16]
  |  |  |  |  ------------------
  |  |  |  |  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|     17|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 16]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  608|       |
  609|     16|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  610|     16|	if(apdu.sw1 == 0x6A && apdu.sw2 == 0x81)
  ------------------
  |  Branch (610:5): [True: 3, False: 13]
  |  Branch (610:25): [True: 1, False: 2]
  ------------------
  611|      1|	{
  612|      1|		sc_log(card->ctx, "Key generation not supported by the card with that particular key type. "
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  613|      1|		       "Your card may not support the specified algorithm used by the applet / specified by you. "
  614|      1|		       "In most cases, this happens when trying to generate EC keys not supported by your java card. "
  615|      1|		       "In this case, look for supported field lengths and whether FP and/or F2M are supported.");
  616|      1|	}
  617|     16|	LOG_TEST_RET(card->ctx, r, "Card returned error");
  ------------------
  |  |  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: 8, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  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|     16|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  618|       |
  619|       |	/* Parse the public key / response. */
  620|      8|	outer_tag_value = apdu.resp;
  621|      8|	r = sc_asn1_read_tag(&outer_tag_value, apdu.resplen, &cla, &tag, &outer_tag_len);
  622|      8|	LOG_TEST_RET(card->ctx, r, "Error in ASN1 handling.");
  ------------------
  |  |  174|      8|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      8|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      8|	int _ret = (r); \
  |  |  |  |  168|      8|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 4, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  169|      4|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      4|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      4|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      4|		return _ret; \
  |  |  |  |  172|      4|	} \
  |  |  |  |  173|      8|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  623|       |	/* Interindustry template for nesting one set of public key data objects */
  624|      4|	if((tag != 0x1F49) || (cla != 0x60))
  ------------------
  |  Branch (624:5): [True: 4, False: 0]
  |  Branch (624:24): [True: 0, False: 0]
  ------------------
  625|      4|	{
  626|      4|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_DATA,
  ------------------
  |  |  174|      4|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      4|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      4|	int _ret = (r); \
  |  |  |  |  168|      4|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 4, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      4|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      4|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      4|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      4|		return _ret; \
  |  |  |  |  172|      4|	} \
  |  |  |  |  173|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  627|      4|		             "The data returned by the card is unexpected.");
  628|      4|	}
  629|       |
  630|      0|	switch(args->algorithm_ref)
  631|      0|	{
  632|       |
  633|      0|	case SC_ISOAPPLET_ALG_REF_RSA_GEN_2048:
  ------------------
  |  |  991|      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:
  ------------------
  |  |  992|      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;
  ------------------
  |  |  991|      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:
  ------------------
  |  |  993|      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|     17|{
  484|     17|	u8 *p = out;
  485|     17|	int r;
  486|       |
  487|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  488|       |
  489|     17|	if(!params
  ------------------
  |  Branch (489:5): [True: 0, False: 17]
  ------------------
  490|     17|	        || !params->prime.value
  ------------------
  |  Branch (490:13): [True: 0, False: 17]
  ------------------
  491|     17|	        || !params->coefficientA.value
  ------------------
  |  Branch (491:13): [True: 0, False: 17]
  ------------------
  492|     17|	        || !params->coefficientB.value
  ------------------
  |  Branch (492:13): [True: 0, False: 17]
  ------------------
  493|     17|	        || !params->basePointG.value
  ------------------
  |  Branch (493:13): [True: 0, False: 17]
  ------------------
  494|     17|	        || !params->order.value
  ------------------
  |  Branch (494:13): [True: 0, False: 17]
  ------------------
  495|     17|	        || !params->coFactor.value)
  ------------------
  |  Branch (495:13): [True: 0, False: 17]
  ------------------
  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|     17|	if(out == NULL || out_len == 0)
  ------------------
  |  Branch (500:5): [True: 0, False: 17]
  |  Branch (500:20): [True: 0, False: 17]
  ------------------
  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|     17|	r = sc_asn1_put_tag(0x81, params->prime.value, params->prime.len, p, out_len - (p - out), &p);
  506|     17|	LOG_TEST_RET(card->ctx, r, "Error in handling TLV.");
  ------------------
  |  |  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: 0, False: 17]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|     17|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 17]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  507|     17|	r = sc_asn1_put_tag(0x82, params->coefficientA.value, params->coefficientA.len, p, out_len - (p - out), &p);
  508|     17|	LOG_TEST_RET(card->ctx, r, "Error in handling TLV.");
  ------------------
  |  |  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: 0, False: 17]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|     17|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 17]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  509|     17|	r = sc_asn1_put_tag(0x83, params->coefficientB.value, params->coefficientB.len, p, out_len - (p - out), &p);
  510|     17|	LOG_TEST_RET(card->ctx, r, "Error in handling TLV.");
  ------------------
  |  |  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: 0, False: 17]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|     17|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 17]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  511|     17|	r = sc_asn1_put_tag(0x84, params->basePointG.value, params->basePointG.len, p, out_len - (p - out), &p);
  512|     17|	LOG_TEST_RET(card->ctx, r, "Error in handling TLV.");
  ------------------
  |  |  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: 0, False: 17]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|     17|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 17]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  513|     17|	r = sc_asn1_put_tag(0x85, params->order.value, params->order.len, p, out_len - (p - out), &p);
  514|     17|	LOG_TEST_RET(card->ctx, r, "Error in handling TLV.");
  ------------------
  |  |  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: 0, False: 17]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|     17|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 17]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  515|     17|	r = sc_asn1_put_tag(0x87, params->coFactor.value, params->coFactor.len, p, out_len - (p - out), &p);
  516|     17|	LOG_TEST_RET(card->ctx, r, "Error in handling TLV.");
  ------------------
  |  |  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: 0, False: 17]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|     17|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 17]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  517|       |
  518|     17|	if (ptr != NULL)
  ------------------
  |  Branch (518:6): [True: 17, False: 0]
  ------------------
  519|     17|		*ptr = p;
  520|     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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 17]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  521|     17|}
card-isoApplet.c:isoApplet_create_file:
  293|    117|{
  294|    117|	int r = 0;
  295|       |
  296|    117|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    117|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    117|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    117|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    117|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 117]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  297|       |
  298|    117|	if(file->sec_attr_len == 0)
  ------------------
  |  Branch (298:5): [True: 105, False: 12]
  ------------------
  299|    105|	{
  300|    105|		u8 access_buf[8];
  301|    105|		int idx[8], i;
  302|       |
  303|    105|		if(file->type == SC_FILE_TYPE_DF)
  ------------------
  |  |  214|    105|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (303:6): [True: 72, False: 33]
  ------------------
  304|     72|		{
  305|     72|			const int df_idx[8] = /* These are the SC operations. */
  306|     72|			{
  307|     72|				0, /* Reserved. */
  308|     72|				SC_AC_OP_DELETE_SELF, /* b6 */
  ------------------
  |  |  174|     72|#define SC_AC_OP_DELETE_SELF		8
  ------------------
  309|     72|				SC_AC_OP_LOCK,        /* b5 */
  ------------------
  |  |  167|     72|#define SC_AC_OP_LOCK			1
  ------------------
  310|     72|				SC_AC_OP_ACTIVATE,    /* b4 */
  ------------------
  |  |  186|     72|#define SC_AC_OP_ACTIVATE		20
  ------------------
  311|     72|				SC_AC_OP_DEACTIVATE,  /* b3 */
  ------------------
  |  |  187|     72|#define SC_AC_OP_DEACTIVATE		21
  ------------------
  312|     72|				SC_AC_OP_CREATE_DF,   /* b2 */
  ------------------
  |  |  194|     72|#define SC_AC_OP_CREATE_DF		28
  ------------------
  313|     72|				SC_AC_OP_CREATE_EF,   /* b1 */
  ------------------
  |  |  193|     72|#define SC_AC_OP_CREATE_EF		27
  ------------------
  314|     72|				SC_AC_OP_DELETE       /* b0 */
  ------------------
  |  |  168|     72|#define SC_AC_OP_DELETE			2
  ------------------
  315|     72|			};
  316|    648|			for(i=0; i<8; i++)
  ------------------
  |  Branch (316:13): [True: 576, False: 72]
  ------------------
  317|    576|			{
  318|    576|				idx[i] = df_idx[i];
  319|    576|			}
  320|     72|		}
  321|     33|		else   /* EF */
  322|     33|		{
  323|     33|			const int ef_idx[8] =
  324|     33|			{
  325|     33|				0, /* Reserved. */
  326|     33|				SC_AC_OP_DELETE_SELF, /* b6 */
  ------------------
  |  |  174|     33|#define SC_AC_OP_DELETE_SELF		8
  ------------------
  327|     33|				SC_AC_OP_LOCK,        /* b5 */
  ------------------
  |  |  167|     33|#define SC_AC_OP_LOCK			1
  ------------------
  328|     33|				SC_AC_OP_ACTIVATE,    /* b4 */
  ------------------
  |  |  186|     33|#define SC_AC_OP_ACTIVATE		20
  ------------------
  329|     33|				SC_AC_OP_DEACTIVATE,  /* b3 */
  ------------------
  |  |  187|     33|#define SC_AC_OP_DEACTIVATE		21
  ------------------
  330|     33|				SC_AC_OP_WRITE,       /* b2 */
  ------------------
  |  |  190|     33|#define SC_AC_OP_WRITE			24
  ------------------
  331|     33|				SC_AC_OP_UPDATE,      /* b1 */
  ------------------
  |  |  189|     33|#define SC_AC_OP_UPDATE			23
  ------------------
  332|     33|				SC_AC_OP_READ         /* b0 */
  ------------------
  |  |  188|     33|#define SC_AC_OP_READ			22
  ------------------
  333|     33|			};
  334|    297|			for(i=0; i<8; i++)
  ------------------
  |  Branch (334:13): [True: 264, False: 33]
  ------------------
  335|    264|			{
  336|    264|				idx[i] = ef_idx[i];
  337|    264|			}
  338|     33|		}
  339|       |		/* Now idx contains the operation identifiers.
  340|       |		 * We now search for the OPs. */
  341|    105|		access_buf[0] = 0xFF; /* A security condition byte is present for every OP. (Table 19) */
  342|    840|		for(i=1; i<8; i++)
  ------------------
  |  Branch (342:12): [True: 735, False: 105]
  ------------------
  343|    735|		{
  344|    735|			const sc_acl_entry_t *entry;
  345|    735|			entry = sc_file_get_acl_entry(file, idx[i]);
  346|    735|			access_buf[i] = isoApplet_acl_to_security_condition_byte(entry);
  347|    735|		}
  348|       |
  349|    105|		r = sc_file_set_sec_attr(file, access_buf, 8);
  350|    105|		LOG_TEST_RET(card->ctx, r, "Error adding security attribute.");
  ------------------
  |  |  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: 0, False: 105]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|    105|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 105]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  351|    105|	}
  352|       |
  353|    117|	r = iso_ops->create_file(card, file);
  354|    117|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    117|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    117|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    117|	int _ret = r; \
  |  |  |  |  155|    117|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 117, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    117|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     28|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 28, False: 89]
  |  |  |  |  ------------------
  |  |  |  |  157|    117|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    117|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    117|	return _ret; \
  |  |  |  |  163|    117|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  355|    117|}
card-isoApplet.c:isoApplet_acl_to_security_condition_byte:
  258|    735|{
  259|    735|	if(!entry)
  ------------------
  |  Branch (259:5): [True: 0, False: 735]
  ------------------
  260|      0|		return 0x00;
  261|    735|	switch(entry->method)
  262|    735|	{
  263|     51|	case SC_AC_CHV:
  ------------------
  |  |  151|     51|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (263:2): [True: 51, False: 684]
  ------------------
  264|     51|		return 0x90;
  265|     12|	case SC_AC_NEVER:
  ------------------
  |  |  163|     12|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (265:2): [True: 12, False: 723]
  ------------------
  266|     12|		return 0xFF;
  267|    503|	case SC_AC_NONE:
  ------------------
  |  |  150|    503|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (267:2): [True: 503, False: 232]
  ------------------
  268|    672|	default:
  ------------------
  |  Branch (268:2): [True: 169, False: 566]
  ------------------
  269|    672|		return 0x00;
  270|    735|	}
  271|    735|}
card-isoApplet.c:isoApplet_process_fci:
  405|    200|{
  406|    200|	int r;
  407|    200|	u8 *sa = NULL;
  408|       |
  409|    200|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    200|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    200|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    200|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    200|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 200]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  410|       |
  411|    200|	r = iso_ops->process_fci(card, file, buf, buflen);
  412|    200|	LOG_TEST_RET(card->ctx, r, "Error while processing the FCI.");
  ------------------
  |  |  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: 0, False: 200]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|    200|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 200]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  413|       |	/* Construct the ACL from the sec_attr. */
  414|    200|	if(file->sec_attr && file->sec_attr_len == 8)
  ------------------
  |  Branch (414:5): [True: 144, False: 56]
  |  Branch (414:23): [True: 58, False: 86]
  ------------------
  415|     58|	{
  416|     58|		sa = file->sec_attr;
  417|     58|		if(sa[0] != 0xFF)
  ------------------
  |  Branch (417:6): [True: 10, False: 48]
  ------------------
  418|     10|		{
  419|     10|			LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_DATA,
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  420|     10|			             "File security attribute does not contain a ACL byte for every operation.");
  421|     10|		}
  422|     48|		if(file->type == SC_FILE_TYPE_DF)
  ------------------
  |  |  214|     48|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (422:6): [True: 11, False: 37]
  ------------------
  423|     11|		{
  424|     11|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_DELETE_SELF, sa[1]);
  ------------------
  |  |  174|     11|#define SC_AC_OP_DELETE_SELF		8
  ------------------
  425|     11|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  426|     11|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_LOCK, sa[2]);
  ------------------
  |  |  167|     11|#define SC_AC_OP_LOCK			1
  ------------------
  427|     11|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  428|     11|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_ACTIVATE, sa[3]);
  ------------------
  |  |  186|     11|#define SC_AC_OP_ACTIVATE		20
  ------------------
  429|     11|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  430|     11|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_DEACTIVATE, sa[4]);
  ------------------
  |  |  187|     11|#define SC_AC_OP_DEACTIVATE		21
  ------------------
  431|     11|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  432|     11|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_CREATE_DF, sa[5]);
  ------------------
  |  |  194|     11|#define SC_AC_OP_CREATE_DF		28
  ------------------
  433|     11|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  434|     11|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_CREATE_EF, sa[6]);
  ------------------
  |  |  193|     11|#define SC_AC_OP_CREATE_EF		27
  ------------------
  435|     11|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  436|     11|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_DELETE, sa[7]);
  ------------------
  |  |  168|     11|#define SC_AC_OP_DELETE			2
  ------------------
  437|     11|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  438|     11|		}
  439|     37|		else if(file->type == SC_FILE_TYPE_INTERNAL_EF
  ------------------
  |  |  215|     74|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (439:11): [True: 10, False: 27]
  ------------------
  440|     27|		        || file->type == SC_FILE_TYPE_WORKING_EF)
  ------------------
  |  |  216|     27|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (440:14): [True: 21, False: 6]
  ------------------
  441|     31|		{
  442|     31|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_DELETE_SELF, sa[1]);
  ------------------
  |  |  174|     31|#define SC_AC_OP_DELETE_SELF		8
  ------------------
  443|     31|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  444|     31|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_LOCK, sa[2]);
  ------------------
  |  |  167|     31|#define SC_AC_OP_LOCK			1
  ------------------
  445|     31|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  446|     31|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_ACTIVATE, sa[3]);
  ------------------
  |  |  186|     31|#define SC_AC_OP_ACTIVATE		20
  ------------------
  447|     31|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  448|     31|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_DEACTIVATE, sa[4]);
  ------------------
  |  |  187|     31|#define SC_AC_OP_DEACTIVATE		21
  ------------------
  449|     31|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  450|     31|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_WRITE, sa[5]);
  ------------------
  |  |  190|     31|#define SC_AC_OP_WRITE			24
  ------------------
  451|     31|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  452|     31|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_UPDATE, sa[6]);
  ------------------
  |  |  189|     31|#define SC_AC_OP_UPDATE			23
  ------------------
  453|     31|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  454|     31|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_READ, sa[7]);
  ------------------
  |  |  188|     31|#define SC_AC_OP_READ			22
  ------------------
  455|     31|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  456|     31|		}
  457|       |
  458|     48|	}
  459|       |
  460|    190|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    190|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    190|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    190|	int _ret = r; \
  |  |  |  |  155|    190|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 190, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    190|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 190]
  |  |  |  |  ------------------
  |  |  |  |  157|    190|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    190|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    190|	return _ret; \
  |  |  |  |  163|    190|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  461|    190|}
card-isoApplet.c:isoApplet_add_sa_to_acl:
  368|    294|{
  369|    294|	int r;
  370|       |
  371|    294|	switch(saByte)
  372|    294|	{
  373|     15|	case 0x90:
  ------------------
  |  Branch (373:2): [True: 15, False: 279]
  ------------------
  374|     15|		r = sc_file_add_acl_entry(file, operation, SC_AC_CHV, 1);
  ------------------
  |  |  151|     15|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  375|     15|		if(r < 0)
  ------------------
  |  Branch (375:6): [True: 0, False: 15]
  ------------------
  376|      0|			return r;
  377|     15|		break;
  378|     62|	case 0xFF:
  ------------------
  |  Branch (378:2): [True: 62, False: 232]
  ------------------
  379|     62|		r = sc_file_add_acl_entry(file, operation, SC_AC_NEVER, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  163|     62|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
              		r = sc_file_add_acl_entry(file, operation, SC_AC_NEVER, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|     62|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  380|     62|		if(r < 0)
  ------------------
  |  Branch (380:6): [True: 0, False: 62]
  ------------------
  381|      0|			return r;
  382|     62|		break;
  383|    104|	case 0x00:
  ------------------
  |  Branch (383:2): [True: 104, False: 190]
  ------------------
  384|    104|		r = sc_file_add_acl_entry(file, operation, SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  150|    104|#define SC_AC_NONE			0x00000000
  ------------------
              		r = sc_file_add_acl_entry(file, operation, SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|    104|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  385|    104|		if(r < 0)
  ------------------
  |  Branch (385:6): [True: 0, False: 104]
  ------------------
  386|      0|			return r;
  387|    104|		break;
  388|    113|	default:
  ------------------
  |  Branch (388:2): [True: 113, False: 181]
  ------------------
  389|    113|		r = sc_file_add_acl_entry(file, operation, SC_AC_UNKNOWN, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  162|    113|#define SC_AC_UNKNOWN			0xFFFFFFFE
  ------------------
              		r = sc_file_add_acl_entry(file, operation, SC_AC_UNKNOWN, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|    113|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  390|    113|		if(r < 0)
  ------------------
  |  Branch (390:6): [True: 0, False: 113]
  ------------------
  391|      0|			return r;
  392|    294|	}
  393|    294|	return SC_SUCCESS;
  ------------------
  |  |   28|    294|#define SC_SUCCESS				0
  ------------------
  394|    294|}
card-isoApplet.c:isoApplet_card_reader_lock_obtained:
 1241|  4.88k|{
 1242|  4.88k|	int r = SC_SUCCESS;
  ------------------
  |  |   28|  4.88k|#define SC_SUCCESS				0
  ------------------
 1243|       |
 1244|  4.88k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  4.88k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  4.88k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  4.88k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 4.88k]
  |  |  ------------------
  ------------------
 1245|       |
 1246|  4.88k|	if (was_reset > 0) {
  ------------------
  |  Branch (1246:6): [True: 0, False: 4.88k]
  ------------------
 1247|      0|		r = iso7816_select_aid(card, isoApplet_aid, sizeof(isoApplet_aid), NULL, NULL);
 1248|      0|	}
 1249|       |
 1250|  4.88k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  4.88k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  4.88k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  4.88k|	int _ret = r; \
  |  |  |  |  155|  4.88k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4.88k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  4.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: 4.88k]
  |  |  |  |  ------------------
  |  |  |  |  157|  4.88k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  4.88k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|  4.88k|	return _ret; \
  |  |  |  |  163|  4.88k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1251|  4.88k|}

sc_get_itacns_driver:
  523|  16.3k|{
  524|  16.3k|	return sc_get_driver();
  525|  16.3k|}
card-itacns.c:sc_get_driver:
  504|  16.3k|{
  505|  16.3k|	if (!default_ops)
  ------------------
  |  Branch (505:6): [True: 1, False: 16.3k]
  ------------------
  506|      1|		default_ops = sc_get_iso7816_driver()->ops;
  507|  16.3k|	itacns_ops = *default_ops;
  508|  16.3k|	itacns_ops.match_card = itacns_match_card;
  509|  16.3k|	itacns_ops.init = itacns_init;
  510|  16.3k|	itacns_ops.finish = itacns_finish;
  511|  16.3k|	itacns_ops.set_security_env = itacns_set_security_env;
  512|  16.3k|	itacns_ops.restore_security_env = itacns_restore_security_env;
  513|  16.3k|	itacns_ops.pin_cmd = itacns_pin_cmd;
  514|  16.3k|	itacns_ops.read_binary = itacns_read_binary;
  515|  16.3k|	itacns_ops.list_files = itacns_list_files;
  516|  16.3k|	itacns_ops.select_file = itacns_select_file;
  517|  16.3k|	itacns_ops.card_ctl = itacns_card_ctl;
  518|  16.3k|	itacns_ops.get_challenge = itacns_get_challenge;
  519|  16.3k|	return &itacns_drv;
  520|  16.3k|}
card-itacns.c:itacns_match_card:
  122|  3.67k|{
  123|  3.67k|	int r = 0;
  124|       |
  125|       |	/* Try table first */
  126|  3.67k|	r = _sc_match_atr(card, itacns_atrs, &card->type);
  127|  3.67k|	if(r >= 0) return 1;
  ------------------
  |  Branch (127:5): [True: 1, False: 3.67k]
  ------------------
  128|       |
  129|  3.67k|	if (itacns_match_cns_card(card)) return 1;
  ------------------
  |  Branch (129:6): [True: 24, False: 3.65k]
  ------------------
  130|  3.65k|	if (itacns_match_cie_card(card)) return 1;
  ------------------
  |  Branch (130:6): [True: 1, False: 3.65k]
  ------------------
  131|       |
  132|       |	/* No card type was matched. */
  133|  3.65k|	return 0;
  134|  3.65k|}
card-itacns.c:itacns_match_cns_card:
   85|  3.67k|{
   86|  3.67k|	u8 manufacturer_code;
   87|  3.67k|	u8 manufacturer_mask;
   88|  3.67k|	u8 fw_major;
   89|       |
   90|  3.67k|	if (15 != card->reader->atr_info.hist_bytes_len ||
  ------------------
  |  Branch (90:6): [True: 3.52k, False: 148]
  ------------------
   91|    148|	    0 != memcmp(card->reader->atr_info.hist_bytes+9, "CNS", 3))
  ------------------
  |  Branch (91:6): [True: 124, False: 24]
  ------------------
   92|  3.65k|		return 0;
   93|       |
   94|     24|	card->type = SC_CARD_TYPE_ITACNS_CNS;
   95|       |
   96|     24|	manufacturer_code = card->reader->atr_info.hist_bytes[2];
   97|     24|	manufacturer_mask = card->reader->atr_info.hist_bytes[3];
   98|     24|	fw_major = card->reader->atr_info.hist_bytes[4];
   99|       |
  100|     24|	if (manufacturer_code == ITACNS_ICMAN_INFINEON &&
  ------------------
  |  |    9|     48|#define ITACNS_ICMAN_INFINEON		0x05
  ------------------
  |  Branch (100:6): [True: 12, False: 12]
  ------------------
  101|     12|	    manufacturer_mask == ITACNS_MASKMAN_IDEMIA &&
  ------------------
  |  |   11|     36|#define ITACNS_MASKMAN_IDEMIA		0x05
  ------------------
  |  Branch (101:6): [True: 6, False: 6]
  ------------------
  102|      6|	    fw_major >= 32) {
  ------------------
  |  Branch (102:6): [True: 2, False: 4]
  ------------------
  103|      2|			card->type = SC_CARD_TYPE_ITACNS_CNS_IDEMIA_2021;
  104|      2|	}
  105|       |
  106|     24|	return 1;
  107|  3.67k|}
card-itacns.c:itacns_match_cie_card:
  110|  3.65k|{
  111|  3.65k|	u8 h7_to_h15[] = { 0x02, 'I', 'T', 'I', 'D', 0x20, 0x20, 0x31, 0x80, };
  112|  3.65k|	if (15 != card->reader->atr_info.hist_bytes_len ||
  ------------------
  |  Branch (112:6): [True: 3.52k, False: 124]
  ------------------
  113|    124|	    0 != memcmp(card->reader->atr_info.hist_bytes+6,
  ------------------
  |  Branch (113:6): [True: 123, False: 1]
  ------------------
  114|    124|			h7_to_h15, sizeof h7_to_h15))
  115|  3.65k|		return 0;
  116|       |
  117|      1|	card->type = SC_CARD_TYPE_ITACNS_CIE_V2;
  118|      1|	return 1;
  119|  3.65k|}
card-itacns.c:itacns_init:
  141|     26|{
  142|     26|	unsigned long	flags;
  143|       |
  144|     26|	SC_FUNC_CALLED(card->ctx, 1);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  145|       |
  146|     26|	card->name = "CNS card";
  147|     26|	card->cla = 0x00;
  148|       |
  149|     26|	card->drv_data = calloc(1, sizeof(itacns_drv_data_t));
  150|     26|	if (!card->drv_data)
  ------------------
  |  Branch (150:6): [True: 0, False: 26]
  ------------------
  151|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  152|       |
  153|     26|	if (card->type == SC_CARD_TYPE_ITACNS_CNS)
  ------------------
  |  Branch (153:6): [True: 22, False: 4]
  ------------------
  154|     22|		itacns_init_cns_card(card);
  155|       |
  156|     26|	DRVDATA(card)->ic_manufacturer_code = card->reader->atr_info.hist_bytes[2];
  ------------------
  |  |   64|     26|#define DRVDATA(card) ((itacns_drv_data_t *) card->drv_data)
  ------------------
  157|     26|	DRVDATA(card)->mask_manufacturer_code = card->reader->atr_info.hist_bytes[3];
  ------------------
  |  |   64|     26|#define DRVDATA(card) ((itacns_drv_data_t *) card->drv_data)
  ------------------
  158|     26|	card->version.fw_major = card->reader->atr_info.hist_bytes[4];
  159|     26|	card->version.fw_minor = card->reader->atr_info.hist_bytes[5];
  160|       |
  161|       |	/* Set up algorithm info. */
  162|     26|	flags = SC_ALGORITHM_NEED_USAGE
  ------------------
  |  |   95|     26|#define SC_ALGORITHM_NEED_USAGE		0x40000000
  ------------------
  163|     26|		| SC_ALGORITHM_RSA_RAW
  ------------------
  |  |  102|     26|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
  164|     26|		| SC_ALGORITHM_RSA_HASHES
  ------------------
  |  |  142|     26|#define SC_ALGORITHM_RSA_HASHES		0x0001FF00
  ------------------
  165|     26|		;
  166|       |
  167|     26|	if ((card->version.hw_major >= 1 && card->version.hw_minor >= 1) ||
  ------------------
  |  Branch (167:7): [True: 10, False: 16]
  |  Branch (167:38): [True: 9, False: 1]
  ------------------
  168|     17|	    card->type == SC_CARD_TYPE_ITACNS_CNS_IDEMIA_2021) {
  ------------------
  |  Branch (168:6): [True: 3, False: 14]
  ------------------
  169|     12|		card->caps |= SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  547|     12|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  170|     12|		_sc_card_add_rsa_alg(card, 2048, flags, 0);
  171|     14|	} else {
  172|     14|		_sc_card_add_rsa_alg(card, 1024, flags, 0);
  173|     14|	}
  174|     26|	return SC_SUCCESS;
  ------------------
  |  |   28|     26|#define SC_SUCCESS				0
  ------------------
  175|     26|}
card-itacns.c:itacns_init_cns_card:
   67|     22|{
   68|     22|	if (15 != card->reader->atr_info.hist_bytes_len)
  ------------------
  |  Branch (68:6): [True: 0, False: 22]
  ------------------
   69|      0|		return;
   70|       |
   71|     22|	u8 cns_version = card->reader->atr_info.hist_bytes[12];
   72|     22|	card->version.hw_major = (cns_version >> 4) & 0x0f;
   73|     22|	card->version.hw_minor = cns_version & 0x0f;
   74|       |
   75|       |	/* Warn if version is not 1.X. */
   76|     22|	if (cns_version != 0x10 && cns_version != 0x11) {
  ------------------
  |  Branch (76:6): [True: 21, False: 1]
  |  Branch (76:29): [True: 19, False: 2]
  ------------------
   77|     19|		char version[8];
   78|     19|		snprintf(version, sizeof(version), "%d.%d", card->version.hw_major, card->version.hw_minor);
   79|     19|		sc_log(card->ctx, "CNS card version %s; no official specifications "
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
   80|     19|		       "are published. Proceeding anyway.\n", version);
   81|     19|	}
   82|     22|}
card-itacns.c:itacns_finish:
  178|     26|{
  179|     26|	if(card->drv_data) {
  ------------------
  |  Branch (179:5): [True: 26, False: 0]
  ------------------
  180|     26|		free(card->drv_data);
  181|     26|	}
  182|     26|	return 0;
  183|     26|}
card-itacns.c:itacns_card_ctl:
  486|     26|{
  487|     26|	switch (cmd) {
  ------------------
  |  Branch (487:10): [True: 0, False: 26]
  ------------------
  488|      0|		case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (488:3): [True: 0, False: 26]
  ------------------
  489|      0|		return itacns_get_serialnr(card, ptr);
  490|     26|	}
  491|     26|	return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|     26|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  492|     26|}

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

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

sc_get_masktech_driver:
  374|  16.3k|{
  375|  16.3k|	return sc_get_driver();
  376|  16.3k|}
card-masktech.c:sc_get_driver:
  355|  16.3k|{
  356|       |
  357|  16.3k|	if (iso_ops == NULL)
  ------------------
  |  Branch (357:6): [True: 1, False: 16.3k]
  ------------------
  358|      1|		iso_ops = sc_get_iso7816_driver()->ops;
  359|       |
  360|  16.3k|	masktech_ops = *iso_ops;
  361|       |
  362|  16.3k|	masktech_ops.match_card = masktech_match_card;
  363|  16.3k|	masktech_ops.init = masktech_init;
  364|  16.3k|	masktech_ops.finish = masktech_finish;
  365|  16.3k|	masktech_ops.set_security_env = masktech_set_security_env;
  366|  16.3k|	masktech_ops.compute_signature = masktech_compute_signature;
  367|  16.3k|	masktech_ops.decipher = masktech_decipher;
  368|  16.3k|	masktech_ops.pin_cmd = masktech_pin_cmd;
  369|  16.3k|	masktech_ops.card_ctl = masktech_card_ctl;
  370|  16.3k|	return &masktech_drv;
  371|  16.3k|}
card-masktech.c:masktech_match_card:
   62|  9.48k|{
   63|       |	/* check if the ATR is in the known ATR */
   64|  9.48k|	if (_sc_match_atr(card, masktech_atrs, &card->type) < 0)
  ------------------
  |  Branch (64:6): [True: 9.48k, False: 2]
  ------------------
   65|  9.48k|		return 0;
   66|       |
   67|      2|	return 1;
   68|  9.48k|}
card-masktech.c:masktech_init:
   71|      2|{
   72|      2|	unsigned long flags;
   73|      2|	struct masktech_private_data *data;
   74|       |
   75|      2|	sc_log(card->ctx,  "masktech_init()\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__
  |  |  ------------------
  ------------------
   76|       |
   77|       |	/* private data kept during the live of the driver */
   78|      2|	if (!(data = (struct masktech_private_data *) malloc(sizeof(*data))))
  ------------------
  |  Branch (78:6): [True: 0, False: 2]
  ------------------
   79|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
   80|      2|	card->drv_data = data;
   81|       |
   82|       |	/* supported RSA keys and how padding is done */
   83|      2|	flags = SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  111|      2|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|      2|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|      2|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
              	flags = SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  133|      2|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
   84|      2|	_sc_card_add_rsa_alg(card, 1024, flags, 0);
   85|      2|	_sc_card_add_rsa_alg(card, 2048, flags, 0);
   86|      2|	_sc_card_add_rsa_alg(card, 3072, flags, 0);
   87|      2|	card->caps |= SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  547|      2|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
   88|      2|	return SC_SUCCESS;
  ------------------
  |  |   28|      2|#define SC_SUCCESS				0
  ------------------
   89|      2|}
card-masktech.c:masktech_finish:
   93|      2|{
   94|       |	/* free the private data */
   95|      2|	if (card->drv_data) {
  ------------------
  |  Branch (95:6): [True: 2, False: 0]
  ------------------
   96|      2|		free(card->drv_data);
   97|       |		card->drv_data = NULL;
   98|      2|	}
   99|      2|	return 0;
  100|      2|}
card-masktech.c:masktech_card_ctl:
  344|      2|{
  345|      2|	sc_log(card->ctx,  "masktech_card_ctl()\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__
  |  |  ------------------
  ------------------
  346|      2|	switch (cmd) {
  347|      0|		case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (347:3): [True: 0, False: 2]
  ------------------
  348|      0|			return masktech_get_serialnr(card, (sc_serial_number_t *) ptr);
  349|      2|		default:
  ------------------
  |  Branch (349:3): [True: 2, False: 0]
  ------------------
  350|      2|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      2|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  351|      2|	}
  352|      2|}

sc_get_mcrd_driver:
 1066|  16.3k|{
 1067|  16.3k|	return sc_get_driver();
 1068|  16.3k|}
card-mcrd.c:sc_get_driver:
 1047|  16.3k|{
 1048|  16.3k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 1049|  16.3k|	if (iso_ops == NULL)
  ------------------
  |  Branch (1049:6): [True: 1, False: 16.3k]
  ------------------
 1050|      1|		iso_ops = iso_drv->ops;
 1051|       |
 1052|  16.3k|	mcrd_ops = *iso_drv->ops;
 1053|  16.3k|	mcrd_ops.match_card = mcrd_match_card;
 1054|  16.3k|	mcrd_ops.init = mcrd_init;
 1055|  16.3k|	mcrd_ops.finish = mcrd_finish;
 1056|  16.3k|	mcrd_ops.select_file = mcrd_select_file;
 1057|  16.3k|	mcrd_ops.set_security_env = mcrd_set_security_env;
 1058|  16.3k|	mcrd_ops.compute_signature = mcrd_compute_signature;
 1059|  16.3k|	mcrd_ops.pin_cmd = mcrd_pin_cmd;
 1060|  16.3k|	mcrd_ops.logout = mcrd_logout;
 1061|       |
 1062|  16.3k|	return &mcrd_drv;
 1063|  16.3k|}
card-mcrd.c:mcrd_match_card:
  191|  15.9k|{
  192|  15.9k|	int i = 0;
  193|       |
  194|  15.9k|	i = _sc_match_atr(card, mcrd_atrs, &card->type);
  195|  15.9k|	if (i >= 0) {
  ------------------
  |  Branch (195:6): [True: 104, False: 15.8k]
  ------------------
  196|    104|		card->name = mcrd_atrs[i].name;
  197|    104|		return 1;
  198|    104|	}
  199|       |
  200|  15.8k|	return 0;
  201|  15.9k|}
card-mcrd.c:mcrd_init:
  204|    104|{
  205|    104|	unsigned long flags;
  206|    104|	struct mcrd_priv_data *priv = calloc(1, sizeof *priv);
  207|    104|	if (!priv)
  ------------------
  |  Branch (207:6): [True: 0, False: 104]
  ------------------
  208|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  209|    104|	priv->curpath[0] = MFID;
  ------------------
  |  |   67|    104|#define MFID 0x3F00
  ------------------
  210|    104|	priv->curpathlen = 1;
  211|    104|	card->drv_data = priv;
  212|    104|	card->cla = 0x00;
  213|    104|	card->caps = SC_CARD_CAP_RNG;
  ------------------
  |  |  550|    104|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  214|       |
  215|    104|	flags = SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  102|    104|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
              	flags = SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  111|    104|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|    104|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|    104|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
              	flags = SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  133|    104|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  216|    104|	_sc_card_add_rsa_alg(card, 512, flags, 0);
  217|    104|	_sc_card_add_rsa_alg(card, 768, flags, 0);
  218|    104|	_sc_card_add_rsa_alg(card, 1024, flags, 0);
  219|       |
  220|    104|	if (SC_SUCCESS != sc_select_file (card, sc_get_mf_path(), NULL))
  ------------------
  |  |   28|    104|#define SC_SUCCESS				0
  ------------------
  |  Branch (220:6): [True: 12, False: 92]
  ------------------
  221|     12|		sc_log(card->ctx, "Warning: select MF failed");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  222|       |
  223|    104|	load_special_files(card);
  224|       |
  225|    104|	return SC_SUCCESS;
  ------------------
  |  |   28|    104|#define SC_SUCCESS				0
  ------------------
  226|    104|}
card-mcrd.c:load_special_files:
  248|    104|{
  249|    104|	sc_context_t *ctx = card->ctx;
  250|    104|	int r;
  251|    104|	unsigned int recno;
  252|    104|	struct df_info_s *dfi;
  253|    104|	struct rule_record_s *rule;
  254|    104|	struct keyd_record_s *keyd;
  255|       |
  256|       |	/* First check whether we already cached it. */
  257|    104|	dfi = get_df_info(card);
  258|    104|	if (dfi && dfi->rule_file)
  ------------------
  |  Branch (258:6): [True: 92, False: 12]
  |  Branch (258:13): [True: 0, False: 92]
  ------------------
  259|      0|		return 0;	/* yes. */
  260|    104|	clear_special_files(dfi);
  261|    104|	if (!dfi)
  ------------------
  |  Branch (261:6): [True: 12, False: 92]
  ------------------
  262|    104|		LOG_FUNC_RETURN(ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  263|       |
  264|       |	/* Read rule file. Note that we bypass our cache here. */
  265|     92|	r = select_part(card, MCRD_SEL_EF, EF_Rule, NULL);
  ------------------
  |  |   69|     92|#define EF_Rule 0x0030		/* Default ACL file. */
  ------------------
  266|     92|	LOG_TEST_RET(ctx, r, "selecting EF_Rule failed");
  ------------------
  |  |  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: 6, False: 86]
  |  |  |  |  ------------------
  |  |  |  |  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|     92|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 86]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  267|       |
  268|  1.19k|	for (recno = 1;; recno++) {
  269|  1.19k|		u8 recbuf[256];
  270|  1.19k|		r = sc_read_record(card, recno, 0, recbuf, sizeof(recbuf),
  271|  1.19k|					SC_RECORD_BY_REC_NR);
  ------------------
  |  | 1298|  1.19k|#define SC_RECORD_BY_REC_NR		0x00100UL
  ------------------
  272|       |
  273|  1.19k|		if (r == SC_ERROR_RECORD_NOT_FOUND)
  ------------------
  |  |   52|  1.19k|#define SC_ERROR_RECORD_NOT_FOUND		-1202
  ------------------
  |  Branch (273:7): [True: 25, False: 1.16k]
  ------------------
  274|     25|			break;
  275|  1.16k|		if (r < 0) {
  ------------------
  |  Branch (275:7): [True: 61, False: 1.10k]
  ------------------
  276|     61|			SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|     61|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|     61|	int _ret = r; \
  |  |  155|     61|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 61, False: 0]
  |  |  ------------------
  |  |  156|     61|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|     61|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 61, False: 0]
  |  |  ------------------
  |  |  157|     61|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|     61|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|     61|	return _ret; \
  |  |  163|     61|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  277|  1.10k|		} else {
  278|  1.10k|			rule = malloc(sizeof *rule + (size_t)r);
  279|  1.10k|			if (!rule)
  ------------------
  |  Branch (279:8): [True: 0, False: 1.10k]
  ------------------
  280|  1.10k|				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|  1.10k|			rule->recno = recno;
  282|  1.10k|			rule->datalen = (size_t)r;
  283|  1.10k|			memcpy(rule->data, recbuf, r);
  284|  1.10k|			rule->next = dfi->rule_file;
  285|  1.10k|			dfi->rule_file = rule;
  286|  1.10k|		}
  287|  1.16k|	}
  288|       |
  289|     25|	sc_log(ctx, "new EF_Rule file loaded (%d records)\n", recno - 1);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  290|       |
  291|       |	/* Read the KeyD file. Note that we bypass our cache here. */
  292|     25|	r = select_part(card, MCRD_SEL_EF, EF_KeyD, NULL);
  ------------------
  |  |   68|     25|#define EF_KeyD 0x0013		/* File with extra key information. */
  ------------------
  293|     25|	if (r == SC_ERROR_FILE_NOT_FOUND) {
  ------------------
  |  |   51|     25|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (293:6): [True: 1, False: 24]
  ------------------
  294|      1|		sc_log(ctx, "no EF_KeyD file available\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__
  |  |  ------------------
  ------------------
  295|      1|		return 0;	/* That is okay. */
  296|      1|	}
  297|     24|	LOG_TEST_RET(ctx, r, "selecting EF_KeyD failed");
  ------------------
  |  |  174|     24|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     24|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     24|	int _ret = (r); \
  |  |  |  |  168|     24|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 18]
  |  |  |  |  ------------------
  |  |  |  |  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|     24|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 18]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  298|       |
  299|    239|	for (recno = 1;; recno++) {
  300|    239|		u8 recbuf[256];
  301|    239|		r = sc_read_record(card, recno, 0, recbuf, sizeof(recbuf),
  302|    239|					SC_RECORD_BY_REC_NR);
  ------------------
  |  | 1298|    239|#define SC_RECORD_BY_REC_NR		0x00100UL
  ------------------
  303|       |
  304|    239|		if (r == SC_ERROR_RECORD_NOT_FOUND)
  ------------------
  |  |   52|    239|#define SC_ERROR_RECORD_NOT_FOUND		-1202
  ------------------
  |  Branch (304:7): [True: 1, False: 238]
  ------------------
  305|      1|			break;
  306|    238|		if (r < 0) {
  ------------------
  |  Branch (306:7): [True: 17, False: 221]
  ------------------
  307|     17|			SC_FUNC_RETURN(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|     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]
  |  |  ------------------
  ------------------
  308|    221|		} else {
  309|    221|			keyd = malloc(sizeof *keyd + (size_t)r);
  310|    221|			if (!keyd)
  ------------------
  |  Branch (310:8): [True: 0, False: 221]
  ------------------
  311|    221|				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|    221|			keyd->recno = recno;
  313|    221|			keyd->datalen = (size_t) r;
  314|    221|			memcpy(keyd->data, recbuf, r);
  315|    221|			keyd->next = dfi->keyd_file;
  316|    221|			dfi->keyd_file = keyd;
  317|    221|		}
  318|    238|	}
  319|       |
  320|      1|	sc_log(ctx, "new EF_KeyD file loaded (%d records)\n", recno - 1);
  ------------------
  |  |   71|      1|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  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|      1|	return 0;
  324|     18|}
card-mcrd.c:get_df_info:
  111|    104|{
  112|    104|	sc_context_t *ctx = card->ctx;
  113|    104|	struct mcrd_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  103|    104|#define DRVDATA(card) ((struct mcrd_priv_data *) ((card)->drv_data))
  ------------------
  114|    104|	struct df_info_s *dfi;
  115|       |
  116|    104|	if (priv->is_ef)
  ------------------
  |  Branch (116:6): [True: 0, False: 104]
  ------------------
  117|      0|		return NULL;
  118|       |
  119|    104|	if (!priv->curpathlen) {
  ------------------
  |  Branch (119:6): [True: 12, False: 92]
  ------------------
  120|     12|		sc_log(ctx, "no current path to find the df_info\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__
  |  |  ------------------
  ------------------
  121|     12|		return NULL;
  122|     12|	}
  123|       |
  124|     92|	for (dfi = priv->df_infos; dfi; dfi = dfi->next) {
  ------------------
  |  Branch (124:29): [True: 0, False: 92]
  ------------------
  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|     92|	dfi = calloc(1, sizeof *dfi);
  132|     92|	if (!dfi) {
  ------------------
  |  Branch (132:6): [True: 0, False: 92]
  ------------------
  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|     92|	dfi->pathlen = priv->curpathlen;
  137|     92|	memcpy(dfi->path, priv->curpath, dfi->pathlen * sizeof *dfi->path);
  138|     92|	dfi->next = priv->df_infos;
  139|     92|	priv->df_infos = dfi;
  140|     92|	return dfi;
  141|     92|}
card-mcrd.c:clear_special_files:
  144|    196|{
  145|    196|	if (dfi) {
  ------------------
  |  Branch (145:6): [True: 184, False: 12]
  ------------------
  146|  1.28k|		while (dfi->rule_file) {
  ------------------
  |  Branch (146:10): [True: 1.10k, False: 184]
  ------------------
  147|  1.10k|			struct rule_record_s *tmp = dfi->rule_file->next;
  148|  1.10k|			free(dfi->rule_file);
  149|  1.10k|			dfi->rule_file = tmp;
  150|  1.10k|		}
  151|    405|		while (dfi->keyd_file) {
  ------------------
  |  Branch (151:10): [True: 221, False: 184]
  ------------------
  152|    221|			struct keyd_record_s *tmp = dfi->keyd_file->next;
  153|    221|			free(dfi->keyd_file);
  154|    221|			dfi->keyd_file = tmp;
  155|    221|		}
  156|    184|	}
  157|    196|}
card-mcrd.c:select_part:
  615|    221|{
  616|    221|	u8 fbuf[2];
  617|    221|	unsigned int len;
  618|    221|	int r;
  619|       |
  620|    221|	sc_log(card->ctx,
  ------------------
  |  |   71|    221|#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|    221|		"select_part (0x%04X, kind=%u)\n", fid, kind);
  622|       |
  623|    221|	if (fid == MFID) {
  ------------------
  |  |   67|    221|#define MFID 0x3F00
  ------------------
  |  Branch (623:6): [True: 104, False: 117]
  ------------------
  624|    104|		kind = MCRD_SEL_MF;	/* force this kind. */
  625|    104|		len = 0;
  626|    117|	} else {
  627|    117|		fbuf[0] = fid >> 8;
  628|    117|		fbuf[1] = fid & 0xff;
  629|    117|		len = 2;
  630|    117|	}
  631|    221|	r = do_select(card, kind, fbuf, len, file);
  632|       |
  633|    221|	return r;
  634|    221|}
card-mcrd.c:do_select:
  556|    221|{
  557|    221|	sc_apdu_t apdu;
  558|    221|	u8 resbuf[SC_MAX_APDU_BUFFER_SIZE];
  559|    221|	int r;
  560|       |
  561|    221|	u8 p2 = 0x00;
  562|    221|	if (kind == MCRD_SEL_EF) p2 = 0x04;
  ------------------
  |  Branch (562:6): [True: 117, False: 104]
  ------------------
  563|    221|	if (kind == MCRD_SEL_DF) p2 = 0x0C;
  ------------------
  |  Branch (563:6): [True: 0, False: 221]
  ------------------
  564|       |
  565|    221|	sc_format_apdu_ex(&apdu, 0x00, 0xA4, kind, p2, buf, buflen, resbuf, 256);
  566|    221|	r = sc_transmit_apdu(card, &apdu);
  567|    221|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    221|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    221|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    221|	int _ret = (r); \
  |  |  |  |  168|    221|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 215]
  |  |  |  |  ------------------
  |  |  |  |  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|    221|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 215]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  568|    215|	if (!file) {
  ------------------
  |  Branch (568:6): [True: 215, False: 0]
  ------------------
  569|    215|		if (apdu.sw1 == 0x61)
  ------------------
  |  Branch (569:7): [True: 0, False: 215]
  ------------------
  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|    215|		r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  572|    215|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, 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|     19|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 19, False: 196]
  |  |  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  573|    215|	}
  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|    104|{
  230|    104|	struct mcrd_priv_data *priv;
  231|       |
  232|    104|	if (card == NULL)
  ------------------
  |  Branch (232:6): [True: 0, False: 104]
  ------------------
  233|      0|		return 0;
  234|    104|	priv = DRVDATA(card);
  ------------------
  |  |  103|    104|#define DRVDATA(card) ((struct mcrd_priv_data *) ((card)->drv_data))
  ------------------
  235|    196|	while (priv->df_infos) {
  ------------------
  |  Branch (235:9): [True: 92, False: 104]
  ------------------
  236|     92|		struct df_info_s *tmp = priv->df_infos->next;
  237|     92|		clear_special_files(priv->df_infos);
  238|     92|		free(priv->df_infos);
  239|     92|		priv->df_infos = tmp;
  240|     92|	}
  241|    104|	free(priv);
  242|    104|	return 0;
  243|    104|}
card-mcrd.c:mcrd_select_file:
  849|    104|{
  850|    104|	struct mcrd_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  103|    104|#define DRVDATA(card) ((struct mcrd_priv_data *) ((card)->drv_data))
  ------------------
  851|    104|	int r = 0;
  852|       |
  853|    104|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    104|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    104|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    104|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 104]
  |  |  ------------------
  ------------------
  854|       |
  855|    104|	if (path->type == SC_PATH_TYPE_DF_NAME) {
  ------------------
  |  |  118|    104|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (855:6): [True: 0, False: 104]
  ------------------
  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|    104|	} else {
  861|    104|		unsigned short int pathtmp[SC_MAX_PATH_SIZE / 2];
  862|    104|		unsigned short int *pathptr;
  863|    104|		int samepath = 1;
  864|    104|		size_t pathlen, n;
  865|       |
  866|    104|		if ((path->len & 1) || path->len > sizeof(pathtmp))
  ------------------
  |  Branch (866:7): [True: 0, False: 104]
  |  Branch (866:26): [True: 0, False: 104]
  ------------------
  867|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  868|       |
  869|    104|		memset(pathtmp, 0, sizeof pathtmp);
  870|    104|		pathptr = pathtmp;
  871|    208|		for (n = 0; n < path->len; n += 2)
  ------------------
  |  Branch (871:15): [True: 104, False: 104]
  ------------------
  872|    104|			pathptr[n >> 1] =
  873|    104|				(unsigned short)((path->value[n] << 8) | path->value[n + 1]);
  874|    104|		pathlen = path->len >> 1;
  875|       |
  876|    104|		if (pathlen == priv->curpathlen && priv->is_ef != 2) {
  ------------------
  |  Branch (876:7): [True: 104, False: 0]
  |  Branch (876:38): [True: 104, False: 0]
  ------------------
  877|    208|			for (n = 0; n < pathlen; n++) {
  ------------------
  |  Branch (877:16): [True: 104, False: 104]
  ------------------
  878|    104|				if (priv->curpath[n] != pathptr[n]) {
  ------------------
  |  Branch (878:9): [True: 0, False: 104]
  ------------------
  879|      0|					samepath = 0;
  880|      0|					break;
  881|      0|				}
  882|    104|			}
  883|    104|		} 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|    104|		if (samepath != 1 || priv->is_ef == 0 || priv->is_ef == 1) {
  ------------------
  |  Branch (894:7): [True: 0, False: 104]
  |  Branch (894:24): [True: 104, False: 0]
  |  Branch (894:44): [True: 0, False: 0]
  ------------------
  895|    104|			if (path->type == SC_PATH_TYPE_PATH)
  ------------------
  |  |  119|    104|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (895:8): [True: 104, False: 0]
  ------------------
  896|    104|				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|    104|		}
  901|    104|	}
  902|       |
  903|    104|	return r;
  904|    104|}
card-mcrd.c:select_file_by_path:
  688|    104|{
  689|    104|	struct mcrd_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  103|    104|#define DRVDATA(card) ((struct mcrd_priv_data *) ((card)->drv_data))
  ------------------
  690|    104|	int r;
  691|    104|	size_t i;
  692|       |
  693|    104|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    104|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    104|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    104|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 104]
  |  |  ------------------
  ------------------
  694|       |
  695|    104|	if (!(!priv->curpathlen || priv->curpath[0] == MFID))
  ------------------
  |  |   67|    104|#define MFID 0x3F00
  ------------------
  |  Branch (695:8): [True: 0, False: 104]
  |  Branch (695:29): [True: 104, False: 0]
  ------------------
  696|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  697|       |
  698|    104|	if (pathlen && *pathptr == 0x3FFF) {
  ------------------
  |  Branch (698:6): [True: 104, False: 0]
  |  Branch (698:17): [True: 0, False: 104]
  ------------------
  699|      0|		pathlen--;
  700|      0|		pathptr++;
  701|      0|	}
  702|       |
  703|    104|	if (!pathlen || pathlen >= MAX_CURPATH)
  ------------------
  |  |   71|    104|#define MAX_CURPATH 10
  ------------------
  |  Branch (703:6): [True: 0, False: 104]
  |  Branch (703:18): [True: 0, False: 104]
  ------------------
  704|      0|		r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  705|    104|	else if (pathlen == 1 && pathptr[0] == MFID) {
  ------------------
  |  |   67|    104|#define MFID 0x3F00
  ------------------
  |  Branch (705:11): [True: 104, False: 0]
  |  Branch (705:27): [True: 104, False: 0]
  ------------------
  706|       |		/* MF requested: clear the cache and select it. */
  707|    104|		priv->curpathlen = 0;
  708|    104|		r = select_part(card, MCRD_SEL_MF, pathptr[0], file);
  709|    104|		LOG_TEST_RET(card->ctx, r, "unable to select MF");
  ------------------
  |  |  174|    104|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    104|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    104|	int _ret = (r); \
  |  |  |  |  168|    104|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 12, False: 92]
  |  |  |  |  ------------------
  |  |  |  |  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|    104|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 92]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  710|     92|		priv->curpath[0] = pathptr[0];
  711|     92|		priv->curpathlen = 1;
  712|     92|		priv->is_ef = 0;
  713|     92|	} 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|     92|	return r;
  776|    104|}

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

sc_get_myeid_driver:
 2176|  16.3k|{
 2177|  16.3k|	return sc_get_driver();
 2178|  16.3k|}
card-myeid.c:sc_get_driver:
 2141|  16.3k|{
 2142|  16.3k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 2143|       |
 2144|  16.3k|	if (iso_ops == NULL)
  ------------------
  |  Branch (2144:6): [True: 1, False: 16.3k]
  ------------------
 2145|      1|		iso_ops = iso_drv->ops;
 2146|       |
 2147|  16.3k|	myeid_ops			= *iso_drv->ops;
 2148|  16.3k|	myeid_ops.match_card		= myeid_match_card;
 2149|  16.3k|	myeid_ops.init			= myeid_init;
 2150|  16.3k|	myeid_ops.finish		= myeid_finish;
 2151|       |	/* no record oriented file services */
 2152|  16.3k|	myeid_ops.read_record		= NULL;
 2153|  16.3k|	myeid_ops.write_record		= NULL;
 2154|  16.3k|	myeid_ops.append_record		= NULL;
 2155|       |	myeid_ops.update_record		= NULL;
 2156|  16.3k|	myeid_ops.select_file		= myeid_select_file;
 2157|  16.3k|	myeid_ops.get_response		= iso_ops->get_response;
 2158|  16.3k|	myeid_ops.logout		= myeid_logout;
 2159|  16.3k|	myeid_ops.create_file		= myeid_create_file;
 2160|  16.3k|	myeid_ops.delete_file		= myeid_delete_file;
 2161|  16.3k|	myeid_ops.list_files		= myeid_list_files;
 2162|  16.3k|	myeid_ops.set_security_env	= myeid_set_security_env;
 2163|  16.3k|	myeid_ops.compute_signature	= myeid_compute_signature;
 2164|  16.3k|	myeid_ops.decipher		= myeid_decipher;
 2165|  16.3k|	myeid_ops.process_fci		= myeid_process_fci;
 2166|  16.3k|	myeid_ops.card_ctl		= myeid_card_ctl;
 2167|  16.3k|	myeid_ops.pin_cmd		= myeid_pin_cmd;
 2168|  16.3k|	myeid_ops.wrap			= myeid_wrap_key;
 2169|  16.3k|	myeid_ops.unwrap		= myeid_unwrap_key;
 2170|  16.3k|	myeid_ops.encrypt_sym		= myeid_encrypt_sym;
 2171|  16.3k|	myeid_ops.decrypt_sym		= myeid_decrypt_sym;
 2172|  16.3k|	return &myeid_drv;
 2173|  16.3k|}
card-myeid.c:myeid_match_card:
  122|  10.6k|{
  123|  10.6k|	size_t len = card->reader->atr_info.hist_bytes_len;
  124|       |	/* Normally the historical bytes are exactly "MyEID", but there might
  125|       |	 * be some historic units which have a small prefix byte sequence. */
  126|  10.6k|	if (len >= 5) {
  ------------------
  |  Branch (126:6): [True: 2.88k, False: 7.79k]
  ------------------
  127|  2.88k|		if (!memcmp(&card->reader->atr_info.hist_bytes[len - 5], "MyEID", 5)) {
  ------------------
  |  Branch (127:7): [True: 1.12k, False: 1.76k]
  ------------------
  128|  1.12k|			sc_log(card->ctx, "Matched MyEID card");
  ------------------
  |  |   71|  1.12k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  129|  1.12k|			card->type = SC_CARD_TYPE_MYEID_GENERIC;
  130|  1.12k|			return 1;
  131|  1.12k|		}
  132|       |		/* The software implementation of MyEID is identified by OsEID bytes */
  133|  1.76k|		if (!memcmp(&card->reader->atr_info.hist_bytes[len - 5], "OsEID", 5)) {
  ------------------
  |  Branch (133:7): [True: 44, False: 1.71k]
  ------------------
  134|     44|			sc_log(card->ctx, "Matched OsEID card");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  135|     44|			card->type = SC_CARD_TYPE_MYEID_OSEID;
  136|     44|			return 1;
  137|     44|		}
  138|  1.76k|	}
  139|  9.51k|	return 0;
  140|  10.6k|}
card-myeid.c:myeid_init:
  171|  1.17k|{
  172|  1.17k|	unsigned long flags = 0, ext_flags = 0;
  173|  1.17k|	myeid_private_data_t *priv;
  174|  1.17k|	u8 appletInfo[20];
  175|  1.17k|	size_t appletInfoLen;
  176|  1.17k|	myeid_card_caps_t card_caps;
  177|  1.17k|	static struct sc_aid myeid_aid = { "\xA0\x00\x00\x00\x63\x50\x4B\x43\x53\x2D\x31\x35", 0x0C };
  178|  1.17k|	int rv = 0;
  179|  1.17k|	void *old_drv_data = card->drv_data;
  180|       |
  181|  1.17k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  1.17k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.17k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.17k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.17k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.17k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  182|       |
  183|  1.17k|	switch (card->type) {
  184|     44|	case SC_CARD_TYPE_MYEID_OSEID:
  ------------------
  |  Branch (184:2): [True: 44, False: 1.12k]
  ------------------
  185|     44|		card->name = oseid_card_name;
  186|     44|		break;
  187|  1.12k|	case SC_CARD_TYPE_MYEID_GENERIC:
  ------------------
  |  Branch (187:2): [True: 1.12k, False: 44]
  ------------------
  188|  1.12k|		card->name = myeid_card_name;
  189|  1.12k|		break;
  190|      0|	default:
  ------------------
  |  Branch (190:2): [True: 0, False: 1.17k]
  ------------------
  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|  1.17k|	}
  193|       |
  194|  1.17k|	priv = calloc(1, sizeof(myeid_private_data_t));
  195|       |
  196|  1.17k|	if (!priv)
  ------------------
  |  Branch (196:6): [True: 0, False: 1.17k]
  ------------------
  197|  1.17k|		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|  1.17k|	rv = myeid_load_options (card->ctx, priv);
  200|  1.17k|	LOG_TEST_GOTO_ERR(card->ctx, rv, "Unable to read options from opensc.conf");
  ------------------
  |  |  184|  1.17k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  1.17k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  1.17k|	int _ret = (r); \
  |  |  |  |  178|  1.17k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 1.17k]
  |  |  |  |  ------------------
  |  |  |  |  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.17k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1.17k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  201|       |
  202|  1.17k|	priv->card_state = SC_FILE_STATUS_CREATION;
  ------------------
  |  |  240|  1.17k|#define SC_FILE_STATUS_CREATION		0x02 /* ISO7816-4: Creation state, (1) */
  ------------------
  203|  1.17k|	card->drv_data = priv;
  204|       |
  205|       |	/* Ensure that the MyEID applet is selected. */
  206|  1.17k|	rv = iso7816_select_aid(card, myeid_aid.value, myeid_aid.len, NULL, NULL);
  207|  1.17k|	LOG_TEST_GOTO_ERR(card->ctx, rv, "Failed to select MyEID applet.");
  ------------------
  |  |  184|  1.17k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  1.17k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  1.17k|	int _ret = (r); \
  |  |  |  |  178|  1.17k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 16, False: 1.15k]
  |  |  |  |  ------------------
  |  |  |  |  179|     16|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     16|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     16|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     16|		goto err; \
  |  |  |  |  182|     16|	} \
  |  |  |  |  183|  1.17k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1.15k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  208|       |
  209|       |	/* find out MyEID version */
  210|       |
  211|  1.15k|	appletInfoLen = 20;
  212|       |
  213|  1.15k|	if (0 > myeid_get_info(card, appletInfo, appletInfoLen))
  ------------------
  |  Branch (213:6): [True: 484, False: 670]
  ------------------
  214|  1.15k|		LOG_TEST_GOTO_ERR(card->ctx, SC_ERROR_INVALID_CARD, "Failed to get MyEID applet information.");
  ------------------
  |  |  184|    484|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    484|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    484|	int _ret = (r); \
  |  |  |  |  178|    484|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 484, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|    484|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    484|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    484|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    484|		goto err; \
  |  |  |  |  182|    484|	} \
  |  |  |  |  183|    484|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  215|       |
  216|    670|	priv->change_counter = appletInfo[19] | appletInfo[18] << 8;
  217|       |
  218|    670|	memset(&card_caps, 0, sizeof(myeid_card_caps_t));
  219|    670|	card_caps.max_ecc_key_length = 256;
  220|    670|	card_caps.max_rsa_key_length = 2048;
  221|       |
  222|    670|	if (card->version.fw_major >= 40) {
  ------------------
  |  Branch (222:6): [True: 580, False: 90]
  ------------------
  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|    580|	    if (myeid_get_card_caps(card, &card_caps) != SC_SUCCESS) {
  ------------------
  |  |   28|    580|#define SC_SUCCESS				0
  ------------------
  |  Branch (225:10): [True: 157, False: 423]
  ------------------
  226|    157|			sc_log(card->ctx, "Failed to get card capabilities. Using default max ECC key length 256.");
  ------------------
  |  |   71|    157|#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|    157|	    }
  228|    580|	}
  229|       |
  230|    670|	flags = SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  102|    670|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
              	flags = SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|    670|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  231|    670|	if (priv->disable_hw_pkcs1_padding == 0)
  ------------------
  |  Branch (231:6): [True: 670, False: 0]
  ------------------
  232|    670|		flags |= SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |  111|    670|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|    670|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|    670|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  233|    670|	flags |= SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  133|    670|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  234|       |
  235|    670|	_sc_card_add_rsa_alg(card,  512, flags, 0);
  236|    670|	_sc_card_add_rsa_alg(card,  768, flags, 0);
  237|    670|	_sc_card_add_rsa_alg(card, 1024, flags, 0);
  238|    670|	_sc_card_add_rsa_alg(card, 1536, flags, 0);
  239|    670|	_sc_card_add_rsa_alg(card, 2048, flags, 0);
  240|       |
  241|    670|	if (card_caps.card_supported_features & MYEID_CARD_CAP_RSA) {
  ------------------
  |  |   50|    670|#define MYEID_CARD_CAP_RSA		0x01
  ------------------
  |  Branch (241:6): [True: 396, False: 274]
  ------------------
  242|    396|		if (card_caps.max_rsa_key_length >= 3072)
  ------------------
  |  Branch (242:7): [True: 334, False: 62]
  ------------------
  243|    334|			_sc_card_add_rsa_alg(card, 3072, flags, 0);
  244|    396|		if (card_caps.max_rsa_key_length >= 4096)
  ------------------
  |  Branch (244:7): [True: 330, False: 66]
  ------------------
  245|    330|			_sc_card_add_rsa_alg(card, 4096, flags, 0);
  246|    396|	}
  247|       |
  248|       |	/* show ECC algorithms if the applet version of the inserted card supports them */
  249|    670|	if (card->version.fw_major >= 35) {
  ------------------
  |  Branch (249:6): [True: 615, False: 55]
  ------------------
  250|    615|		int i;
  251|       |
  252|    615|		flags = SC_ALGORITHM_ECDSA_RAW | SC_ALGORITHM_ECDH_CDH_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  174|    615|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
              		flags = SC_ALGORITHM_ECDSA_RAW | SC_ALGORITHM_ECDH_CDH_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  173|    615|#define SC_ALGORITHM_ECDH_CDH_RAW	0x00200000
  ------------------
              		flags = SC_ALGORITHM_ECDSA_RAW | SC_ALGORITHM_ECDH_CDH_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|    615|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  253|    615|		flags |= SC_ALGORITHM_ECDSA_HASH_NONE;
  ------------------
  |  |  175|    615|#define SC_ALGORITHM_ECDSA_HASH_NONE		SC_ALGORITHM_RSA_HASH_NONE
  |  |  ------------------
  |  |  |  |  133|    615|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  ------------------
  254|    615|		ext_flags = SC_ALGORITHM_EXT_EC_NAMEDCURVE | SC_ALGORITHM_EXT_EC_UNCOMPRESES;
  ------------------
  |  |  201|    615|#define SC_ALGORITHM_EXT_EC_NAMEDCURVE   0x00000008
  ------------------
              		ext_flags = SC_ALGORITHM_EXT_EC_NAMEDCURVE | SC_ALGORITHM_EXT_EC_UNCOMPRESES;
  ------------------
  |  |  202|    615|#define SC_ALGORITHM_EXT_EC_UNCOMPRESES  0x00000010
  ------------------
  255|       |
  256|  3.07k|		for (i=0; ec_curves[i].curve_name != NULL; i++) {
  ------------------
  |  Branch (256:13): [True: 2.46k, False: 615]
  ------------------
  257|  2.46k|			if (card_caps.max_ecc_key_length >= ec_curves[i].size)
  ------------------
  |  Branch (257:8): [True: 1.98k, False: 478]
  ------------------
  258|  1.98k|				_sc_card_add_ec_alg(card, ec_curves[i].size, flags, ext_flags, &ec_curves[i].curve_oid);
  259|  2.46k|		}
  260|    615|	}
  261|       |
  262|       |	/* show supported symmetric algorithms */
  263|    670|	flags = 0;
  264|    670|	if (card_caps.card_supported_features & MYEID_CARD_CAP_3DES) {
  ------------------
  |  |   51|    670|#define MYEID_CARD_CAP_3DES		0x02
  ------------------
  |  Branch (264:6): [True: 389, False: 281]
  ------------------
  265|    389|		if (card_caps.max_des_key_length >= 64)
  ------------------
  |  Branch (265:7): [True: 375, False: 14]
  ------------------
  266|    375|			_sc_card_add_symmetric_alg(card, SC_ALGORITHM_DES, 64, flags);
  ------------------
  |  |   76|    375|#define SC_ALGORITHM_DES		64
  ------------------
  267|    389|		if (card_caps.max_des_key_length >= 128)
  ------------------
  |  Branch (267:7): [True: 368, False: 21]
  ------------------
  268|    368|			_sc_card_add_symmetric_alg(card, SC_ALGORITHM_3DES, 128, flags);
  ------------------
  |  |   77|    368|#define SC_ALGORITHM_3DES		65
  ------------------
  269|    389|		if (card_caps.max_des_key_length >= 192)
  ------------------
  |  Branch (269:7): [True: 313, False: 76]
  ------------------
  270|    313|			_sc_card_add_symmetric_alg(card, SC_ALGORITHM_3DES, 192, flags);
  ------------------
  |  |   77|    313|#define SC_ALGORITHM_3DES		65
  ------------------
  271|    389|	}
  272|    670|	if (card_caps.card_supported_features & MYEID_CARD_CAP_AES) {
  ------------------
  |  |   52|    670|#define MYEID_CARD_CAP_AES		0x04
  ------------------
  |  Branch (272:6): [True: 393, False: 277]
  ------------------
  273|    393|		if (card_caps.max_aes_key_length >= 128)
  ------------------
  |  Branch (273:7): [True: 383, False: 10]
  ------------------
  274|    383|			_sc_card_add_symmetric_alg(card, SC_ALGORITHM_AES, 128, flags);
  ------------------
  |  |   79|    383|#define SC_ALGORITHM_AES		67
  ------------------
  275|    393|		if (card_caps.max_aes_key_length >= 256)
  ------------------
  |  Branch (275:7): [True: 378, False: 15]
  ------------------
  276|    378|			_sc_card_add_symmetric_alg(card, SC_ALGORITHM_AES, 256, flags);
  ------------------
  |  |   79|    378|#define SC_ALGORITHM_AES		67
  ------------------
  277|    393|	}
  278|       |
  279|       |	/* State that we have an RNG */
  280|    670|	card->caps |= SC_CARD_CAP_RNG | SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  550|    670|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
              	card->caps |= SC_CARD_CAP_RNG | SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  553|    670|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
  281|       |
  282|    670|	if ((card->version.fw_major == 40 && card->version.fw_minor >= 10 )
  ------------------
  |  Branch (282:7): [True: 21, False: 649]
  |  Branch (282:39): [True: 8, False: 13]
  ------------------
  283|    662|		|| card->version.fw_major >= 41)
  ------------------
  |  Branch (283:6): [True: 559, False: 103]
  ------------------
  284|    567|		card->caps |= SC_CARD_CAP_WRAP_KEY | SC_CARD_CAP_UNWRAP_KEY
  ------------------
  |  |  572|    567|#define SC_CARD_CAP_WRAP_KEY			0x00000800
  ------------------
              		card->caps |= SC_CARD_CAP_WRAP_KEY | SC_CARD_CAP_UNWRAP_KEY
  ------------------
  |  |  574|    567|#define SC_CARD_CAP_UNWRAP_KEY			0x00001000
  ------------------
  285|    567|			   | SC_CARD_CAP_ONCARD_SESSION_OBJECTS;
  ------------------
  |  |  569|    567|#define SC_CARD_CAP_ONCARD_SESSION_OBJECTS	0x00000400
  ------------------
  286|       |
  287|    670|	if (card->version.fw_major >= 45)
  ------------------
  |  Branch (287:6): [True: 555, False: 115]
  ------------------
  288|    555|		priv->cap_chaining = 1;
  289|    670|	if (card->version.fw_major >= 40)
  ------------------
  |  Branch (289:6): [True: 580, False: 90]
  ------------------
  290|    580|		card->max_recv_size = 256;
  291|     90|	else
  292|     90|		card->max_recv_size = 255;
  293|    670|	card->max_send_size = 255;
  294|       |
  295|    670|	rv = SC_SUCCESS;
  ------------------
  |  |   28|    670|#define SC_SUCCESS				0
  ------------------
  296|       |
  297|  1.17k|err:
  298|  1.17k|	if (rv < 0) {
  ------------------
  |  Branch (298:6): [True: 16, False: 1.15k]
  ------------------
  299|     16|		free(priv);
  300|     16|		card->drv_data = old_drv_data;
  301|     16|	}
  302|       |
  303|  1.17k|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  164|  1.17k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.17k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.17k|	int _ret = r; \
  |  |  |  |  155|  1.17k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.17k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.17k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     16|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 16, False: 1.15k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.17k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.17k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|  1.17k|	return _ret; \
  |  |  |  |  163|  1.17k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  304|  1.17k|}
card-myeid.c:myeid_load_options:
  143|  1.17k|{
  144|  1.17k|	int r;
  145|  1.17k|	size_t i, j;
  146|  1.17k|	scconf_block **found_blocks, *block;
  147|       |
  148|  1.17k|	if (!ctx || !priv) {
  ------------------
  |  Branch (148:6): [True: 0, False: 1.17k]
  |  Branch (148:14): [True: 0, False: 1.17k]
  ------------------
  149|      0|		r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  150|      0|		goto err;
  151|      0|	}
  152|  1.17k|	priv->disable_hw_pkcs1_padding = 0;
  153|  2.34k|	for (i = 0; ctx->conf_blocks[i]; i++) {
  ------------------
  |  Branch (153:14): [True: 1.17k, False: 1.17k]
  ------------------
  154|  1.17k|		found_blocks = scconf_find_blocks(ctx->conf, ctx->conf_blocks[i],
  155|  1.17k|				"card_driver", "myeid");
  156|  1.17k|		if (!found_blocks)
  ------------------
  |  Branch (156:7): [True: 0, False: 1.17k]
  ------------------
  157|      0|			continue;
  158|  1.17k|		for (j = 0, block = found_blocks[j]; block; j++, block = found_blocks[j]) {
  ------------------
  |  Branch (158:40): [True: 0, False: 1.17k]
  ------------------
  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|  1.17k|		free(found_blocks);
  163|  1.17k|	}
  164|  1.17k|	r = SC_SUCCESS;
  ------------------
  |  |   28|  1.17k|#define SC_SUCCESS				0
  ------------------
  165|       |
  166|  1.17k|err:
  167|  1.17k|	return r;
  168|  1.17k|}
card-myeid.c:myeid_get_info:
 1733|  2.15k|{
 1734|  2.15k|	sc_apdu_t apdu;
 1735|  2.15k|	int r;
 1736|       |
 1737|  2.15k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  2.15k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  2.15k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  2.15k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  2.15k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2.15k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1738|       |
 1739|  2.15k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, 0xA0);
  ------------------
  |  |  292|  2.15k|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1740|  2.15k|	apdu.resp    = rbuf;
 1741|  2.15k|	apdu.resplen = buflen;
 1742|  2.15k|	apdu.le      = buflen;
 1743|       |
 1744|  2.15k|	r = sc_transmit_apdu(card, &apdu);
 1745|  2.15k|	LOG_TEST_RET(card->ctx, r,  "APDU transmit failed");
  ------------------
  |  |  174|  2.15k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.15k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.15k|	int _ret = (r); \
  |  |  |  |  168|  2.15k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 14, False: 2.14k]
  |  |  |  |  ------------------
  |  |  |  |  169|     14|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     14|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     14|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     14|		return _ret; \
  |  |  |  |  172|     14|	} \
  |  |  |  |  173|  2.15k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.14k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1746|       |
 1747|  2.14k|	if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00)
  ------------------
  |  Branch (1747:6): [True: 651, False: 1.49k]
  |  Branch (1747:26): [True: 58, False: 1.43k]
  ------------------
 1748|    709|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|    709|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1749|       |
 1750|  1.43k|	if (apdu.resplen != 20)
  ------------------
  |  Branch (1750:6): [True: 378, False: 1.05k]
  ------------------
 1751|    378|	{
 1752|    378|		sc_log(card->ctx, "Unexpected response to GET DATA (applet info)");
  ------------------
  |  |   71|    378|#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|    378|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|    378|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1754|    378|	}
 1755|       |
 1756|       |	/* store the applet version */
 1757|  1.05k|	card->version.fw_major = rbuf[5] * 10 + rbuf[6];
 1758|  1.05k|	card->version.fw_minor = rbuf[7];
 1759|       |	/* add version to name */
 1760|  1.05k|	snprintf(card_name_buf, sizeof(card_name_buf),
 1761|  1.05k|			"%s %d.%d.%d", card->name, rbuf[5], rbuf[6], rbuf[7]);
 1762|  1.05k|	card->name = card_name_buf;
 1763|       |
 1764|  1.05k|	LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1765|  1.05k|}
card-myeid.c:myeid_get_card_caps:
 1816|    580|{
 1817|    580|	sc_apdu_t apdu;
 1818|    580|	int r;
 1819|    580|	unsigned char rbuf[SC_MAX_APDU_BUFFER_SIZE];
 1820|       |
 1821|    580|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    580|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    580|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    580|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    580|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 580]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1822|       |
 1823|    580|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, 0xAA);
  ------------------
  |  |  292|    580|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1824|    580|	apdu.resp    = rbuf;
 1825|    580|	apdu.resplen = sizeof(myeid_card_caps_t);
 1826|    580|	apdu.le      = sizeof(myeid_card_caps_t);
 1827|       |
 1828|    580|	r = sc_transmit_apdu(card, &apdu);
 1829|    580|	LOG_TEST_RET(card->ctx, r,  "APDU transmit failed");
  ------------------
  |  |  174|    580|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    580|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    580|	int _ret = (r); \
  |  |  |  |  168|    580|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 578]
  |  |  |  |  ------------------
  |  |  |  |  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|    580|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 578]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1830|       |
 1831|    578|	if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00)
  ------------------
  |  Branch (1831:6): [True: 113, False: 465]
  |  Branch (1831:26): [True: 19, False: 446]
  ------------------
 1832|    132|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|    132|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1833|       |
 1834|    446|	if (apdu.resplen < 11) {
  ------------------
  |  Branch (1834:6): [True: 23, False: 423]
  ------------------
 1835|     23|		sc_log(card->ctx, "Unexpected response to GET DATA (MyEIC card capabilities)");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1836|     23|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     23|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1837|     23|	}
 1838|       |
 1839|    423|	card_caps->card_caps_ver = rbuf[0];
 1840|       |	/* the card returns big endian values */
 1841|    423|	card_caps->card_supported_features = (unsigned short) rbuf[1] << 8 | rbuf[2];
 1842|    423|	card_caps->max_rsa_key_length = (unsigned short) rbuf[3] << 8 | rbuf[4];
 1843|    423|	card_caps->max_des_key_length = (unsigned short) rbuf[5] << 8 | rbuf[6];
 1844|    423|	card_caps->max_aes_key_length = (unsigned short) rbuf[7] << 8 | rbuf[8];
 1845|    423|	card_caps->max_ecc_key_length = (unsigned short) rbuf[9] << 8 | rbuf[10];
 1846|       |
 1847|    423|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    423|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    423|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    423|	int _ret = r; \
  |  |  |  |  155|    423|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 423, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    423|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 423]
  |  |  |  |  ------------------
  |  |  |  |  157|    423|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    423|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    423|	return _ret; \
  |  |  |  |  163|    423|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1848|    423|}
card-myeid.c:myeid_finish:
 1886|  1.15k|{
 1887|  1.15k|	struct myeid_private_data *priv = (struct myeid_private_data *) card->drv_data;
 1888|  1.15k|	free(priv);
 1889|  1.15k|	return SC_SUCCESS;
  ------------------
  |  |   28|  1.15k|#define SC_SUCCESS				0
  ------------------
 1890|  1.15k|}
card-myeid.c:myeid_select_file:
  392|  24.9k|{
  393|  24.9k|	int r;
  394|       |
  395|  24.9k|	LOG_FUNC_CALLED(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  396|  24.9k|	r = iso_ops->select_file(card, in_path, file);
  397|       |
  398|  24.9k|	if (r == 0 && file != NULL && *file != NULL)
  ------------------
  |  Branch (398:6): [True: 9.90k, False: 15.0k]
  |  Branch (398:16): [True: 5.19k, False: 4.71k]
  |  Branch (398:32): [True: 5.19k, False: 0]
  ------------------
  399|  5.19k|		parse_sec_attr(*file, (*file)->sec_attr, (*file)->sec_attr_len);
  400|       |
  401|  24.9k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  24.9k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  24.9k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  24.9k|	int _ret = r; \
  |  |  |  |  155|  24.9k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 24.9k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  24.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|  15.0k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 15.0k, False: 9.90k]
  |  |  |  |  ------------------
  |  |  |  |  157|  24.9k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  24.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|  24.9k|	return _ret; \
  |  |  |  |  163|  24.9k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  402|  24.9k|}
card-myeid.c:parse_sec_attr:
  350|  5.19k|{
  351|  5.19k|	int i;
  352|  5.19k|	const int df_ops[4] =
  353|  5.19k|		{ SC_AC_OP_CREATE, SC_AC_OP_CREATE, SC_AC_OP_DELETE, -1 };
  ------------------
  |  |  169|  5.19k|#define SC_AC_OP_CREATE			3
  ------------------
              		{ SC_AC_OP_CREATE, SC_AC_OP_CREATE, SC_AC_OP_DELETE, -1 };
  ------------------
  |  |  169|  5.19k|#define SC_AC_OP_CREATE			3
  ------------------
              		{ SC_AC_OP_CREATE, SC_AC_OP_CREATE, SC_AC_OP_DELETE, -1 };
  ------------------
  |  |  168|  5.19k|#define SC_AC_OP_DELETE			2
  ------------------
  354|  5.19k|	const int ef_ops[4] =
  355|  5.19k|		{ SC_AC_OP_READ, SC_AC_OP_UPDATE, SC_AC_OP_DELETE, -1 };
  ------------------
  |  |  188|  5.19k|#define SC_AC_OP_READ			22
  ------------------
              		{ SC_AC_OP_READ, SC_AC_OP_UPDATE, SC_AC_OP_DELETE, -1 };
  ------------------
  |  |  189|  5.19k|#define SC_AC_OP_UPDATE			23
  ------------------
              		{ SC_AC_OP_READ, SC_AC_OP_UPDATE, SC_AC_OP_DELETE, -1 };
  ------------------
  |  |  168|  5.19k|#define SC_AC_OP_DELETE			2
  ------------------
  356|  5.19k|	const int key_ops[4] =
  357|  5.19k|		{ SC_AC_OP_CRYPTO, SC_AC_OP_UPDATE, SC_AC_OP_DELETE, SC_AC_OP_GENERATE };
  ------------------
  |  |  173|  5.19k|#define SC_AC_OP_CRYPTO			7
  ------------------
              		{ SC_AC_OP_CRYPTO, SC_AC_OP_UPDATE, SC_AC_OP_DELETE, SC_AC_OP_GENERATE };
  ------------------
  |  |  189|  5.19k|#define SC_AC_OP_UPDATE			23
  ------------------
              		{ SC_AC_OP_CRYPTO, SC_AC_OP_UPDATE, SC_AC_OP_DELETE, SC_AC_OP_GENERATE };
  ------------------
  |  |  168|  5.19k|#define SC_AC_OP_DELETE			2
  ------------------
              		{ SC_AC_OP_CRYPTO, SC_AC_OP_UPDATE, SC_AC_OP_DELETE, SC_AC_OP_GENERATE };
  ------------------
  |  |  192|  5.19k|#define SC_AC_OP_GENERATE		26
  ------------------
  358|       |
  359|  5.19k|	const int *ops;
  360|       |
  361|  5.19k|	if (len < 2)
  ------------------
  |  Branch (361:6): [True: 2.01k, False: 3.17k]
  ------------------
  362|  2.01k|		return;
  363|       |
  364|  3.17k|	switch (file->type) {
  365|  1.72k|	case SC_FILE_TYPE_WORKING_EF:
  ------------------
  |  |  216|  1.72k|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (365:2): [True: 1.72k, False: 1.44k]
  ------------------
  366|  1.72k|		ops = ef_ops;
  367|  1.72k|		break;
  368|     42|	case SC_FILE_TYPE_INTERNAL_EF:
  ------------------
  |  |  215|     42|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (368:2): [True: 42, False: 3.13k]
  ------------------
  369|     42|		ops = key_ops;
  370|     42|		break;
  371|  1.13k|	case SC_FILE_TYPE_DF:
  ------------------
  |  |  214|  1.13k|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (371:2): [True: 1.13k, False: 2.03k]
  ------------------
  372|  1.13k|		ops = df_ops;
  373|  1.13k|		break;
  374|    270|	default:
  ------------------
  |  Branch (374:2): [True: 270, False: 2.90k]
  ------------------
  375|    270|		ops = key_ops;
  376|    270|		break;
  377|  3.17k|	}
  378|       |
  379|  15.8k|	for (i = 0; i < 4; i++)
  ------------------
  |  Branch (379:14): [True: 12.6k, False: 3.17k]
  ------------------
  380|  12.6k|	{
  381|  12.6k|		if (ops[i] == -1)
  ------------------
  |  Branch (381:7): [True: 2.86k, False: 9.83k]
  ------------------
  382|  2.86k|			continue;
  383|  9.83k|		if ((i & 1) == 0)
  ------------------
  |  Branch (383:7): [True: 6.34k, False: 3.48k]
  ------------------
  384|  6.34k|			add_acl_entry(file, ops[i], (u8)(buf[i / 2] >> 4));
  385|  3.48k|		else
  386|  3.48k|			add_acl_entry(file, ops[i], (u8)(buf[i / 2] & 0x0F));
  387|  9.83k|	}
  388|  3.17k|}
card-myeid.c:add_acl_entry:
  330|  9.83k|{
  331|  9.83k|	unsigned int method, key_ref = SC_AC_KEY_REF_NONE;
  ------------------
  |  |  204|  9.83k|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  332|       |
  333|  9.83k|	switch (byte)
  334|  9.83k|	{
  335|  1.94k|	case 0:
  ------------------
  |  Branch (335:2): [True: 1.94k, False: 7.88k]
  ------------------
  336|  1.94k|		method = SC_AC_NONE;
  ------------------
  |  |  150|  1.94k|#define SC_AC_NONE			0x00000000
  ------------------
  337|  1.94k|		break;
  338|    338|	case 15:
  ------------------
  |  Branch (338:2): [True: 338, False: 9.49k]
  ------------------
  339|    338|		method = SC_AC_NEVER;
  ------------------
  |  |  163|    338|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  340|    338|		break;
  341|  7.54k|	default:
  ------------------
  |  Branch (341:2): [True: 7.54k, False: 2.28k]
  ------------------
  342|  7.54k|		method = SC_AC_CHV;
  ------------------
  |  |  151|  7.54k|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  343|  7.54k|		key_ref = byte;
  344|  7.54k|		break;
  345|  9.83k|	}
  346|  9.83k|	sc_file_add_acl_entry(file, op, method, key_ref);
  347|  9.83k|}
card-myeid.c:myeid_create_file:
  617|  1.79k|{
  618|  1.79k|	sc_apdu_t apdu;
  619|  1.79k|	u8 sbuf[45];
  620|  1.79k|	size_t buflen = sizeof sbuf;
  621|  1.79k|	int r;
  622|       |
  623|  1.79k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  1.79k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.79k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.79k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.79k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.79k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  624|       |
  625|  1.79k|	r = encode_file_structure(card, file, sbuf, &buflen);
  626|  1.79k|	if (r)
  ------------------
  |  Branch (626:6): [True: 15, False: 1.78k]
  ------------------
  627|  1.79k|	  LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     15|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     15|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     15|	int _ret = r; \
  |  |  |  |  155|     15|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 15, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     15|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     15|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 15, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     15|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     15|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     15|	return _ret; \
  |  |  |  |  163|     15|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  628|       |
  629|  1.78k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE0, 0x00, 0x00);
  ------------------
  |  |  293|  1.78k|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  630|  1.78k|	apdu.data = sbuf;
  631|  1.78k|	apdu.datalen = buflen;
  632|  1.78k|	apdu.lc = buflen;
  633|       |
  634|  1.78k|	r = sc_transmit_apdu(card, &apdu);
  635|  1.78k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  1.78k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.78k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.78k|	int _ret = (r); \
  |  |  |  |  168|  1.78k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 7, False: 1.77k]
  |  |  |  |  ------------------
  |  |  |  |  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|  1.78k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.77k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  636|  1.77k|	if (apdu.sw1 == 0x6A && apdu.sw2 == 0x89)
  ------------------
  |  Branch (636:6): [True: 33, False: 1.74k]
  |  Branch (636:26): [True: 1, False: 32]
  ------------------
  637|  1.77k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_FILE_ALREADY_EXISTS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  638|       |
  639|  1.77k|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  640|  1.77k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  1.77k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.77k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.77k|	int _ret = r; \
  |  |  |  |  155|  1.77k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.77k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.77k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    159|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 159, False: 1.61k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.77k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.77k|	} else { \
  |  |  |  |  159|      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.77k|	return _ret; \
  |  |  |  |  163|  1.77k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  641|  1.77k|}
card-myeid.c:encode_file_structure:
  485|  1.79k|{
  486|  1.79k|	const sc_acl_entry_t *read, *update, *delete, *generate;
  487|  1.79k|	size_t i;
  488|       |
  489|  1.79k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  1.79k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.79k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.79k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.79k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.79k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  490|       |
  491|  1.79k|	if (!buf || !outlen || *outlen < 45)
  ------------------
  |  Branch (491:6): [True: 0, False: 1.79k]
  |  Branch (491:14): [True: 0, False: 1.79k]
  |  Branch (491:25): [True: 0, False: 1.79k]
  ------------------
  492|  1.79k|		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.79k|	memset(buf, 0x0, *outlen);
  498|       |
  499|  1.79k|	buf[0] = 0x62;
  500|  1.79k|	buf[1] = 0x17;
  501|       |	/* File size */
  502|  1.79k|	buf[2] = (SC_FILE_TYPE_WORKING_EF == file->type ? 0x80 : 0x81);
  ------------------
  |  |  216|  1.79k|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (502:12): [True: 1.32k, False: 476]
  ------------------
  503|  1.79k|	buf[3] = 0x02;
  504|  1.79k|	buf[4] = (file->size >> 8) & 0xFF;
  505|  1.79k|	buf[5] = file->size & 0xFF;
  506|       |
  507|       |	/* File Description tag */
  508|  1.79k|	buf[6] = 0x82;
  509|  1.79k|	buf[7] = 0x01;
  510|  1.79k|	buf[8] = 0x01;
  511|       |
  512|       |	/* File Identifier tag */
  513|  1.79k|	buf[9]  = 0x83;
  514|  1.79k|	buf[10] = 0x02;
  515|  1.79k|	buf[11] = (file->id >> 8) & 0xFF;
  516|  1.79k|	buf[12] = file->id & 0xFF;
  517|       |
  518|       |	/* Security Attributes Tag */
  519|  1.79k|	buf[13] = 0x86;
  520|  1.79k|	buf[14] = 0x03;
  521|  1.79k|	buf[15] = 0xFF;
  522|  1.79k|	buf[16] = 0xFF;
  523|  1.79k|	buf[17] = 0xFF;
  524|       |
  525|  1.79k|	if (file->sec_attr_len == 3 && file->sec_attr)   {
  ------------------
  |  Branch (525:6): [True: 124, False: 1.67k]
  |  Branch (525:33): [True: 124, False: 0]
  ------------------
  526|    124|		buf[15] = file->sec_attr[0];
  527|    124|		buf[16] = file->sec_attr[1];
  528|    124|		buf[17] = file->sec_attr[2];
  529|       |
  530|    124|		sc_log(card->ctx, "id (%X), sec_attr %X %X %X", file->id,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  531|    124|				file->sec_attr[0],file->sec_attr[1],file->sec_attr[2]);
  532|    124|	}
  533|  1.67k|	else   {
  534|  1.67k|		delete = sc_file_get_acl_entry(file, SC_AC_OP_DELETE);
  ------------------
  |  |  168|  1.67k|#define SC_AC_OP_DELETE			2
  ------------------
  535|       |
  536|  1.67k|		sc_log(card->ctx, "id (%X), type (%X)", file->id, file->type);
  ------------------
  |  |   71|  1.67k|#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.67k|		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: 433]
  ------------------
  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|    115|		case SC_FILE_TYPE_INTERNAL_EF:
  ------------------
  |  |  215|    115|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (547:3): [True: 115, False: 1.55k]
  ------------------
  548|       |
  549|    115|			read = sc_file_get_acl_entry(file, SC_AC_OP_CRYPTO);
  ------------------
  |  |  173|    115|#define SC_AC_OP_CRYPTO			7
  ------------------
  550|    115|			update = sc_file_get_acl_entry(file, SC_AC_OP_UPDATE);
  ------------------
  |  |  189|    115|#define SC_AC_OP_UPDATE			23
  ------------------
  551|    115|			generate = sc_file_get_acl_entry(file, SC_AC_OP_GENERATE);
  ------------------
  |  |  192|    115|#define SC_AC_OP_GENERATE		26
  ------------------
  552|       |
  553|    115|			buf[15] = (acl_to_byte(read) << 4) | acl_to_byte(update);
  554|    115|			buf[16] = (acl_to_byte(delete)<< 4) | acl_to_byte(generate);
  555|    115|			break;
  556|    303|		case SC_FILE_TYPE_DF:
  ------------------
  |  |  214|    303|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (556:3): [True: 303, False: 1.37k]
  ------------------
  557|       |
  558|    303|			update = sc_file_get_acl_entry(file, SC_AC_OP_CREATE);
  ------------------
  |  |  169|    303|#define SC_AC_OP_CREATE			3
  ------------------
  559|       |
  560|    303|			buf[15] = (acl_to_byte(update) << 4) | acl_to_byte(update);
  561|    303|			buf[16] = (acl_to_byte(delete) << 4) | 0x0F;
  562|    303|			break;
  563|     15|		default:
  ------------------
  |  Branch (563:3): [True: 15, False: 1.65k]
  ------------------
  564|     15|			break;
  565|  1.67k|		}
  566|  1.67k|	}
  567|       |
  568|       |	/* Proprietary Information */
  569|  1.79k|	buf[18] = 0x85;
  570|  1.79k|	buf[19] = 0x02;
  571|  1.79k|	if (file->prop_attr_len == 2 && file->prop_attr != NULL)
  ------------------
  |  Branch (571:6): [True: 416, False: 1.38k]
  |  Branch (571:34): [True: 416, False: 0]
  ------------------
  572|    416|	    memcpy(&buf[20], file->prop_attr, 2);
  573|  1.38k|	else
  574|  1.38k|	{
  575|  1.38k|		buf[20] = 0x00;
  576|  1.38k|		buf[21] = 0x00;
  577|  1.38k|	}
  578|       |
  579|       |	/* Life Cycle Status tag */
  580|  1.79k|	buf[22] = 0x8A;
  581|  1.79k|	buf[23] = 0x01;
  582|  1.79k|	buf[24] = 0x0; /* RFU */
  583|       |
  584|  1.79k|	switch (file->type)
  585|  1.79k|	{
  586|  1.32k|	case SC_FILE_TYPE_WORKING_EF:
  ------------------
  |  |  216|  1.32k|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (586:2): [True: 1.32k, False: 476]
  ------------------
  587|  1.32k|		break;
  588|       |
  589|    152|	case SC_FILE_TYPE_INTERNAL_EF:
  ------------------
  |  |  215|    152|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (589:2): [True: 152, False: 1.64k]
  ------------------
  590|    152|		buf[8] = file->ef_structure; /* RSA or EC */
  591|    152|		break;
  592|       |
  593|    309|	case SC_FILE_TYPE_DF:
  ------------------
  |  |  214|    309|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (593:2): [True: 309, False: 1.48k]
  ------------------
  594|    309|		buf[8] = 0x38;
  595|    309|		if(file->namelen > 0 && file->namelen <= 16)
  ------------------
  |  Branch (595:6): [True: 25, False: 284]
  |  Branch (595:27): [True: 25, False: 0]
  ------------------
  596|     25|		{
  597|     25|			buf[25] = 0x84;
  598|     25|			buf[26] = (u8)file->namelen;
  599|       |
  600|    196|			for(i=0;i < file->namelen;i++)
  ------------------
  |  Branch (600:12): [True: 171, False: 25]
  ------------------
  601|    171|				buf[i + 27] = file->name[i];
  602|       |
  603|     25|			buf[1] = 27 + file->namelen;
  604|     25|		}
  605|    309|		break;
  606|     15|	default:
  ------------------
  |  Branch (606:2): [True: 15, False: 1.78k]
  ------------------
  607|     15|		sc_log(card->ctx, "Unknown file type\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__
  |  |  ------------------
  ------------------
  608|     15|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|     15|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  609|  1.79k|	}
  610|       |
  611|  1.78k|	*outlen = buf[1]+2;
  612|       |
  613|  1.78k|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|  1.78k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.78k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.78k|	int _ret = r; \
  |  |  |  |  155|  1.78k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.78k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 1.78k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.78k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.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|  1.78k|	return _ret; \
  |  |  |  |  163|  1.78k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  614|  1.78k|}
card-myeid.c:acl_to_byte:
  309|  5.09k|{
  310|  5.09k|	if (NULL == e)
  ------------------
  |  Branch (310:6): [True: 0, False: 5.09k]
  ------------------
  311|      0|		return 0x00;
  312|  5.09k|	switch (e->method) {
  ------------------
  |  Branch (312:10): [True: 4.92k, False: 172]
  ------------------
  313|  3.36k|	case SC_AC_NONE:
  ------------------
  |  |  150|  3.36k|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (313:2): [True: 3.36k, False: 1.73k]
  ------------------
  314|  3.36k|		return 0x00;
  315|  1.44k|	case SC_AC_CHV:
  ------------------
  |  |  151|  1.44k|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (315:2): [True: 1.44k, False: 3.64k]
  ------------------
  316|  1.46k|	case SC_AC_TERM:
  ------------------
  |  |  152|  1.46k|#define SC_AC_TERM			0x00000002 /* Terminal auth. */
  ------------------
  |  Branch (316:2): [True: 19, False: 5.07k]
  ------------------
  317|  1.48k|	case SC_AC_AUT:
  ------------------
  |  |  154|  1.48k|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  |  Branch (317:2): [True: 21, False: 5.07k]
  ------------------
  318|  1.48k|		if (e->key_ref == SC_AC_KEY_REF_NONE)
  ------------------
  |  |  204|  1.48k|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  |  Branch (318:7): [True: 0, False: 1.48k]
  ------------------
  319|      0|			return 0x00;
  320|  1.48k|		if (e->key_ref < 1 || e->key_ref > 14)
  ------------------
  |  Branch (320:7): [True: 94, False: 1.39k]
  |  Branch (320:25): [True: 36, False: 1.35k]
  ------------------
  321|    130|			return 0x00;
  322|  1.35k|		return e->key_ref;
  323|     72|	case SC_AC_NEVER:
  ------------------
  |  |  163|     72|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (323:2): [True: 72, False: 5.02k]
  ------------------
  324|     72|		return 0x0F;
  325|  5.09k|	}
  326|    172|	return 0x00;
  327|  5.09k|}
card-myeid.c:myeid_delete_file:
  644|     16|{
  645|     16|	int r;
  646|     16|	struct sc_apdu apdu;
  647|       |
  648|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  649|     16|	if (path->type != SC_PATH_TYPE_FILE_ID && path->len != 2)
  ------------------
  |  |  117|     32|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (649:6): [True: 0, False: 16]
  |  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|     16|	r = sc_select_file(card, path, NULL);
  655|     16|	LOG_TEST_RET(card->ctx, r, "Unable to select file to be deleted");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  656|       |
  657|     12|	sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0xE4, 0x00, 0x00);
  ------------------
  |  |  291|     12|#define SC_APDU_CASE_1			0x01
  ------------------
  658|       |
  659|     12|	r = sc_transmit_apdu(card, &apdu);
  660|     12|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     12|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     12|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     12|	int _ret = (r); \
  |  |  |  |  168|     12|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 11]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|     12|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 11]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  661|       |
  662|     11|	LOG_FUNC_RETURN(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  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|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 6, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  663|     11|}
card-myeid.c:myeid_process_fci:
  442|  4.78k|{
  443|  4.78k|	myeid_private_data_t *priv = (myeid_private_data_t *) card->drv_data;
  444|  4.78k|	size_t taglen = 0;
  445|  4.78k|	const u8 *tag = NULL;
  446|  4.78k|	int r;
  447|       |
  448|  4.78k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  4.78k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  4.78k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  4.78k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  4.78k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 4.78k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  449|  4.78k|	r = iso_ops->process_fci(card, file, buf, buflen);
  450|  4.78k|	if (r < 0)
  ------------------
  |  Branch (450:6): [True: 0, False: 4.78k]
  ------------------
  451|  4.78k|	 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|  4.78k|	if(file->type == SC_FILE_EF_UNKNOWN)
  ------------------
  |  |  220|  4.78k|#define SC_FILE_EF_UNKNOWN		0x00
  ------------------
  |  Branch (453:5): [True: 1.35k, False: 3.42k]
  ------------------
  454|  1.35k|	{
  455|  1.35k|		tag = sc_asn1_find_tag(NULL, buf, buflen, 0x82, &taglen);
  456|  1.35k|		if (tag != NULL && taglen > 0 && *tag == 17)
  ------------------
  |  Branch (456:7): [True: 385, False: 972]
  |  Branch (456:22): [True: 357, False: 28]
  |  Branch (456:36): [True: 26, False: 331]
  ------------------
  457|     26|		{
  458|     26|			file->type = SC_FILE_TYPE_INTERNAL_EF;
  ------------------
  |  |  215|     26|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  459|     26|		}
  460|  1.35k|	}
  461|  4.78k|	if(file->sec_attr_len >= 3)
  ------------------
  |  Branch (461:5): [True: 3.12k, False: 1.65k]
  ------------------
  462|  3.12k|	{
  463|  3.12k|		sc_log(card->ctx, "id (%X) sec_attr (%X %X %X)", file->id,
  ------------------
  |  |   71|  3.12k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  464|  3.12k|			file->sec_attr[0],file->sec_attr[1],file->sec_attr[2]);
  465|  3.12k|	}
  466|       |
  467|  4.78k|	priv->card_state = file->status;
  468|  4.78k|	switch (file->status) {
  469|  2.76k|		case SC_FILE_STATUS_CREATION:
  ------------------
  |  |  240|  2.76k|#define SC_FILE_STATUS_CREATION		0x02 /* ISO7816-4: Creation state, (1) */
  ------------------
  |  Branch (469:3): [True: 2.76k, False: 2.02k]
  ------------------
  470|  2.76k|			file->acl_inactive = 1;
  471|  2.76k|			sc_log(card->ctx, "File id (%X) status SC_FILE_STATUS_CREATION", file->id);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  472|  2.76k|			break;
  473|     10|		case SC_FILE_STATUS_ACTIVATED:
  ------------------
  |  |  236|     10|#define SC_FILE_STATUS_ACTIVATED	0x00 /* ISO7816-4: Operational state (activated)   (5, 7) */
  ------------------
  |  Branch (473:3): [True: 10, False: 4.77k]
  ------------------
  474|     10|			sc_log(card->ctx, "File id (%X) status SC_FILE_STATUS_ACTIVATED", file->id);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  475|     10|			break;
  476|  2.01k|		default:
  ------------------
  |  Branch (476:3): [True: 2.01k, False: 2.77k]
  ------------------
  477|  2.01k|			sc_log(card->ctx, "File id (%X) unusual status (0x%X)", file->id, file->status);
  ------------------
  |  |   71|  2.01k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  478|  4.78k|	}
  479|       |
  480|  4.78k|	LOG_FUNC_RETURN(card->ctx, 0);
  ------------------
  |  |  164|  4.78k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  4.78k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  4.78k|	int _ret = r; \
  |  |  |  |  155|  4.78k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4.78k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  4.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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 4.78k]
  |  |  |  |  ------------------
  |  |  |  |  157|  4.78k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  4.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|  4.78k|	return _ret; \
  |  |  |  |  163|  4.78k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  481|  4.78k|}
card-myeid.c:myeid_card_ctl:
 1851|  5.46k|{
 1852|  5.46k|	int r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|  5.46k|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1853|  5.46k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  5.46k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  5.46k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  5.46k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  5.46k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 5.46k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1854|       |
 1855|  5.46k|	switch(cmd) {
  ------------------
  |  Branch (1855:9): [True: 5.46k, False: 6]
  ------------------
 1856|    527|	case SC_CARDCTL_MYEID_PUTDATA:
  ------------------
  |  Branch (1856:2): [True: 527, False: 4.94k]
  ------------------
 1857|    527|		r = myeid_putdata(card,
 1858|    527|			(struct sc_cardctl_myeid_data_obj*) ptr);
 1859|    527|		break;
 1860|     51|	case SC_CARDCTL_MYEID_GETDATA:
  ------------------
  |  Branch (1860:2): [True: 51, False: 5.41k]
  ------------------
 1861|     51|		r = myeid_getdata(card,
 1862|     51|			(struct sc_cardctl_myeid_data_obj*) ptr);
 1863|     51|		break;
 1864|    190|	case SC_CARDCTL_MYEID_GENERATE_STORE_KEY:
  ------------------
  |  Branch (1864:2): [True: 190, False: 5.27k]
  ------------------
 1865|    190|		r = myeid_generate_store_key(card,
 1866|    190|			(struct sc_cardctl_myeid_gen_store_key_info *) ptr);
 1867|    190|		break;
 1868|    708|	case SC_CARDCTL_MYEID_ACTIVATE_CARD:
  ------------------
  |  Branch (1868:2): [True: 708, False: 4.76k]
  ------------------
 1869|    708|		r = myeid_activate_card(card);
 1870|    708|		break;
 1871|    980|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (1871:2): [True: 980, False: 4.48k]
  ------------------
 1872|    980|		r = myeid_get_serialnr(card, (sc_serial_number_t *)ptr);
 1873|    980|		break;
 1874|     22|	case SC_CARDCTL_GET_CHANGE_COUNTER:
  ------------------
  |  Branch (1874:2): [True: 22, False: 5.44k]
  ------------------
 1875|     22|		r = myeid_get_change_counter(card, (size_t *)ptr);
 1876|     22|		break;
 1877|     32|	case SC_CARDCTL_GET_DEFAULT_KEY:
  ------------------
  |  Branch (1877:2): [True: 32, False: 5.43k]
  ------------------
 1878|  2.98k|	case SC_CARDCTL_LIFECYCLE_SET:
  ------------------
  |  Branch (1878:2): [True: 2.95k, False: 2.51k]
  ------------------
 1879|  2.98k|	case SC_CARDCTL_LIFECYCLE_GET:
  ------------------
  |  Branch (1879:2): [True: 0, False: 5.46k]
  ------------------
 1880|  2.98k|		break;
 1881|  5.46k|	}
 1882|  5.46k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  5.46k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  5.46k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  5.46k|	int _ret = r; \
  |  |  |  |  155|  5.46k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 5.46k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  5.46k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  4.63k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 4.63k, False: 835]
  |  |  |  |  ------------------
  |  |  |  |  157|  5.46k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  5.46k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|  5.46k|	return _ret; \
  |  |  |  |  163|  5.46k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1883|  5.46k|}
card-myeid.c:myeid_putdata:
 1507|    527|{
 1508|    527|	int r;
 1509|    527|	struct sc_apdu apdu;
 1510|       |
 1511|    527|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    527|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    527|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    527|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    527|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 527]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1512|       |
 1513|    527|	memset(&apdu, 0, sizeof(apdu));
 1514|    527|	apdu.cse     = SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|    527|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1515|    527|	apdu.cla     = 0x00;
 1516|    527|	apdu.ins     = 0xDA;
 1517|    527|	apdu.p1      = data_obj->P1;
 1518|    527|	apdu.p2      = data_obj->P2;
 1519|    527|	apdu.lc      = data_obj->DataLen;
 1520|    527|	apdu.datalen = data_obj->DataLen;
 1521|    527|	apdu.data    = data_obj->Data;
 1522|       |
 1523|    527|	r = sc_transmit_apdu(card, &apdu);
 1524|    527|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    527|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    527|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    527|	int _ret = (r); \
  |  |  |  |  168|    527|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 524]
  |  |  |  |  ------------------
  |  |  |  |  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|    527|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 524]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1525|       |
 1526|    524|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1527|    524|	LOG_TEST_RET(card->ctx, r, "PUT_DATA returned error");
  ------------------
  |  |  174|    524|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    524|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    524|	int _ret = (r); \
  |  |  |  |  168|    524|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 337, False: 187]
  |  |  |  |  ------------------
  |  |  |  |  169|    337|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    337|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    337|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    337|		return _ret; \
  |  |  |  |  172|    337|	} \
  |  |  |  |  173|    524|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 187]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1528|       |
 1529|    187|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    187|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    187|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    187|	int _ret = r; \
  |  |  |  |  155|    187|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 187, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    187|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 187]
  |  |  |  |  ------------------
  |  |  |  |  157|    187|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    187|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    187|	return _ret; \
  |  |  |  |  163|    187|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1530|    187|}
card-myeid.c:myeid_getdata:
 1534|     51|{
 1535|     51|	int r;
 1536|     51|	struct sc_apdu apdu;
 1537|       |
 1538|     51|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     51|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1539|       |
 1540|     51|	memset(&apdu, 0, sizeof(apdu));
 1541|     51|	apdu.cse     = SC_APDU_CASE_2_SHORT;
  ------------------
  |  |  292|     51|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1542|     51|	apdu.cla     = 0x00;
 1543|     51|	apdu.ins     = 0xCA;		/* GET DATA */
 1544|     51|	apdu.p1      = data_obj->P1;
 1545|     51|	apdu.p2      = data_obj->P2;
 1546|     51|	apdu.lc      = 0;
 1547|     51|	apdu.datalen = 0;
 1548|     51|	apdu.data    = data_obj->Data;
 1549|       |
 1550|     51|	apdu.le      = card->max_recv_size;
 1551|     51|	apdu.resp    = data_obj->Data;
 1552|     51|	apdu.resplen = data_obj->DataLen;
 1553|       |
 1554|     51|	r = sc_transmit_apdu(card, &apdu);
 1555|     51|	LOG_TEST_RET(card->ctx, r, "APDU transmit 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: 1, False: 50]
  |  |  |  |  ------------------
  |  |  |  |  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|     51|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 50]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1556|       |
 1557|     50|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1558|     50|	LOG_TEST_RET(card->ctx, r, "GET_DATA returned error");
  ------------------
  |  |  174|     50|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     50|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     50|	int _ret = (r); \
  |  |  |  |  168|     50|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 11, False: 39]
  |  |  |  |  ------------------
  |  |  |  |  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|     50|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 39]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1559|       |
 1560|     39|	if (apdu.resplen > data_obj->DataLen)
  ------------------
  |  Branch (1560:6): [True: 0, False: 39]
  ------------------
 1561|      0|		r = SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|      0|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
 1562|     39|	else
 1563|     39|		data_obj->DataLen = apdu.resplen;
 1564|       |
 1565|     39|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1566|     39|}
card-myeid.c:myeid_generate_store_key:
 1628|    190|{
 1629|    190|	struct	sc_apdu apdu;
 1630|    190|	u8	sbuf[SC_MAX_APDU_BUFFER_SIZE];
 1631|    190|	int	r=0,len;
 1632|       |
 1633|    190|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    190|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    190|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    190|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    190|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 190]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1634|       |	/* Setup key-generation parameters */
 1635|    190|	if (data->op_type == OP_TYPE_GENERATE)
  ------------------
  |  |  530|    190|#define OP_TYPE_GENERATE	0
  ------------------
  |  Branch (1635:6): [True: 68, False: 122]
  ------------------
 1636|     68|	{
 1637|     68|		len = 0;
 1638|     68|		memset(&apdu, 0, sizeof(apdu));
 1639|       |
 1640|     68|		if(data->key_type == SC_CARDCTL_MYEID_KEY_RSA)
  ------------------
  |  Branch (1640:6): [True: 26, False: 42]
  ------------------
 1641|     26|		{
 1642|     26|		    sbuf[len++] = 0x30;
 1643|     26|		    sbuf[len++] = 0x05;
 1644|     26|		    sbuf[len++] = 0x81;
 1645|     26|		    sbuf[len++] = data->pubexp_len;
 1646|       |
 1647|     26|		    memcpy(sbuf + len, data->pubexp, data->pubexp_len);
 1648|     26|		    len += data->pubexp_len;
 1649|     26|			sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x46, 0x00, 0x00);
  ------------------
  |  |  293|     26|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1650|     26|			apdu.data    = sbuf;
 1651|     26|		}
 1652|     42|		else if(data->key_type == SC_CARDCTL_MYEID_KEY_EC) {
  ------------------
  |  Branch (1652:11): [True: 42, False: 0]
  ------------------
 1653|       |
 1654|     42|			sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x46, 0x00, 0x00);
  ------------------
  |  |  291|     42|#define SC_APDU_CASE_1			0x01
  ------------------
 1655|       |
 1656|     42|			apdu.data    = NULL;
 1657|     42|			apdu.resp	 = sbuf;
 1658|     42|			apdu.resplen = 0x00;
 1659|     42|			apdu.le		 = 0x00;
 1660|     42|		}
 1661|       |
 1662|     68|		apdu.cla     = 0x00;
 1663|     68|		apdu.datalen = len;
 1664|     68|		apdu.lc	     = len;
 1665|       |
 1666|     68|		r = sc_transmit_apdu(card, &apdu);
 1667|     68|		LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  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: 1, False: 67]
  |  |  |  |  ------------------
  |  |  |  |  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|     68|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 67]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1668|       |
 1669|     67|		r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1670|     67|		LOG_TEST_RET(card->ctx, r, "GENERATE_KEY returned error");
  ------------------
  |  |  174|     67|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     67|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     67|	int _ret = (r); \
  |  |  |  |  168|     67|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 5, False: 62]
  |  |  |  |  ------------------
  |  |  |  |  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|     67|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 62]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1671|     67|	}
 1672|    122|	else
 1673|    122|	{
 1674|    122|		if(data->key_type == SC_CARDCTL_MYEID_KEY_RSA)
  ------------------
  |  Branch (1674:6): [True: 0, False: 122]
  ------------------
 1675|      0|		{
 1676|      0|			if((r=myeid_loadkey(card, LOAD_KEY_PRIME_P,
  ------------------
  |  |   37|      0|#define LOAD_KEY_PRIME_P		0x0083
  ------------------
  |  Branch (1676:7): [True: 0, False: 0]
  ------------------
 1677|      0|				data->primep, data->primep_len)) >= 0 &&
 1678|      0|			(r=myeid_loadkey(card, LOAD_KEY_PRIME_Q,
  ------------------
  |  |   38|      0|#define LOAD_KEY_PRIME_Q		0x0084
  ------------------
  |  Branch (1678:4): [True: 0, False: 0]
  ------------------
 1679|      0|				data->primeq, data->primeq_len)) >= 0 &&
 1680|      0|			(r=myeid_loadkey(card, LOAD_KEY_DP1,
  ------------------
  |  |   39|      0|#define LOAD_KEY_DP1			0x0085
  ------------------
  |  Branch (1680:4): [True: 0, False: 0]
  ------------------
 1681|      0|				data->dp1, data->dp1_len)) >= 0 &&
 1682|      0|			(r=myeid_loadkey(card, LOAD_KEY_DQ1,
  ------------------
  |  |   40|      0|#define LOAD_KEY_DQ1			0x0086
  ------------------
  |  Branch (1682:4): [True: 0, False: 0]
  ------------------
 1683|      0|				data->dq1, data->dq1_len)) >= 0 &&
 1684|      0|			(r=myeid_loadkey(card, LOAD_KEY_INVQ,
  ------------------
  |  |   41|      0|#define LOAD_KEY_INVQ			0x0087
  ------------------
  |  Branch (1684:4): [True: 0, False: 0]
  ------------------
 1685|      0|				data->invq, data->invq_len)) >= 0 &&
 1686|      0|			(r=myeid_loadkey(card, LOAD_KEY_MODULUS,
  ------------------
  |  |   35|      0|#define LOAD_KEY_MODULUS		0x0080
  ------------------
  |  Branch (1686:4): [True: 0, False: 0]
  ------------------
 1687|      0|				data->mod, data->key_len_bits)) >= 0 &&
 1688|      0|			(r=myeid_loadkey(card, LOAD_KEY_PUBLIC_EXPONENT,
  ------------------
  |  |   36|      0|#define LOAD_KEY_PUBLIC_EXPONENT	0x0081
  ------------------
  |  Branch (1688:4): [True: 0, False: 0]
  ------------------
 1689|      0|				data->pubexp, data->pubexp_len)) >= 0)
 1690|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1691|      0|		}
 1692|    122|		else if(data->key_type == SC_CARDCTL_MYEID_KEY_EC) {
  ------------------
  |  Branch (1692:11): [True: 0, False: 122]
  ------------------
 1693|      0|			if((r = myeid_loadkey(card, LOAD_KEY_EC_PRIVATE, data->d,
  ------------------
  |  |   43|      0|#define LOAD_KEY_EC_PRIVATE		0x1087
  ------------------
  |  Branch (1693:7): [True: 0, False: 0]
  ------------------
 1694|      0|					data->d_len)) >= 0 &&
 1695|      0|				(r = myeid_loadkey(card, LOAD_KEY_EC_PUBLIC, data->ecpublic_point,
  ------------------
  |  |   42|      0|#define LOAD_KEY_EC_PUBLIC		0x1086
  ------------------
  |  Branch (1695:5): [True: 0, False: 0]
  ------------------
 1696|      0|					data->ecpublic_point_len)) >= 0)
 1697|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1698|      0|		}
 1699|    122|		else if(data->key_type == SC_CARDCTL_MYEID_KEY_AES ||
  ------------------
  |  Branch (1699:11): [True: 55, False: 67]
  ------------------
 1700|     95|			data->key_type == SC_CARDCTL_MYEID_KEY_DES) {
  ------------------
  |  Branch (1700:4): [True: 40, False: 27]
  ------------------
 1701|     95|			if((r = myeid_loadkey(card, LOAD_KEY_SYMMETRIC, data->d,
  ------------------
  |  |   44|     95|#define LOAD_KEY_SYMMETRIC		0x20a0
  ------------------
  |  Branch (1701:7): [True: 82, False: 13]
  ------------------
 1702|     95|					data->d_len)) >= 0)
 1703|     95|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     82|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     82|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     82|	int _ret = r; \
  |  |  |  |  155|     82|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 82, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     82|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 82]
  |  |  |  |  ------------------
  |  |  |  |  157|     82|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     82|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     82|	return _ret; \
  |  |  |  |  163|     82|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1704|     95|		}
 1705|    122|	}
 1706|       |
 1707|    102|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    102|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    102|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    102|	int _ret = r; \
  |  |  |  |  155|    102|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 102, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    102|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     13|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 13, False: 89]
  |  |  |  |  ------------------
  |  |  |  |  157|    102|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    102|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    102|	return _ret; \
  |  |  |  |  163|    102|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1708|    102|}
card-myeid.c:myeid_loadkey:
 1569|     95|{
 1570|     95|	myeid_private_data_t *priv = (myeid_private_data_t *) card->drv_data;
 1571|     95|	sc_apdu_t apdu;
 1572|     95|	u8 sbuf[MYEID_MAX_EXT_APDU_BUFFER_SIZE];
 1573|     95|	int r;
 1574|       |
 1575|     95|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     95|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     95|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     95|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     95|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 95]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1576|     95|	if (value_len == 0 || value == NULL)
  ------------------
  |  Branch (1576:6): [True: 0, False: 95]
  |  Branch (1576:24): [True: 0, False: 95]
  ------------------
 1577|      0|		return 0;
 1578|       |
 1579|     95|	if (mode == LOAD_KEY_MODULUS && value_len == 256 && !priv->cap_chaining)
  ------------------
  |  |   35|    190|#define LOAD_KEY_MODULUS		0x0080
  ------------------
  |  Branch (1579:6): [True: 0, False: 95]
  |  Branch (1579:34): [True: 0, False: 0]
  |  Branch (1579:54): [True: 0, False: 0]
  ------------------
 1580|      0|	{
 1581|      0|		mode = 0x88;
 1582|      0|		memset(&apdu, 0, sizeof(apdu));
 1583|      0|		sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xDA, 0x01, mode);
  ------------------
  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1584|       |
 1585|      0|		apdu.cla     = 0x00;
 1586|      0|		apdu.data    = value;
 1587|      0|		apdu.datalen = 128;
 1588|      0|		apdu.lc	     = 128;
 1589|       |
 1590|      0|		r = sc_transmit_apdu(card, &apdu);
 1591|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1592|       |
 1593|      0|		r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1594|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1595|       |
 1596|      0|		mode = 0x89;
 1597|      0|		value += 128;
 1598|      0|		value_len -= 128;
 1599|      0|	}
 1600|     95|	else if ((mode & 0xff00) == 0 && mode != LOAD_KEY_PUBLIC_EXPONENT &&
  ------------------
  |  |   36|     95|#define LOAD_KEY_PUBLIC_EXPONENT	0x0081
  ------------------
  |  Branch (1600:11): [True: 0, False: 95]
  |  Branch (1600:35): [True: 0, False: 0]
  ------------------
 1601|      0|		 value[0] != 0x00)
  ------------------
  |  Branch (1601:4): [True: 0, False: 0]
  ------------------
 1602|      0|	{
 1603|       |		/* RSA components needing leading zero byte */
 1604|      0|		sbuf[0] = 0x0;
 1605|      0|		memcpy(&sbuf[1], value, value_len);
 1606|      0|		value = sbuf;
 1607|      0|		value_len ++;
 1608|      0|	}
 1609|       |
 1610|     95|	memset(&apdu, 0, sizeof(apdu));
 1611|     95|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xDA, 0x01, mode & 0xFF);
  ------------------
  |  |  293|     95|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1612|     95|	apdu.flags   = SC_APDU_FLAGS_CHAINING;
  ------------------
  |  |  306|     95|#define SC_APDU_FLAGS_CHAINING		0x00000001UL
  ------------------
 1613|     95|	apdu.cla     = 0x00;
 1614|     95|	apdu.data    = value;
 1615|     95|	apdu.datalen = value_len;
 1616|     95|	apdu.lc	     = value_len;
 1617|       |
 1618|     95|	r = sc_transmit_apdu(card, &apdu);
 1619|     95|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  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: 6, False: 89]
  |  |  |  |  ------------------
  |  |  |  |  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|     95|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 89]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1620|       |
 1621|     89|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1622|     89|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     89|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     89|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     89|	int _ret = r; \
  |  |  |  |  155|     89|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 89, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|      7|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 7, False: 82]
  |  |  |  |  ------------------
  |  |  |  |  157|     89|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     89|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     89|	return _ret; \
  |  |  |  |  163|     89|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1623|     89|}
card-myeid.c:myeid_activate_card:
 1711|    708|{
 1712|    708|	int r;
 1713|    708|	u8 sbuf[] ="\xA0\x00\x00\x00\x63\x50\x4B\x43\x53\x2D\x31\x35";
 1714|    708|	sc_apdu_t apdu;
 1715|       |
 1716|    708|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    708|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    708|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    708|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    708|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 708]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1717|    708|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x44, 0x04, 0x00);
  ------------------
  |  |  293|    708|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1718|    708|	apdu.cla     = 0x00;
 1719|    708|	apdu.data    = sbuf;
 1720|    708|	apdu.datalen = 0x0C;
 1721|    708|	apdu.lc	     = 0x0C;
 1722|       |
 1723|    708|	r = sc_transmit_apdu(card, &apdu);
 1724|    708|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    708|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    708|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    708|	int _ret = (r); \
  |  |  |  |  168|    708|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 4, False: 704]
  |  |  |  |  ------------------
  |  |  |  |  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|    708|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 704]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1725|       |
 1726|    704|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1727|    704|	LOG_TEST_RET(card->ctx, r, "ACTIVATE_APPLET returned error");
  ------------------
  |  |  174|    704|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    704|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    704|	int _ret = (r); \
  |  |  |  |  168|    704|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 651, False: 53]
  |  |  |  |  ------------------
  |  |  |  |  169|    651|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    651|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    651|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    651|		return _ret; \
  |  |  |  |  172|    651|	} \
  |  |  |  |  173|    704|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 53]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1728|       |
 1729|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1730|     53|}
card-myeid.c:myeid_get_serialnr:
 1768|    980|{
 1769|    980|	int r;
 1770|    980|	u8  rbuf[256];
 1771|       |
 1772|    980|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    980|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    980|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    980|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    980|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 980]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1773|       |
 1774|       |	/* if number cached, get it
 1775|       |	if(card->serialnr.value) {
 1776|       |		memcpy(serial, &card->serialnr, sizeof(*serial));
 1777|       |		LOG_FUNC_RETURN(card->ctx, r);
 1778|       |	}*/
 1779|       |
 1780|       |	/* get number from card */
 1781|    980|	r = myeid_get_info(card, rbuf, sizeof(rbuf));
 1782|    980|	LOG_TEST_RET(card->ctx, r,  "Get applet info failed");
  ------------------
  |  |  174|    980|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    980|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    980|	int _ret = (r); \
  |  |  |  |  168|    980|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 604, False: 376]
  |  |  |  |  ------------------
  |  |  |  |  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|    980|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 376]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1783|       |
 1784|       |	/* cache serial number */
 1785|    376|	memcpy(card->serialnr.value, &rbuf[8], 10);
 1786|    376|	card->serialnr.len = 10;
 1787|       |
 1788|       |	/* copy and return serial number */
 1789|    376|	memcpy(serial, &card->serialnr, sizeof(*serial));
 1790|       |
 1791|    376|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    376|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    376|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    376|	int _ret = r; \
  |  |  |  |  155|    376|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 376]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1792|    376|}
card-myeid.c:myeid_get_change_counter:
 1796|     22|{
 1797|     22|	int r;
 1798|     22|	u8 rbuf[256];
 1799|       |
 1800|     22|	LOG_FUNC_CALLED(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1801|       |
 1802|       |	/* get change counter from card */
 1803|     22|	r = myeid_get_info(card, rbuf, sizeof(rbuf));
 1804|     22|	LOG_TEST_RET(card->ctx, r, "Get applet info failed");
  ------------------
  |  |  174|     22|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     22|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     22|	int _ret = (r); \
  |  |  |  |  168|     22|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 13, False: 9]
  |  |  |  |  ------------------
  |  |  |  |  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|     22|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1805|       |
 1806|      9|	*change_counter = rbuf[18] * 256 + rbuf[19];
 1807|       |
 1808|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1809|      9|}
card-myeid.c:myeid_pin_cmd:
  666|    703|{
  667|    703|	myeid_private_data_t *priv = (myeid_private_data_t *) card->drv_data;
  668|       |
  669|    703|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    703|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    703|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    703|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    703|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 703]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  670|       |
  671|    703|	sc_log(card->ctx, "cmd (%d), ref (%d), pin1 len(%zu), pin2 len (%zu), puk ref (%d)\n",
  ------------------
  |  |   71|    703|#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|    703|			data->cmd, data->pin_reference, data->pin1.len, data->pin2.len, data->puk_reference);
  673|       |
  674|    703|	if(data->pin1.len > 8 || data->pin2.len > 8)
  ------------------
  |  Branch (674:5): [True: 0, False: 703]
  |  Branch (674:27): [True: 0, False: 703]
  ------------------
  675|    703|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_PIN_LENGTH);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  676|       |
  677|    703|	data->pin1.pad_length = data->pin2.pad_length = 8;
  678|    703|	data->pin1.pad_char = data->pin2.pad_char = 0xFF;
  679|       |
  680|    703|	if (data->cmd == SC_PIN_CMD_UNBLOCK) {
  ------------------
  |  |  417|    703|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (680:6): [True: 0, False: 703]
  ------------------
  681|       |		/* In case the PUK reference is set, the PIN is being unblocked implicitly using a global unblocker PIN instead of the
  682|       |		directly associated PUK. In this case, we must issue a VERIFY command first and then the RESET RETRY COUNTER command with only
  683|       |		the new PIN in the data field. */
  684|       |
  685|      0|		struct sc_pin_cmd_data global_unblocker_verif_data;
  686|      0|		int r;
  687|       |
  688|      0|		if (data->puk_reference != 0) {
  ------------------
  |  Branch (688:7): [True: 0, False: 0]
  ------------------
  689|       |			/* Call the iso driver to do the VERIFY */
  690|      0|			memset(&global_unblocker_verif_data, 0, sizeof(global_unblocker_verif_data));
  691|      0|			global_unblocker_verif_data.pin_type = SC_AC_CHV;
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  692|      0|			global_unblocker_verif_data.cmd = SC_PIN_CMD_VERIFY;
  ------------------
  |  |  415|      0|#define SC_PIN_CMD_VERIFY	0
  ------------------
  693|      0|			global_unblocker_verif_data.pin1 = data->pin1;
  694|      0|			global_unblocker_verif_data.pin_reference = data->puk_reference;
  695|      0|			global_unblocker_verif_data.flags = data->flags;
  696|      0|			r = iso_ops->pin_cmd(card, &global_unblocker_verif_data);
  697|      0|			LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  698|       |
  699|      0|			if (r != SC_SUCCESS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (699:8): [True: 0, False: 0]
  ------------------
  700|      0|				LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  701|       |
  702|      0|			memset(&data->pin1, 0, sizeof(struct sc_pin_cmd_pin));
  703|      0|			data->flags |= SC_PIN_CMD_IMPLICIT_CHANGE;
  ------------------
  |  |  423|      0|#define SC_PIN_CMD_IMPLICIT_CHANGE	0x0004
  ------------------
  704|      0|			struct sc_apdu apdu;
  705|      0|			u8 buf[SC_MAX_APDU_BUFFER_SIZE];
  706|       |
  707|       |			/* Let iso driver build the RESET RETRY COUNTER APDU, but we'll have to modify it before transmitting it. */
  708|      0|			r = iso7816_build_pin_apdu(card, &apdu, data, buf, sizeof(buf));
  709|       |
  710|      0|			if (r != SC_SUCCESS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (710:8): [True: 0, False: 0]
  ------------------
  711|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  712|       |
  713|       |			/* MyEID's implementation of unblocking a PIN implicitly contradicts with ISO 7816-4 here. The iso driver properly sets P2=0x02
  714|       |			while MyEID expects 0x00 */
  715|      0|			apdu.p1 = 0x00;
  716|       |
  717|      0|			r = sc_transmit_apdu(card, &apdu);
  718|       |
  719|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  720|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  721|      0|		}
  722|      0|	}
  723|       |
  724|    703|	if (data->cmd == SC_PIN_CMD_VERIFY && priv->card_state == SC_FILE_STATUS_CREATION) {
  ------------------
  |  |  415|  1.40k|#define SC_PIN_CMD_VERIFY	0
  ------------------
              	if (data->cmd == SC_PIN_CMD_VERIFY && priv->card_state == SC_FILE_STATUS_CREATION) {
  ------------------
  |  |  240|     12|#define SC_FILE_STATUS_CREATION		0x02 /* ISO7816-4: Creation state, (1) */
  ------------------
  |  Branch (724:6): [True: 12, False: 691]
  |  Branch (724:40): [True: 6, False: 6]
  ------------------
  725|      6|		sc_log(card->ctx, "Card in creation state, no need to verify");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  726|      6|		return SC_SUCCESS;
  ------------------
  |  |   28|      6|#define SC_SUCCESS				0
  ------------------
  727|      6|	}
  728|       |
  729|    697|	LOG_FUNC_RETURN(card->ctx, iso_ops->pin_cmd(card, data));
  ------------------
  |  |  164|    697|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    697|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    697|	int _ret = r; \
  |  |  |  |  155|    697|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 697, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    697|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    277|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 277, False: 420]
  |  |  |  |  ------------------
  |  |  |  |  157|    697|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    697|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    697|	return _ret; \
  |  |  |  |  163|    697|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  730|    697|}

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

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

sc_get_oberthur_driver:
 2319|  16.3k|{
 2320|  16.3k|	return sc_get_driver();
 2321|  16.3k|}
card-oberthur.c:sc_get_driver:
 2288|  16.3k|{
 2289|  16.3k|	if (iso_ops == NULL)
  ------------------
  |  Branch (2289:6): [True: 1, False: 16.3k]
  ------------------
 2290|      1|		iso_ops = sc_get_iso7816_driver()->ops;
 2291|       |
 2292|  16.3k|	auth_ops = *iso_ops;
 2293|  16.3k|	auth_ops.match_card = auth_match_card;
 2294|  16.3k|	auth_ops.init = auth_init;
 2295|  16.3k|	auth_ops.finish = auth_finish;
 2296|  16.3k|	auth_ops.select_file = auth_select_file;
 2297|  16.3k|	auth_ops.list_files = auth_list_files;
 2298|  16.3k|	auth_ops.delete_file = auth_delete_file;
 2299|  16.3k|	auth_ops.create_file = auth_create_file;
 2300|  16.3k|	auth_ops.read_binary = auth_read_binary;
 2301|  16.3k|	auth_ops.update_binary = auth_update_binary;
 2302|  16.3k|	auth_ops.read_record = auth_read_record;
 2303|  16.3k|	auth_ops.delete_record = auth_delete_record;
 2304|  16.3k|	auth_ops.card_ctl = auth_card_ctl;
 2305|  16.3k|	auth_ops.set_security_env = auth_set_security_env;
 2306|  16.3k|	auth_ops.restore_security_env = auth_restore_security_env;
 2307|  16.3k|	auth_ops.compute_signature = auth_compute_signature;
 2308|  16.3k|	auth_ops.decipher = auth_decipher;
 2309|  16.3k|	auth_ops.process_fci = auth_process_fci;
 2310|  16.3k|	auth_ops.pin_cmd = auth_pin_cmd;
 2311|  16.3k|	auth_ops.logout = auth_logout;
 2312|  16.3k|	auth_ops.check_sw = auth_check_sw;
 2313|  16.3k|	return &auth_drv;
 2314|  16.3k|}
card-oberthur.c:auth_match_card:
  204|  14.0k|{
  205|  14.0k|	if (_sc_match_atr(card, oberthur_atrs, &card->type) < 0)
  ------------------
  |  Branch (205:6): [True: 13.1k, False: 852]
  ------------------
  206|  13.1k|		return 0;
  207|    852|	else
  208|    852|		return 1;
  209|  14.0k|}
card-oberthur.c:auth_init:
  214|    852|{
  215|    852|	struct auth_private_data *data;
  216|    852|	struct sc_path path;
  217|    852|	unsigned long flags;
  218|    852|	int rv = 0;
  219|       |
  220|    852|	data = calloc(1, sizeof(struct auth_private_data));
  221|    852|	if (!data)
  ------------------
  |  Branch (221:6): [True: 0, False: 852]
  ------------------
  222|    852|		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|    852|	card->cla = 0x00;
  225|    852|	card->drv_data = data;
  226|       |
  227|    852|	card->caps |= SC_CARD_CAP_RNG;
  ------------------
  |  |  550|    852|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  228|    852|	card->caps |= SC_CARD_CAP_USE_FCI_AC;
  ------------------
  |  |  557|    852|#define SC_CARD_CAP_USE_FCI_AC		0x00000010
  ------------------
  229|       |
  230|    852|	if (auth_select_aid(card)) {
  ------------------
  |  Branch (230:6): [True: 46, False: 806]
  ------------------
  231|     46|		sc_log(card->ctx, "Failed to initialize %s", card->name);
  ------------------
  |  |   71|     46|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  232|     46|		rv = SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|     46|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  233|     46|		LOG_TEST_GOTO_ERR(card->ctx, SC_ERROR_INVALID_CARD, "Failed to initialize");
  ------------------
  |  |  184|     46|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     46|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     46|	int _ret = (r); \
  |  |  |  |  178|     46|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 46, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|     46|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     46|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     46|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     46|		goto err; \
  |  |  |  |  182|     46|	} \
  |  |  |  |  183|     46|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  234|     46|	}
  235|       |
  236|    806|	sc_format_path("3F00", &path);
  237|    806|	rv = auth_select_file(card, &path, NULL);
  238|       |
  239|    852|err:
  240|    852|	if (rv == SC_SUCCESS) {
  ------------------
  |  |   28|    852|#define SC_SUCCESS				0
  ------------------
  |  Branch (240:6): [True: 806, False: 46]
  ------------------
  241|    806|		flags = SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_PAD_ISO9796;
  ------------------
  |  |  111|    806|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|    806|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|    806|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
              		flags = SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_PAD_ISO9796;
  ------------------
  |  |  106|    806|#define SC_ALGORITHM_RSA_PAD_ISO9796	0x00000008
  ------------------
  242|    806|		flags |= SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  133|    806|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  243|    806|		flags |= SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|    806|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  244|       |
  245|    806|		_sc_card_add_rsa_alg(card, 512, flags, 0);
  246|    806|		_sc_card_add_rsa_alg(card, 1024, flags, 0);
  247|    806|		_sc_card_add_rsa_alg(card, 2048, flags, 0);
  248|    806|	} else {
  249|     46|		free(card->drv_data);
  250|     46|		card->drv_data = NULL;
  251|     46|	}
  252|       |
  253|    852|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  164|    852|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    852|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    852|	int _ret = r; \
  |  |  |  |  155|    852|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 852, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    852|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     46|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 46, False: 806]
  |  |  |  |  ------------------
  |  |  |  |  157|    852|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    852|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    852|	return _ret; \
  |  |  |  |  163|    852|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  254|    852|}
card-oberthur.c:auth_select_aid:
  145|    852|{
  146|    852|	struct sc_apdu apdu;
  147|    852|	unsigned char apdu_resp[SC_MAX_APDU_BUFFER_SIZE];
  148|    852|	struct auth_private_data *data = (struct auth_private_data *)card->drv_data;
  149|    852|	int rv, ii;
  150|    852|	struct sc_path tmp_path;
  151|       |
  152|       |	/* Select Card Manager (to deselect previously selected application) */
  153|    852|	rv = gp_select_card_manager(card);
  154|    852|	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|    852|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    852|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    852|	int _ret = (r); \
  |  |  |  |  168|    852|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 23, False: 829]
  |  |  |  |  ------------------
  |  |  |  |  169|     23|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     23|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     23|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     23|		return _ret; \
  |  |  |  |  172|     23|	} \
  |  |  |  |  173|    852|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 829]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  155|       |
  156|       |	/* Get smart card serial number */
  157|    829|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xCA, 0x9F, 0x7F);
  ------------------
  |  |  292|    829|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  158|    829|	apdu.cla = 0x80;
  159|    829|	apdu.le = 0x2D;
  160|    829|	apdu.resplen = 0x30;
  161|    829|	apdu.resp = apdu_resp;
  162|       |
  163|    829|	rv = sc_transmit_apdu(card, &apdu);
  164|    829|	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|    829|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    829|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    829|	int _ret = (r); \
  |  |  |  |  168|    829|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 828]
  |  |  |  |  ------------------
  |  |  |  |  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|    829|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 828]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  165|    828|	if (apdu.resplen < 20) {
  ------------------
  |  Branch (165:6): [True: 13, False: 815]
  ------------------
  166|     13|		LOG_TEST_RET(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Serial number has incorrect length");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  167|     13|	}
  168|    815|	card->serialnr.len = 4;
  169|    815|	memcpy(card->serialnr.value, apdu.resp+15, 4);
  170|       |
  171|  4.07k|	for (ii=0, data->sn = 0; ii < 4; ii++)
  ------------------
  |  Branch (171:27): [True: 3.26k, False: 815]
  ------------------
  172|  3.26k|		data->sn += (long int)(*(apdu.resp + 15 + ii)) << (3-ii)*8;
  173|       |
  174|    815|	sc_log(card->ctx, "serial number %li/0x%lX", data->sn, data->sn);
  ------------------
  |  |   71|    815|#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|    815|	memset(&tmp_path, 0, sizeof(struct sc_path));
  177|    815|	tmp_path.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|    815|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  178|    815|	memcpy(tmp_path.value, aidAuthentIC_V5, lenAidAuthentIC_V5);
  179|    815|	tmp_path.len = lenAidAuthentIC_V5;
  180|       |
  181|    815|	rv = iso_ops->select_file(card, &tmp_path, NULL);
  182|    815|	LOG_TEST_RET(card->ctx, rv, "select parent failed");
  ------------------
  |  |  174|    815|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    815|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    815|	int _ret = (r); \
  |  |  |  |  168|    815|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 812]
  |  |  |  |  ------------------
  |  |  |  |  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|    815|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 812]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  183|       |
  184|    812|	sc_format_path("3F00", &tmp_path);
  185|    812|	sc_file_free(auth_current_df);
  186|    812|	auth_current_df = NULL;
  187|    812|	rv = iso_ops->select_file(card, &tmp_path, &auth_current_df);
  188|    812|	LOG_TEST_RET(card->ctx, rv, "select parent failed");
  ------------------
  |  |  174|    812|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    812|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    812|	int _ret = (r); \
  |  |  |  |  168|    812|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 806]
  |  |  |  |  ------------------
  |  |  |  |  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|    812|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 806]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  189|       |
  190|    806|	sc_file_free(auth_current_ef);
  191|    806|	auth_current_ef = NULL;
  192|    806|	sc_file_dup(&auth_current_ef, auth_current_df);
  193|       |
  194|    806|	memcpy(data->aid, aidAuthentIC_V5, lenAidAuthentIC_V5);
  195|    806|	data->aid_len = lenAidAuthentIC_V5;
  196|    806|	card->name = nameAidAuthentIC_V5;
  197|       |
  198|    806|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  164|    806|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    806|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    806|	int _ret = r; \
  |  |  |  |  155|    806|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 806, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    806|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 806]
  |  |  |  |  ------------------
  |  |  |  |  157|    806|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    806|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    806|	return _ret; \
  |  |  |  |  163|    806|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  199|    806|}
card-oberthur.c:auth_finish:
  137|    806|{
  138|    806|	free(card->drv_data);
  139|    806|	return SC_SUCCESS;
  ------------------
  |  |   28|    806|#define SC_SUCCESS				0
  ------------------
  140|    806|}
card-oberthur.c:auth_select_file:
  443|  19.9k|{
  444|  19.9k|	struct sc_path path;
  445|  19.9k|	struct sc_file *tmp_file = NULL;
  446|  19.9k|	size_t offs, ii;
  447|  19.9k|	int rv;
  448|       |
  449|  19.9k|	if (card == NULL || in_path == NULL)
  ------------------
  |  Branch (449:6): [True: 0, False: 19.9k]
  |  Branch (449:22): [True: 0, False: 19.9k]
  ------------------
  450|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  451|       |
  452|  19.9k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  19.9k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  19.9k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  19.9k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  19.9k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 19.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  453|       |
  454|  19.9k|	memcpy(&path, in_path, sizeof(struct sc_path));
  455|       |
  456|  19.9k|	if (!auth_current_df)
  ------------------
  |  Branch (456:6): [True: 0, False: 19.9k]
  ------------------
  457|      0|		return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|      0|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  458|       |
  459|  19.9k|	sc_log(card->ctx, "in_path; type=%d, path=%s, out %p",
  ------------------
  |  |   71|  19.9k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  460|  19.9k|			in_path->type, sc_print_path(in_path), file_out);
  461|  19.9k|	sc_log(card->ctx, "current path; type=%d, path=%s",
  ------------------
  |  |   71|  19.9k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  462|  19.9k|			auth_current_df->path.type, sc_print_path(&auth_current_df->path));
  463|  19.9k|	if (auth_current_ef)
  ------------------
  |  Branch (463:6): [True: 8.35k, False: 11.5k]
  ------------------
  464|  8.35k|		sc_log(card->ctx, "current file; type=%d, path=%s",
  ------------------
  |  |   71|  8.35k|#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|  19.9k|				auth_current_ef->path.type, sc_print_path(&auth_current_ef->path));
  466|       |
  467|  19.9k|	if (path.type == SC_PATH_TYPE_PARENT || path.type == SC_PATH_TYPE_FILE_ID) {
  ------------------
  |  |  123|  39.8k|#define SC_PATH_TYPE_PARENT		5
  ------------------
              	if (path.type == SC_PATH_TYPE_PARENT || path.type == SC_PATH_TYPE_FILE_ID) {
  ------------------
  |  |  117|  19.5k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (467:6): [True: 422, False: 19.5k]
  |  Branch (467:42): [True: 7.56k, False: 11.9k]
  ------------------
  468|  7.98k|		sc_file_free(auth_current_ef);
  469|  7.98k|		auth_current_ef = NULL;
  470|       |
  471|  7.98k|		rv = iso_ops->select_file(card, &path, &tmp_file);
  472|  7.98k|		LOG_TEST_RET(card->ctx, rv, "select file failed");
  ------------------
  |  |  174|  7.98k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  7.98k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  7.98k|	int _ret = (r); \
  |  |  |  |  168|  7.98k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 4.68k, False: 3.30k]
  |  |  |  |  ------------------
  |  |  |  |  169|  4.68k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  4.68k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  4.68k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  4.68k|		return _ret; \
  |  |  |  |  172|  4.68k|	} \
  |  |  |  |  173|  7.98k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3.30k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  473|  3.30k|		if (!tmp_file)
  ------------------
  |  Branch (473:7): [True: 0, False: 3.30k]
  ------------------
  474|      0|			return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|      0|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  475|       |
  476|  3.30k|		if (path.type == SC_PATH_TYPE_PARENT) {
  ------------------
  |  |  123|  3.30k|#define SC_PATH_TYPE_PARENT		5
  ------------------
  |  Branch (476:7): [True: 257, False: 3.05k]
  ------------------
  477|    257|			memcpy(&tmp_file->path, &auth_current_df->path, sizeof(struct sc_path));
  478|    257|			if (tmp_file->path.len > 2)
  ------------------
  |  Branch (478:8): [True: 56, False: 201]
  ------------------
  479|     56|				tmp_file->path.len -= 2;
  480|       |
  481|    257|			sc_file_free(auth_current_df);
  482|    257|			auth_current_df = NULL;
  483|    257|			sc_file_dup(&auth_current_df, tmp_file);
  484|  3.05k|		} else {
  485|  3.05k|			if (tmp_file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|  3.05k|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (485:8): [True: 340, False: 2.71k]
  ------------------
  486|    340|				sc_concatenate_path(&tmp_file->path, &auth_current_df->path, &path);
  487|       |
  488|    340|				sc_file_free(auth_current_df);
  489|    340|				auth_current_df = NULL;
  490|    340|				sc_file_dup(&auth_current_df, tmp_file);
  491|  2.71k|			} else {
  492|  2.71k|				sc_file_free(auth_current_ef);
  493|  2.71k|				auth_current_ef = NULL;
  494|       |
  495|  2.71k|				sc_file_dup(&auth_current_ef, tmp_file);
  496|  2.71k|				sc_concatenate_path(&auth_current_ef->path, &auth_current_df->path, &path);
  497|  2.71k|			}
  498|  3.05k|		}
  499|  3.30k|		if (file_out) {
  ------------------
  |  Branch (499:7): [True: 2.29k, False: 1.01k]
  ------------------
  500|  2.29k|			sc_file_free(*file_out);
  501|  2.29k|			sc_file_dup(file_out, tmp_file);
  502|  2.29k|		}
  503|       |
  504|  3.30k|		sc_file_free(tmp_file);
  505|  11.9k|	} else if (path.type == SC_PATH_TYPE_DF_NAME) {
  ------------------
  |  |  118|  11.9k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (505:13): [True: 1.36k, False: 10.5k]
  ------------------
  506|  1.36k|		rv = iso_ops->select_file(card, &path, NULL);
  507|  1.36k|		if (rv) {
  ------------------
  |  Branch (507:7): [True: 1.20k, False: 159]
  ------------------
  508|  1.20k|			sc_file_free(auth_current_ef);
  509|  1.20k|			auth_current_ef = NULL;
  510|  1.20k|		}
  511|  1.36k|		LOG_TEST_RET(card->ctx, rv, "select file 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: 1.20k, False: 159]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.20k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  1.20k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.20k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.20k|		return _ret; \
  |  |  |  |  172|  1.20k|	} \
  |  |  |  |  173|  1.36k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 159]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  512|  10.5k|	} else {
  513|  21.1k|		for (offs = 0; offs < path.len && offs < auth_current_df->path.len; offs += 2)
  ------------------
  |  Branch (513:18): [True: 17.2k, False: 3.91k]
  |  Branch (513:37): [True: 11.0k, False: 6.26k]
  ------------------
  514|  11.0k|			if (path.value[offs] != auth_current_df->path.value[offs] ||
  ------------------
  |  Branch (514:8): [True: 246, False: 10.7k]
  ------------------
  515|  10.7k|					path.value[offs + 1] != auth_current_df->path.value[offs + 1])
  ------------------
  |  Branch (515:6): [True: 151, False: 10.6k]
  ------------------
  516|    397|				break;
  517|       |
  518|  10.5k|		sc_log(card->ctx, "offs %zu", offs);
  ------------------
  |  |   71|  10.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__
  |  |  ------------------
  ------------------
  519|  10.5k|		if (offs && offs < auth_current_df->path.len) {
  ------------------
  |  Branch (519:7): [True: 8.73k, False: 1.83k]
  |  Branch (519:15): [True: 198, False: 8.53k]
  ------------------
  520|    198|			size_t deep = auth_current_df->path.len - offs;
  521|       |
  522|    198|			sc_log(card->ctx, "deep %zu", deep);
  ------------------
  |  |   71|    198|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  523|    253|			for (ii = 0; ii < deep; ii += 2) {
  ------------------
  |  Branch (523:17): [True: 206, False: 47]
  ------------------
  524|    206|				struct sc_path tmp_path;
  525|       |
  526|    206|				memcpy(&tmp_path, &auth_current_df->path,  sizeof(struct sc_path));
  527|    206|				tmp_path.type = SC_PATH_TYPE_PARENT;
  ------------------
  |  |  123|    206|#define SC_PATH_TYPE_PARENT		5
  ------------------
  528|       |
  529|    206|				if (file_out) {
  ------------------
  |  Branch (529:9): [True: 90, False: 116]
  ------------------
  530|     90|					sc_file_free(*file_out);
  531|     90|					*file_out = NULL;
  532|     90|				}
  533|       |
  534|    206|				rv = auth_select_file (card, &tmp_path, file_out);
  535|    206|				LOG_TEST_RET(card->ctx, rv, "select file failed");
  ------------------
  |  |  174|    206|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    206|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    206|	int _ret = (r); \
  |  |  |  |  168|    206|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 151, False: 55]
  |  |  |  |  ------------------
  |  |  |  |  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|    206|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 55]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  536|    206|			}
  537|    198|		}
  538|       |
  539|  10.4k|		if (path.len > offs) {
  ------------------
  |  Branch (539:7): [True: 6.50k, False: 3.91k]
  ------------------
  540|  6.50k|			struct sc_path tmp_path;
  541|       |
  542|  6.50k|			memset(&tmp_path, 0, sizeof(struct sc_path));
  543|  6.50k|			tmp_path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|  6.50k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  544|  6.50k|			tmp_path.len = 2;
  545|       |
  546|  9.18k|			for (ii = 0; ii < path.len - offs; ii += 2) {
  ------------------
  |  Branch (546:17): [True: 7.00k, False: 2.18k]
  ------------------
  547|  7.00k|				memcpy(tmp_path.value, path.value + offs + ii, 2);
  548|       |
  549|  7.00k|				if (file_out) {
  ------------------
  |  Branch (549:9): [True: 5.41k, False: 1.58k]
  ------------------
  550|  5.41k|					sc_file_free(*file_out);
  551|  5.41k|					*file_out = NULL;
  552|  5.41k|				}
  553|       |
  554|  7.00k|				rv = auth_select_file(card, &tmp_path, file_out);
  555|  7.00k|				LOG_TEST_RET(card->ctx, rv, "select file failed");
  ------------------
  |  |  174|  7.00k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  7.00k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  7.00k|	int _ret = (r); \
  |  |  |  |  168|  7.00k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 4.32k, False: 2.67k]
  |  |  |  |  ------------------
  |  |  |  |  169|  4.32k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.32k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  4.32k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  4.32k|		return _ret; \
  |  |  |  |  172|  4.32k|	} \
  |  |  |  |  173|  7.00k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.67k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  556|  7.00k|			}
  557|  6.50k|		} else if (path.len - offs == 0 && file_out) {
  ------------------
  |  Branch (557:14): [True: 3.91k, False: 0]
  |  Branch (557:38): [True: 3.02k, False: 891]
  ------------------
  558|  3.02k|			if (sc_compare_path(&path, &auth_current_df->path) && file_out) {
  ------------------
  |  Branch (558:8): [True: 1.38k, False: 1.63k]
  |  Branch (558:58): [True: 1.38k, False: 0]
  ------------------
  559|  1.38k|				sc_file_free(*file_out);
  560|  1.38k|				sc_file_dup(file_out, auth_current_df);
  561|  1.63k|			} else  if (auth_current_ef && file_out) {
  ------------------
  |  Branch (561:16): [True: 1.35k, False: 277]
  |  Branch (561:35): [True: 1.35k, False: 0]
  ------------------
  562|  1.35k|				sc_file_free(*file_out);
  563|  1.35k|				sc_file_dup(file_out, auth_current_ef);
  564|  1.35k|			} else {
  565|    277|				LOG_TEST_RET(card->ctx, SC_ERROR_INTERNAL, "No current EF");
  ------------------
  |  |  174|    277|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    277|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    277|	int _ret = (r); \
  |  |  |  |  168|    277|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 277, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|    277|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  566|    277|			}
  567|  3.02k|		}
  568|  10.4k|	}
  569|       |
  570|  9.28k|	LOG_FUNC_RETURN(card->ctx, 0);
  ------------------
  |  |  164|  9.28k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  9.28k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  9.28k|	int _ret = r; \
  |  |  |  |  155|  9.28k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 9.28k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  9.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: 9.28k]
  |  |  |  |  ------------------
  |  |  |  |  157|  9.28k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  9.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|  9.28k|	return _ret; \
  |  |  |  |  163|  9.28k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  571|  9.28k|}
card-oberthur.c:auth_list_files:
  576|    375|{
  577|    375|	struct sc_apdu apdu;
  578|    375|	unsigned char rbuf[SC_MAX_APDU_BUFFER_SIZE];
  579|    375|	int rv;
  580|       |
  581|    375|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    375|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    375|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    375|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    375|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 375]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  582|    375|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0x34, 0, 0);
  ------------------
  |  |  292|    375|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  583|    375|	apdu.cla = 0x80;
  584|    375|	apdu.le = 0x40;
  585|    375|	apdu.resplen = sizeof(rbuf);
  586|    375|	apdu.resp = rbuf;
  587|       |
  588|    375|	rv = sc_transmit_apdu(card, &apdu);
  589|    375|	LOG_TEST_RET(card->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: 1, False: 374]
  |  |  |  |  ------------------
  |  |  |  |  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|    375|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 374]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  590|       |
  591|    374|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  592|    374|	LOG_TEST_RET(card->ctx, rv, "Card returned error");
  ------------------
  |  |  174|    374|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    374|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    374|	int _ret = (r); \
  |  |  |  |  168|    374|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 7, False: 367]
  |  |  |  |  ------------------
  |  |  |  |  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|    374|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 367]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  593|       |
  594|    367|	if (apdu.resplen == 0x100 && rbuf[0]==0 && rbuf[1]==0)
  ------------------
  |  Branch (594:6): [True: 3, False: 364]
  |  Branch (594:31): [True: 2, False: 1]
  |  Branch (594:45): [True: 1, False: 1]
  ------------------
  595|    367|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  596|       |
  597|    366|	buflen = MIN(buflen, apdu.resplen);
  ------------------
  |  |   70|    366|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 0, False: 366]
  |  |  ------------------
  ------------------
  598|    366|	memcpy(buf, rbuf, buflen);
  599|       |
  600|    366|	LOG_FUNC_RETURN(card->ctx, (int)buflen);
  ------------------
  |  |  164|    366|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    366|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    366|	int _ret = r; \
  |  |  |  |  155|    366|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 213, False: 153]
  |  |  |  |  ------------------
  |  |  |  |  156|    213|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 213]
  |  |  |  |  ------------------
  |  |  |  |  157|    213|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    213|	} else { \
  |  |  |  |  159|    153|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    153|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    153|	} \
  |  |  |  |  162|    366|	return _ret; \
  |  |  |  |  163|    366|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  601|    366|}
card-oberthur.c:auth_delete_file:
  606|    907|{
  607|    907|	struct sc_apdu apdu;
  608|    907|	unsigned char sbuf[2];
  609|    907|	int rv;
  610|    907|	char pbuf[SC_MAX_PATH_STRING_SIZE];
  611|       |
  612|    907|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    907|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    907|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    907|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    907|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 907]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  613|       |
  614|    907|	rv = sc_path_print(pbuf, sizeof(pbuf), path);
  615|    907|	if (rv != SC_SUCCESS)
  ------------------
  |  |   28|    907|#define SC_SUCCESS				0
  ------------------
  |  Branch (615:6): [True: 0, False: 907]
  ------------------
  616|      0|		pbuf[0] = '\0';
  617|       |
  618|    907|	sc_log(card->ctx, "path; type=%d, path=%s", path->type, pbuf);
  ------------------
  |  |   71|    907|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  619|       |
  620|    907|	if (path->len < 2) {
  ------------------
  |  Branch (620:6): [True: 0, False: 907]
  ------------------
  621|      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__
  |  |  ------------------
  ------------------
  622|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  623|      0|	}
  624|       |
  625|    907|	if (path->len > 2) {
  ------------------
  |  Branch (625:6): [True: 0, False: 907]
  ------------------
  626|      0|		struct sc_path parent = *path;
  627|       |
  628|      0|		parent.len -= 2;
  629|      0|		parent.type = SC_PATH_TYPE_PATH;
  ------------------
  |  |  119|      0|#define SC_PATH_TYPE_PATH		2
  ------------------
  630|      0|		rv = auth_select_file(card, &parent, NULL);
  631|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  632|      0|	}
  633|       |
  634|    907|	sbuf[0] = path->value[path->len - 2];
  635|    907|	sbuf[1] = path->value[path->len - 1];
  636|       |
  637|    907|	if (memcmp(sbuf,"\x00\x00",2)==0 || (memcmp(sbuf,"\xFF\xFF",2)==0) ||
  ------------------
  |  Branch (637:6): [True: 7, False: 900]
  |  Branch (637:38): [True: 5, False: 895]
  ------------------
  638|    895|			memcmp(sbuf,"\x3F\xFF",2)==0)
  ------------------
  |  Branch (638:4): [True: 1, False: 894]
  ------------------
  639|    907|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS);
  ------------------
  |  |  164|     13|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     13|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     13|	int _ret = r; \
  |  |  |  |  155|     13|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 13, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     13|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     13|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 13, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     13|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     13|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     13|	return _ret; \
  |  |  |  |  163|     13|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  640|       |
  641|    894|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE4, 0x02, 0x00);
  ------------------
  |  |  293|    894|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  642|    894|	apdu.lc = 2;
  643|    894|	apdu.datalen = 2;
  644|    894|	apdu.data = sbuf;
  645|       |
  646|    894|	rv = sc_transmit_apdu(card, &apdu);
  647|    894|	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|    894|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    894|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    894|	int _ret = (r); \
  |  |  |  |  168|    894|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 891]
  |  |  |  |  ------------------
  |  |  |  |  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|    894|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 891]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  648|    891|	if (apdu.sw1 == 0x6A && apdu.sw2 == 0x82) {
  ------------------
  |  Branch (648:6): [True: 399, False: 492]
  |  Branch (648:26): [True: 390, False: 9]
  ------------------
  649|       |		/* Clean up tDF contents.*/
  650|    390|		struct sc_path tmp_path;
  651|    390|		int ii, len;
  652|    390|		unsigned char lbuf[SC_MAX_APDU_BUFFER_SIZE];
  653|       |
  654|    390|		memset(&tmp_path, 0, sizeof(struct sc_path));
  655|    390|		tmp_path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|    390|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  656|    390|		memcpy(tmp_path.value, sbuf, 2);
  657|    390|		tmp_path.len = 2;
  658|    390|		rv = auth_select_file(card, &tmp_path, NULL);
  659|    390|		LOG_TEST_RET(card->ctx, rv, "select DF failed");
  ------------------
  |  |  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: 15, False: 375]
  |  |  |  |  ------------------
  |  |  |  |  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|    390|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 375]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  660|       |
  661|    375|		len = auth_list_files(card, lbuf, sizeof(lbuf));
  662|    375|		LOG_TEST_RET(card->ctx, len, "list DF 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  663|       |
  664|    961|		for (ii = 0; ii < len / 2; ii++) {
  ------------------
  |  Branch (664:16): [True: 745, False: 216]
  ------------------
  665|    745|			struct sc_path tmp_path_x;
  666|       |
  667|    745|			memset(&tmp_path_x, 0, sizeof(struct sc_path));
  668|    745|			tmp_path_x.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|    745|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  669|    745|			tmp_path_x.value[0] = *(lbuf + ii*2);
  670|    745|			tmp_path_x.value[1] = *(lbuf + ii*2 + 1);
  671|    745|			tmp_path_x.len = 2;
  672|       |
  673|    745|			rv = auth_delete_file(card, &tmp_path_x);
  674|    745|			LOG_TEST_RET(card->ctx, rv, "delete failed");
  ------------------
  |  |  174|    745|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    745|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    745|	int _ret = (r); \
  |  |  |  |  168|    745|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 151, False: 594]
  |  |  |  |  ------------------
  |  |  |  |  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|    745|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 594]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  675|    745|		}
  676|       |
  677|    216|		tmp_path.type = SC_PATH_TYPE_PARENT;
  ------------------
  |  |  123|    216|#define SC_PATH_TYPE_PARENT		5
  ------------------
  678|    216|		rv = auth_select_file(card, &tmp_path, NULL);
  679|    216|		LOG_TEST_RET(card->ctx, rv, "select parent failed");
  ------------------
  |  |  174|    216|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    216|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    216|	int _ret = (r); \
  |  |  |  |  168|    216|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 14, False: 202]
  |  |  |  |  ------------------
  |  |  |  |  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|    216|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 202]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  680|       |
  681|    202|		apdu.p1 = 1;
  682|    202|		rv = sc_transmit_apdu(card, &apdu);
  683|    202|	}
  684|       |
  685|    703|	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|    703|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    703|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    703|	int _ret = (r); \
  |  |  |  |  168|    703|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 702]
  |  |  |  |  ------------------
  |  |  |  |  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|    703|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 702]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  686|    702|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  687|       |
  688|    702|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  164|    702|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    702|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    702|	int _ret = r; \
  |  |  |  |  155|    702|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 702, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    702|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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: 650]
  |  |  |  |  ------------------
  |  |  |  |  157|    702|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    702|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    702|	return _ret; \
  |  |  |  |  163|    702|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  689|    702|}
card-oberthur.c:auth_create_file:
  902|     63|{
  903|     63|	struct sc_apdu apdu;
  904|     63|	struct sc_path path;
  905|     63|	int rv, rec_nr;
  906|     63|	unsigned char sbuf[0x18];
  907|     63|	size_t sendlen = sizeof(sbuf);
  908|     63|	char pbuf[SC_MAX_PATH_STRING_SIZE];
  909|       |
  910|     63|	LOG_FUNC_CALLED(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  911|       |
  912|     63|	rv = sc_path_print(pbuf, sizeof(pbuf), &file->path);
  913|     63|	if (rv != SC_SUCCESS)
  ------------------
  |  |   28|     63|#define SC_SUCCESS				0
  ------------------
  |  Branch (913:6): [True: 0, False: 63]
  ------------------
  914|      0|		pbuf[0] = '\0';
  915|     63|	sc_log(card->ctx, " create path=%s", pbuf);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  916|       |
  917|     63|	sc_log(card->ctx, "id %04X; size %zu; type 0x%X; ef 0x%X",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  918|     63|			file->id, file->size, file->type, file->ef_structure);
  919|       |
  920|     63|	if (file->id==0x0000 || file->id==0xFFFF || file->id==0x3FFF)
  ------------------
  |  Branch (920:6): [True: 1, False: 62]
  |  Branch (920:26): [True: 1, False: 61]
  |  Branch (920:46): [True: 1, False: 60]
  ------------------
  921|     63|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  922|       |
  923|     60|	if (file->path.len) {
  ------------------
  |  Branch (923:6): [True: 60, False: 0]
  ------------------
  924|     60|		memcpy(&path, &file->path, sizeof(path));
  925|     60|		if (path.len>2)
  ------------------
  |  Branch (925:7): [True: 39, False: 21]
  ------------------
  926|     39|			path.len -= 2;
  927|       |
  928|     60|		if (auth_select_file(card, &path, NULL)) {
  ------------------
  |  Branch (928:7): [True: 13, False: 47]
  ------------------
  929|     13|			sc_log(card->ctx, "Cannot select parent DF.");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  930|     13|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|     13|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     13|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     13|	int _ret = r; \
  |  |  |  |  155|     13|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 13, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     13|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     13|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 13, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     13|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     13|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     13|	return _ret; \
  |  |  |  |  163|     13|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  931|     13|		}
  932|     60|	}
  933|       |
  934|     47|	rv = encode_file_structure_V5(card, file, sbuf, &sendlen);
  935|     47|	LOG_TEST_RET(card->ctx, rv, "File structure encoding failed");
  ------------------
  |  |  174|     47|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     47|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     47|	int _ret = (r); \
  |  |  |  |  168|     47|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 14, False: 33]
  |  |  |  |  ------------------
  |  |  |  |  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|     47|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 33]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  936|       |
  937|     33|	if (file->type != SC_FILE_TYPE_DF && file->ef_structure != SC_FILE_EF_TRANSPARENT)
  ------------------
  |  |  214|     66|#define SC_FILE_TYPE_DF			0x04
  ------------------
              	if (file->type != SC_FILE_TYPE_DF && file->ef_structure != SC_FILE_EF_TRANSPARENT)
  ------------------
  |  |  221|     25|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (937:6): [True: 25, False: 8]
  |  Branch (937:39): [True: 1, False: 24]
  ------------------
  938|      1|		rec_nr = (int)file->record_count;
  939|     32|	else
  940|     32|		rec_nr = 0;
  941|       |
  942|     33|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE0, 0x00, rec_nr);
  ------------------
  |  |  293|     33|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  943|     33|	apdu.data = sbuf;
  944|     33|	apdu.datalen = sendlen;
  945|     33|	apdu.lc = sendlen;
  946|       |
  947|     33|	rv = sc_transmit_apdu(card, &apdu);
  948|     33|	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|     33|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     33|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     33|	int _ret = (r); \
  |  |  |  |  168|     33|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 32]
  |  |  |  |  ------------------
  |  |  |  |  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|     33|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 32]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  949|     32|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  950|     32|	LOG_TEST_RET(card->ctx, rv, "Card returned error");
  ------------------
  |  |  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: 16, False: 16]
  |  |  |  |  ------------------
  |  |  |  |  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|     32|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 16]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  951|       |
  952|       |	/* select created DF. */
  953|     16|	if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|     16|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (953:6): [True: 5, False: 11]
  ------------------
  954|      5|		struct sc_path tmp_path;
  955|      5|		struct sc_file *df_file = NULL;
  956|       |
  957|      5|		memset(&tmp_path, 0, sizeof(struct sc_path));
  958|      5|		tmp_path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|      5|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  959|      5|		tmp_path.value[0] = file->id >> 8;
  960|      5|		tmp_path.value[1] = file->id & 0xFF;
  961|      5|		tmp_path.len = 2;
  962|      5|		rv = auth_select_file(card, &tmp_path, &df_file);
  963|      5|		sc_log(card->ctx, "rv %i", rv);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  964|      5|		sc_file_free(df_file);
  965|      5|	}
  966|       |
  967|     16|	sc_file_free(auth_current_ef);
  968|     16|	auth_current_ef = NULL;
  969|     16|	sc_file_dup(&auth_current_ef, file);
  970|       |
  971|     16|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  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|      5|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 5, False: 11]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  972|     16|}
card-oberthur.c:encode_file_structure_V5:
  729|     47|{
  730|     47|	size_t ii;
  731|     47|	int rv = 0;
  732|     47|	size_t size;
  733|     47|	unsigned char *p = buf;
  734|     47|	unsigned char  ops[8] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
  735|       |
  736|     47|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     47|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     47|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     47|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     47|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  737|     47|	sc_log(card->ctx, "id %04X; size %zu; type 0x%X/0x%X",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  738|     47|			file->id, file->size, file->type, file->ef_structure);
  739|       |
  740|     47|	if (*buflen < 0x18)
  ------------------
  |  Branch (740:6): [True: 0, False: 47]
  ------------------
  741|     47|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  742|       |
  743|     47|	p[0] = 0x62, p[1] = 0x16;
  744|     47|	p[2] = 0x82, p[3] = 0x02;
  745|       |
  746|     47|	rv = 0;
  747|     47|	if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|     47|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (747:6): [True: 13, False: 34]
  ------------------
  748|     13|		p[4] = 0x38;
  749|     13|		p[5] = 0x00;
  750|     34|	} else if (file->type == SC_FILE_TYPE_WORKING_EF) {
  ------------------
  |  |  216|     34|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (750:13): [True: 25, False: 9]
  ------------------
  751|     25|		switch (file->ef_structure) {
  752|     24|		case SC_FILE_EF_TRANSPARENT:
  ------------------
  |  |  221|     24|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (752:3): [True: 24, False: 1]
  ------------------
  753|     24|			p[4] = 0x01;
  754|     24|			p[5] = 0x01;
  755|     24|			break;
  756|      0|		case SC_FILE_EF_LINEAR_VARIABLE:
  ------------------
  |  |  224|      0|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  |  Branch (756:3): [True: 0, False: 25]
  ------------------
  757|      0|			p[4] = 0x04;
  758|      0|			p[5] = 0x01;
  759|      0|			break;
  760|      1|		default:
  ------------------
  |  Branch (760:3): [True: 1, False: 24]
  ------------------
  761|      1|			rv = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      1|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  762|      1|			break;
  763|     25|		}
  764|     25|	} else if (file->type == SC_FILE_TYPE_INTERNAL_EF) {
  ------------------
  |  |  215|      9|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (764:13): [True: 1, False: 8]
  ------------------
  765|      1|		switch (file->ef_structure) {
  766|      0|		case SC_CARDCTL_OBERTHUR_KEY_DES:
  ------------------
  |  Branch (766:3): [True: 0, False: 1]
  ------------------
  767|      0|			p[4] = 0x11;
  768|      0|			p[5] = 0x00;
  769|      0|			break;
  770|      0|		case SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC:
  ------------------
  |  Branch (770:3): [True: 0, False: 1]
  ------------------
  771|      0|			p[4] = 0x12;
  772|      0|			p[5] = 0x00;
  773|      0|			break;
  774|      1|		case SC_CARDCTL_OBERTHUR_KEY_RSA_CRT:
  ------------------
  |  Branch (774:3): [True: 1, False: 0]
  ------------------
  775|      1|			p[4] = 0x14;
  776|      1|			p[5] = 0x00;
  777|      1|			break;
  778|      0|		default:
  ------------------
  |  Branch (778:3): [True: 0, False: 1]
  ------------------
  779|      0|			rv = -1;
  780|      0|			break;
  781|      1|		}
  782|      1|	} else
  783|      8|		rv = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      8|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  784|       |
  785|     47|	if (rv) {
  ------------------
  |  Branch (785:6): [True: 9, False: 38]
  ------------------
  786|      9|		sc_log(card->ctx, "Invalid EF structure 0x%X/0x%X", file->type, file->ef_structure);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  787|      9|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS);
  ------------------
  |  |  164|      9|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      9|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      9|	int _ret = r; \
  |  |  |  |  155|      9|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 9, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      9|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      9|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 9, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      9|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      9|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      9|	return _ret; \
  |  |  |  |  163|      9|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  788|      9|	}
  789|       |
  790|     38|	p[6] = 0x83;
  791|     38|	p[7] = 0x02;
  792|     38|	p[8] = file->id >> 8;
  793|     38|	p[9] = file->id & 0xFF;
  794|       |
  795|     38|	p[10] = 0x85;
  796|     38|	p[11] = 0x02;
  797|       |
  798|     38|	size = file->size;
  799|       |
  800|     38|	if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|     38|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (800:6): [True: 13, False: 25]
  ------------------
  801|     13|		size &= 0xFF;
  802|     25|	} else if (file->type == SC_FILE_TYPE_INTERNAL_EF &&
  ------------------
  |  |  215|     50|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (802:13): [True: 1, False: 24]
  ------------------
  803|      1|			file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC) {
  ------------------
  |  Branch (803:4): [True: 0, False: 1]
  ------------------
  804|      0|		sc_log(card->ctx, "ef %s","SC_FILE_EF_RSA_PUBLIC");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  805|      0|		if (file->size == PUBKEY_512_ASN1_SIZE || file->size == 512)
  ------------------
  |  |  100|      0|#define PUBKEY_512_ASN1_SIZE	0x4A
  ------------------
  |  Branch (805:7): [True: 0, False: 0]
  |  Branch (805:45): [True: 0, False: 0]
  ------------------
  806|      0|			size = 512;
  807|      0|		else if (file->size == PUBKEY_1024_ASN1_SIZE || file->size == 1024)
  ------------------
  |  |  101|      0|#define PUBKEY_1024_ASN1_SIZE	0x8C
  ------------------
  |  Branch (807:12): [True: 0, False: 0]
  |  Branch (807:51): [True: 0, False: 0]
  ------------------
  808|      0|			size = 1024;
  809|      0|		else if (file->size == PUBKEY_2048_ASN1_SIZE || file->size == 2048)
  ------------------
  |  |  102|      0|#define PUBKEY_2048_ASN1_SIZE	0x10E
  ------------------
  |  Branch (809:12): [True: 0, False: 0]
  |  Branch (809:51): [True: 0, False: 0]
  ------------------
  810|      0|			size = 2048;
  811|      0|		else {
  812|      0|			sc_log(card->ctx, "incorrect RSA size %zX", 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__
  |  |  ------------------
  ------------------
  813|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  814|      0|		}
  815|     25|	} else if (file->type == SC_FILE_TYPE_INTERNAL_EF &&
  ------------------
  |  |  215|     50|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (815:13): [True: 1, False: 24]
  ------------------
  816|      1|			file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_DES) {
  ------------------
  |  Branch (816:4): [True: 0, False: 1]
  ------------------
  817|      0|		if (file->size == 8 || file->size == 64)
  ------------------
  |  Branch (817:7): [True: 0, False: 0]
  |  Branch (817:26): [True: 0, False: 0]
  ------------------
  818|      0|			size = 64;
  819|      0|		else if (file->size == 16 || file->size == 128)
  ------------------
  |  Branch (819:12): [True: 0, False: 0]
  |  Branch (819:32): [True: 0, False: 0]
  ------------------
  820|      0|			size = 128;
  821|      0|		else if (file->size == 24 || file->size == 192)
  ------------------
  |  Branch (821:12): [True: 0, False: 0]
  |  Branch (821:32): [True: 0, False: 0]
  ------------------
  822|      0|			size = 192;
  823|      0|		else {
  824|      0|			sc_log(card->ctx, "incorrect DES size %zu", 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__
  |  |  ------------------
  ------------------
  825|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  826|      0|		}
  827|      0|	}
  828|       |
  829|     38|	p[12] = (size >> 8) & 0xFF;
  830|     38|	p[13] = size & 0xFF;
  831|       |
  832|     38|	p[14] = 0x86;
  833|     38|	p[15] = 0x08;
  834|       |
  835|     38|	if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|     38|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (835:6): [True: 13, False: 25]
  ------------------
  836|     13|		ops[0] = SC_AC_OP_CREATE;
  ------------------
  |  |  169|     13|#define SC_AC_OP_CREATE			3
  ------------------
  837|     13|		ops[1] = SC_AC_OP_CRYPTO;
  ------------------
  |  |  173|     13|#define SC_AC_OP_CRYPTO			7
  ------------------
  838|     13|		ops[2] = SC_AC_OP_LIST_FILES;
  ------------------
  |  |  172|     13|#define SC_AC_OP_LIST_FILES		6
  ------------------
  839|     13|		ops[3] = SC_AC_OP_DELETE;
  ------------------
  |  |  168|     13|#define SC_AC_OP_DELETE			2
  ------------------
  840|     13|		ops[4] = SC_AC_OP_PIN_DEFINE;
  ------------------
  |  |  183|     13|#define SC_AC_OP_PIN_DEFINE		17
  ------------------
  841|     13|		ops[5] = SC_AC_OP_PIN_CHANGE;
  ------------------
  |  |  184|     13|#define SC_AC_OP_PIN_CHANGE		18
  ------------------
  842|     13|		ops[6] = SC_AC_OP_PIN_RESET;
  ------------------
  |  |  185|     13|#define SC_AC_OP_PIN_RESET		19
  ------------------
  843|     25|	} else if (file->type == SC_FILE_TYPE_WORKING_EF) {
  ------------------
  |  |  216|     25|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (843:13): [True: 24, False: 1]
  ------------------
  844|     24|		if (file->ef_structure == SC_FILE_EF_TRANSPARENT) {
  ------------------
  |  |  221|     24|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (844:7): [True: 24, False: 0]
  ------------------
  845|     24|			sc_log(card->ctx, "SC_FILE_EF_TRANSPARENT");
  ------------------
  |  |   71|     24|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  846|     24|			ops[0] = SC_AC_OP_WRITE;
  ------------------
  |  |  190|     24|#define SC_AC_OP_WRITE			24
  ------------------
  847|     24|			ops[1] = SC_AC_OP_UPDATE;
  ------------------
  |  |  189|     24|#define SC_AC_OP_UPDATE			23
  ------------------
  848|     24|			ops[2] = SC_AC_OP_READ;
  ------------------
  |  |  188|     24|#define SC_AC_OP_READ			22
  ------------------
  849|     24|			ops[3] = SC_AC_OP_ERASE;
  ------------------
  |  |  202|     24|#define SC_AC_OP_ERASE			SC_AC_OP_DELETE
  |  |  ------------------
  |  |  |  |  168|     24|#define SC_AC_OP_DELETE			2
  |  |  ------------------
  ------------------
  850|     24|		} else if (file->ef_structure == SC_FILE_EF_LINEAR_VARIABLE) {
  ------------------
  |  |  224|      0|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  |  Branch (850:14): [True: 0, False: 0]
  ------------------
  851|      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__
  |  |  ------------------
  ------------------
  852|      0|			ops[0] = SC_AC_OP_WRITE;
  ------------------
  |  |  190|      0|#define SC_AC_OP_WRITE			24
  ------------------
  853|      0|			ops[1] = SC_AC_OP_UPDATE;
  ------------------
  |  |  189|      0|#define SC_AC_OP_UPDATE			23
  ------------------
  854|      0|			ops[2] = SC_AC_OP_READ;
  ------------------
  |  |  188|      0|#define SC_AC_OP_READ			22
  ------------------
  855|      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
  |  |  ------------------
  ------------------
  856|      0|		}
  857|     24|	} else if (file->type == SC_FILE_TYPE_INTERNAL_EF) {
  ------------------
  |  |  215|      1|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (857:13): [True: 1, False: 0]
  ------------------
  858|      1|		if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_DES) {
  ------------------
  |  Branch (858:7): [True: 0, False: 1]
  ------------------
  859|      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__
  |  |  ------------------
  ------------------
  860|      0|			ops[0] = SC_AC_OP_UPDATE;
  ------------------
  |  |  189|      0|#define SC_AC_OP_UPDATE			23
  ------------------
  861|      0|			ops[1] = SC_AC_OP_PSO_DECRYPT;
  ------------------
  |  |  175|      0|#define SC_AC_OP_PSO_DECRYPT		9
  ------------------
  862|      0|			ops[2] = SC_AC_OP_PSO_ENCRYPT;
  ------------------
  |  |  176|      0|#define SC_AC_OP_PSO_ENCRYPT		10
  ------------------
  863|      0|			ops[3] = SC_AC_OP_PSO_COMPUTE_CHECKSUM;
  ------------------
  |  |  179|      0|#define SC_AC_OP_PSO_COMPUTE_CHECKSUM	13
  ------------------
  864|      0|			ops[4] = SC_AC_OP_PSO_VERIFY_CHECKSUM;
  ------------------
  |  |  180|      0|#define SC_AC_OP_PSO_VERIFY_CHECKSUM	14
  ------------------
  865|      0|			ops[5] = SC_AC_OP_INTERNAL_AUTHENTICATE;
  ------------------
  |  |  181|      0|#define SC_AC_OP_INTERNAL_AUTHENTICATE	15
  ------------------
  866|      0|			ops[6] = SC_AC_OP_EXTERNAL_AUTHENTICATE;
  ------------------
  |  |  182|      0|#define SC_AC_OP_EXTERNAL_AUTHENTICATE	16
  ------------------
  867|      1|		} else if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC) {
  ------------------
  |  Branch (867:14): [True: 0, False: 1]
  ------------------
  868|      0|			sc_log(card->ctx, "EF_RSA_PUBLIC");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  869|      0|			ops[0] = SC_AC_OP_UPDATE;
  ------------------
  |  |  189|      0|#define SC_AC_OP_UPDATE			23
  ------------------
  870|      0|			ops[2] = SC_AC_OP_PSO_ENCRYPT;
  ------------------
  |  |  176|      0|#define SC_AC_OP_PSO_ENCRYPT		10
  ------------------
  871|      0|			ops[4] = SC_AC_OP_PSO_VERIFY_SIGNATURE;
  ------------------
  |  |  178|      0|#define SC_AC_OP_PSO_VERIFY_SIGNATURE	12
  ------------------
  872|      0|			ops[6] = SC_AC_OP_EXTERNAL_AUTHENTICATE;
  ------------------
  |  |  182|      0|#define SC_AC_OP_EXTERNAL_AUTHENTICATE	16
  ------------------
  873|      1|		} else if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_CRT) {
  ------------------
  |  Branch (873:14): [True: 1, False: 0]
  ------------------
  874|      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__
  |  |  ------------------
  ------------------
  875|      1|			ops[0] = SC_AC_OP_UPDATE;
  ------------------
  |  |  189|      1|#define SC_AC_OP_UPDATE			23
  ------------------
  876|      1|			ops[1] = SC_AC_OP_PSO_DECRYPT;
  ------------------
  |  |  175|      1|#define SC_AC_OP_PSO_DECRYPT		9
  ------------------
  877|      1|			ops[3] = SC_AC_OP_PSO_COMPUTE_SIGNATURE;
  ------------------
  |  |  177|      1|#define SC_AC_OP_PSO_COMPUTE_SIGNATURE	11
  ------------------
  878|      1|			ops[5] = SC_AC_OP_INTERNAL_AUTHENTICATE;
  ------------------
  |  |  181|      1|#define SC_AC_OP_INTERNAL_AUTHENTICATE	15
  ------------------
  879|      1|		}
  880|      1|	}
  881|       |
  882|    312|	for (ii = 0; ii < sizeof(ops); ii++) {
  ------------------
  |  Branch (882:15): [True: 279, False: 33]
  ------------------
  883|    279|		const struct sc_acl_entry *entry;
  884|       |
  885|    279|		p[16+ii] = 0xFF;
  886|    279|		if (ops[ii]==0xFF)
  ------------------
  |  Branch (886:7): [True: 108, False: 171]
  ------------------
  887|    108|			continue;
  888|    171|		entry = sc_file_get_acl_entry(file, ops[ii]);
  889|    171|		rv = acl_to_ac_byte(card,entry);
  890|    171|		LOG_TEST_RET(card->ctx, rv, "Invalid ACL");
  ------------------
  |  |  174|    171|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    171|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    171|	int _ret = (r); \
  |  |  |  |  168|    171|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 5, False: 166]
  |  |  |  |  ------------------
  |  |  |  |  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|    171|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 166]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  891|    166|		p[16+ii] = rv;
  892|    166|	}
  893|       |
  894|     33|	*buflen = 0x18;
  895|       |
  896|     33|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|     33|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     33|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     33|	int _ret = r; \
  |  |  |  |  155|     33|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 33, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     33|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 33]
  |  |  |  |  ------------------
  |  |  |  |  157|     33|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     33|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     33|	return _ret; \
  |  |  |  |  163|     33|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  897|     33|}
card-oberthur.c:acl_to_ac_byte:
  694|    171|{
  695|    171|	unsigned key_ref;
  696|       |
  697|    171|	if (e == NULL)
  ------------------
  |  Branch (697:6): [True: 0, False: 171]
  ------------------
  698|      0|		return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|      0|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  699|       |
  700|    171|	key_ref = e->key_ref & ~OBERTHUR_PIN_LOCAL;
  ------------------
  |  |   41|    171|#define OBERTHUR_PIN_LOCAL	0x80
  ------------------
  701|       |
  702|    171|	switch (e->method) {
  ------------------
  |  Branch (702:10): [True: 170, False: 1]
  ------------------
  703|    157|	case SC_AC_NONE:
  ------------------
  |  |  150|    157|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (703:2): [True: 157, False: 14]
  ------------------
  704|    157|		LOG_FUNC_RETURN(card->ctx, 0);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 157]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  705|       |
  706|      6|	case SC_AC_CHV:
  ------------------
  |  |  151|      6|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (706:2): [True: 6, False: 165]
  ------------------
  707|      6|		if (key_ref > 0 && key_ref < 6)
  ------------------
  |  Branch (707:7): [True: 4, False: 2]
  |  Branch (707:22): [True: 3, False: 1]
  ------------------
  708|      6|			LOG_FUNC_RETURN(card->ctx, (0x20 | key_ref));
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  709|      3|		else
  710|      6|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  711|       |
  712|      1|	case SC_AC_PRO:
  ------------------
  |  |  153|      1|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  |  Branch (712:2): [True: 1, False: 170]
  ------------------
  713|      1|		if (((key_ref & 0xE0) != 0x60) || ((key_ref & 0x18) == 0))
  ------------------
  |  Branch (713:7): [True: 1, False: 0]
  |  Branch (713:37): [True: 0, False: 0]
  ------------------
  714|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  715|      0|		else
  716|      1|			LOG_FUNC_RETURN(card->ctx, 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  717|       |
  718|      6|	case SC_AC_NEVER:
  ------------------
  |  |  163|      6|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (718:2): [True: 6, False: 165]
  ------------------
  719|      6|		return 0xff;
  720|    171|	}
  721|       |
  722|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  723|      1|}
card-oberthur.c:auth_read_binary:
 2102|  6.47k|{
 2103|  6.47k|	int rv;
 2104|  6.47k|	size_t sz;
 2105|  6.47k|	struct sc_pkcs15_bignum bn[2];
 2106|  6.47k|	unsigned char *out = NULL;
 2107|  6.47k|	bn[0].data = NULL;
 2108|  6.47k|	bn[1].data = NULL;
 2109|       |
 2110|  6.47k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  6.47k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  6.47k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  6.47k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  6.47k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 6.47k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2111|       |
 2112|  6.47k|	if (!auth_current_ef)
  ------------------
  |  Branch (2112:6): [True: 891, False: 5.58k]
  ------------------
 2113|  6.47k|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS, "Invalid auth_current_ef");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2114|       |
 2115|  5.58k|	sc_log(card->ctx, "offset %i; size %zu; flags 0x%lX", offset, count, flags ? *flags : 0);
  ------------------
  |  |   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__
  |  |  ------------------
  |  |  |  Branch (71:122): [True: 1.20k, False: 4.38k]
  |  |  ------------------
  ------------------
 2116|  5.58k|	sc_log(card->ctx, "last selected : magic %X; ef %X",
  ------------------
  |  |   71|  5.58k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2117|  5.58k|			auth_current_ef->magic, auth_current_ef->ef_structure);
 2118|       |
 2119|  5.58k|	if (offset & ~0x7FFF)
  ------------------
  |  Branch (2119:6): [True: 1, False: 5.58k]
  ------------------
 2120|  5.58k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2121|       |
 2122|  5.58k|	if (auth_current_ef->magic == SC_FILE_MAGIC &&
  ------------------
  |  |   57|  11.1k|#define SC_FILE_MAGIC			0x14426950
  ------------------
  |  Branch (2122:6): [True: 5.58k, False: 0]
  ------------------
 2123|  5.58k|			auth_current_ef->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC) {
  ------------------
  |  Branch (2123:4): [True: 91, False: 5.49k]
  ------------------
 2124|     91|		int jj;
 2125|     91|		unsigned char resp[SC_MAX_APDU_RESP_SIZE];
 2126|     91|		size_t resp_len, out_len;
 2127|     91|		struct sc_pkcs15_pubkey_rsa key;
 2128|       |
 2129|     91|		resp_len = sizeof(resp);
 2130|     91|		rv = auth_read_component(card, SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC,
 2131|     91|				2, resp, resp_len);
 2132|     91|		LOG_TEST_RET(card->ctx, rv, "read component failed");
  ------------------
  |  |  174|     91|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     91|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     91|	int _ret = (r); \
  |  |  |  |  168|     91|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 17, False: 74]
  |  |  |  |  ------------------
  |  |  |  |  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|     91|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 74]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2133|       |
 2134|    284|		for (jj=0; jj<rv && *(resp+jj)==0; jj++)
  ------------------
  |  Branch (2134:14): [True: 274, False: 10]
  |  Branch (2134:23): [True: 210, False: 64]
  ------------------
 2135|    210|			;
 2136|       |
 2137|     74|		if (rv - jj == 0)
  ------------------
  |  Branch (2137:7): [True: 10, False: 64]
  ------------------
 2138|     10|			return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|     10|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 2139|     64|		bn[0].data = calloc(1, rv - jj);
 2140|     64|		if (!bn[0].data) {
  ------------------
  |  Branch (2140:7): [True: 0, False: 64]
  ------------------
 2141|      0|			rv = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2142|      0|			goto err;
 2143|      0|		}
 2144|     64|		bn[0].len = rv - jj;
 2145|     64|		memcpy(bn[0].data, resp + jj, rv - jj);
 2146|       |
 2147|     64|		rv = auth_read_component(card, SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC,
 2148|     64|				1, resp, resp_len);
 2149|     64|		LOG_TEST_GOTO_ERR(card->ctx, rv, "Cannot read RSA public key component");
  ------------------
  |  |  184|     64|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     64|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     64|	int _ret = (r); \
  |  |  |  |  178|     64|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 10, False: 54]
  |  |  |  |  ------------------
  |  |  |  |  179|     10|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     10|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     10|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     10|		goto err; \
  |  |  |  |  182|     10|	} \
  |  |  |  |  183|     64|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 54]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2150|       |
 2151|     54|		bn[1].data = calloc(1, rv);
 2152|     54|		if (!bn[1].data) {
  ------------------
  |  Branch (2152:7): [True: 0, False: 54]
  ------------------
 2153|      0|			rv = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2154|      0|			goto err;
 2155|      0|		}
 2156|     54|		bn[1].len = rv;
 2157|     54|		memcpy(bn[1].data, resp, rv);
 2158|       |
 2159|     54|		key.exponent = bn[0];
 2160|     54|		key.modulus = bn[1];
 2161|       |
 2162|     54|		if (sc_pkcs15_encode_pubkey_rsa(card->ctx, &key, &out, &out_len) != SC_SUCCESS) {
  ------------------
  |  |   28|     54|#define SC_SUCCESS				0
  ------------------
  |  Branch (2162:7): [True: 2, False: 52]
  ------------------
 2163|      2|			rv = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      2|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 2164|      2|			LOG_TEST_GOTO_ERR(card->ctx, rv, "cannot encode RSA 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2165|      2|		}
 2166|     52|		else {
 2167|     52|			if (out_len < offset) {
  ------------------
  |  Branch (2167:8): [True: 5, False: 47]
  ------------------
 2168|      5|				rv = SC_ERROR_UNKNOWN_DATA_RECEIVED;
  ------------------
  |  |   63|      5|#define SC_ERROR_UNKNOWN_DATA_RECEIVED		-1213
  ------------------
 2169|      5|				goto err;
 2170|      5|			}
 2171|     47|			sz = MIN(out_len - offset, count);
  ------------------
  |  |   70|     47|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 29, False: 18]
  |  |  ------------------
  ------------------
 2172|     47|			memcpy(buf, out + offset, sz);
 2173|       |
 2174|     47|			sc_log_hex(card->ctx, "write_publickey", buf, sz);
  ------------------
  |  |  129|     47|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|     47|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2175|     47|			rv = (int)sz;
 2176|     47|		}
 2177|  5.49k|	} else {
 2178|  5.49k|		rv = iso_ops->read_binary(card, offset, buf, count, 0);
 2179|  5.49k|	}
 2180|       |
 2181|  5.56k|err:
 2182|  5.56k|	free(bn[0].data);
 2183|  5.56k|	free(bn[1].data);
 2184|  5.56k|	free(out);
 2185|       |
 2186|  5.56k|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  164|  5.56k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  5.56k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  5.56k|	int _ret = r; \
  |  |  |  |  155|  5.56k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.68k, False: 3.87k]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.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|  1.39k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.39k, False: 285]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.68k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.87k|	} else { \
  |  |  |  |  159|  3.87k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  3.87k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  3.87k|	} \
  |  |  |  |  162|  5.56k|	return _ret; \
  |  |  |  |  163|  5.56k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2187|  5.56k|}
card-oberthur.c:auth_read_component:
 1463|    155|{
 1464|    155|	struct sc_apdu apdu;
 1465|    155|	int rv;
 1466|    155|	unsigned char resp[SC_MAX_APDU_RESP_SIZE];
 1467|       |
 1468|    155|	LOG_FUNC_CALLED(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1469|    155|	sc_log(card->ctx, "num %i, outlen %zu, type %i", num, outlen, type);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1470|       |
 1471|    155|	if (!outlen || type!=SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC)
  ------------------
  |  Branch (1471:6): [True: 0, False: 155]
  |  Branch (1471:17): [True: 0, False: 155]
  ------------------
 1472|    155|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1473|       |
 1474|    155|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xB4,	num, 0x00);
  ------------------
  |  |  292|    155|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1475|    155|	apdu.cla |= 0x80;
 1476|    155|	apdu.le = outlen;
 1477|    155|	apdu.resp = resp;
 1478|    155|	apdu.resplen = sizeof(resp);
 1479|    155|	rv = sc_transmit_apdu(card, &apdu);
 1480|    155|	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  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: 2, False: 153]
  |  |  |  |  ------------------
  |  |  |  |  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|    155|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 153]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1481|       |
 1482|    153|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1483|    153|	LOG_TEST_RET(card->ctx, rv, "Card returned error");
  ------------------
  |  |  174|    153|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    153|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    153|	int _ret = (r); \
  |  |  |  |  168|    153|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 25, False: 128]
  |  |  |  |  ------------------
  |  |  |  |  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|    153|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 128]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1484|       |
 1485|    128|	if (outlen < apdu.resplen)
  ------------------
  |  Branch (1485:6): [True: 0, False: 128]
  ------------------
 1486|    128|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_WRONG_LENGTH);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1487|       |
 1488|    128|	memcpy(out, apdu.resp, apdu.resplen);
 1489|    128|	LOG_FUNC_RETURN(card->ctx, (int)apdu.resplen);
  ------------------
  |  |  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: 4, False: 124]
  |  |  |  |  ------------------
  |  |  |  |  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|    124|	} else { \
  |  |  |  |  159|    124|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    124|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    124|	} \
  |  |  |  |  162|    128|	return _ret; \
  |  |  |  |  163|    128|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1490|    128|}
card-oberthur.c:auth_update_binary:
 2064|     16|{
 2065|     16|	int rv = 0;
 2066|       |
 2067|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2068|       |
 2069|     16|	if (!auth_current_ef)
  ------------------
  |  Branch (2069:6): [True: 1, False: 15]
  ------------------
 2070|     16|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS, "Invalid auth_current_ef");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2071|       |
 2072|     15|	sc_log(card->ctx, "offset %i; count %zu", offset, count);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2073|     15|	sc_log(card->ctx, "last selected : magic %X; ef %X",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2074|     15|			auth_current_ef->magic, auth_current_ef->ef_structure);
 2075|       |
 2076|     15|	if (offset & ~0x7FFF)
  ------------------
  |  Branch (2076:6): [True: 0, False: 15]
  ------------------
 2077|     15|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS, "Invalid file offset");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2078|       |
 2079|     15|	if (auth_current_ef->magic == SC_FILE_MAGIC &&
  ------------------
  |  |   57|     30|#define SC_FILE_MAGIC			0x14426950
  ------------------
  |  Branch (2079:6): [True: 15, False: 0]
  ------------------
 2080|     15|			auth_current_ef->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC) {
  ------------------
  |  Branch (2080:4): [True: 0, False: 15]
  ------------------
 2081|      0|		rv = write_publickey(card, offset, buf, count);
 2082|     15|	} else if (auth_current_ef->magic == SC_FILE_MAGIC &&
  ------------------
  |  |   57|     30|#define SC_FILE_MAGIC			0x14426950
  ------------------
  |  Branch (2082:13): [True: 15, False: 0]
  ------------------
 2083|     15|			auth_current_ef->ef_structure == SC_CARDCTL_OBERTHUR_KEY_DES) {
  ------------------
  |  Branch (2083:4): [True: 0, False: 15]
  ------------------
 2084|      0|		struct auth_update_component_info args;
 2085|       |
 2086|      0|		memset(&args, 0, sizeof(args));
 2087|      0|		args.type = SC_CARDCTL_OBERTHUR_KEY_DES;
 2088|      0|		args.data = (unsigned char *)buf;
 2089|      0|		args.len = count;
 2090|      0|		rv = auth_update_component(card, &args);
 2091|     15|	} else {
 2092|     15|		rv = iso_ops->update_binary(card, offset, buf, count, 0);
 2093|     15|	}
 2094|       |
 2095|     15|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  164|     15|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     15|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     15|	int _ret = r; \
  |  |  |  |  155|     15|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 5, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  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|     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|     15|	return _ret; \
  |  |  |  |  163|     15|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2096|     15|}
card-oberthur.c:auth_read_record:
 2193|    142|{
 2194|    142|	struct sc_apdu apdu;
 2195|    142|	int rv = 0;
 2196|    142|	unsigned char recvbuf[SC_MAX_APDU_BUFFER_SIZE];
 2197|       |
 2198|    142|	sc_log(card->ctx, "auth_read_record(): nr_rec %i; count %zu", nr_rec, count);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2199|       |
 2200|    142|	if (nr_rec > 0xFF || idx != 0)
  ------------------
  |  Branch (2200:6): [True: 0, False: 142]
  |  Branch (2200:23): [True: 43, False: 99]
  ------------------
 2201|    142|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2202|       |
 2203|     99|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xB2, nr_rec, 0);
  ------------------
  |  |  292|     99|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 2204|     99|	apdu.p2 = (flags & SC_RECORD_EF_ID_MASK) << 3;
  ------------------
  |  | 1293|     99|#define SC_RECORD_EF_ID_MASK		0x0001FUL
  ------------------
 2205|     99|	if (flags & SC_RECORD_BY_REC_NR)
  ------------------
  |  | 1298|     99|#define SC_RECORD_BY_REC_NR		0x00100UL
  ------------------
  |  Branch (2205:6): [True: 99, False: 0]
  ------------------
 2206|     99|		apdu.p2 |= 0x04;
 2207|       |
 2208|     99|	apdu.le = MIN(count, SC_MAX_APDU_BUFFER_SIZE);
  ------------------
  |  |   70|     99|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 99, False: 0]
  |  |  ------------------
  ------------------
 2209|     99|	apdu.resplen = SC_MAX_APDU_BUFFER_SIZE;
  ------------------
  |  |   34|     99|#define SC_MAX_APDU_BUFFER_SIZE		261 /* takes account of: CLA INS P1 P2 Lc [255 byte of data] Le */
  ------------------
 2210|     99|	apdu.resp = recvbuf;
 2211|       |
 2212|     99|	rv = sc_transmit_apdu(card, &apdu);
 2213|     99|	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|     99|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     99|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     99|	int _ret = (r); \
  |  |  |  |  168|     99|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 96]
  |  |  |  |  ------------------
  |  |  |  |  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|     99|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 96]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2214|     96|	if (apdu.resplen == 0)
  ------------------
  |  Branch (2214:6): [True: 47, False: 49]
  ------------------
 2215|     96|		LOG_FUNC_RETURN(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  164|     47|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     47|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     47|	int _ret = r; \
  |  |  |  |  155|     47|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 47, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     47|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     19|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 19, False: 28]
  |  |  |  |  ------------------
  |  |  |  |  157|     47|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     47|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     47|	return _ret; \
  |  |  |  |  163|     47|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2216|     49|	if (count < apdu.resplen)
  ------------------
  |  Branch (2216:6): [True: 1, False: 48]
  ------------------
 2217|     49|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_WRONG_LENGTH);
  ------------------
  |  |  164|      1|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      1|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      1|	int _ret = r; \
  |  |  |  |  155|      1|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      1|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      1|	return _ret; \
  |  |  |  |  163|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2218|     48|	memcpy(buf, recvbuf, apdu.resplen);
 2219|       |
 2220|     48|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 2221|     48|	LOG_TEST_RET(card->ctx, rv, "Card returned error");
  ------------------
  |  |  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: 5, False: 43]
  |  |  |  |  ------------------
  |  |  |  |  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|     48|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 43]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2222|       |
 2223|     43|	LOG_FUNC_RETURN(card->ctx, (int)apdu.resplen);
  ------------------
  |  |  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: 0, False: 43]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"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|     43|	return _ret; \
  |  |  |  |  163|     43|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2224|     43|}
card-oberthur.c:auth_card_ctl:
 1435|    928|{
 1436|    928|	switch (cmd) {
 1437|      0|	case SC_CARDCTL_GET_DEFAULT_KEY:
  ------------------
  |  Branch (1437:2): [True: 0, False: 928]
  ------------------
 1438|      0|		return auth_get_default_key(card,
 1439|      0|				(struct sc_cardctl_default_key *) ptr);
 1440|      0|	case SC_CARDCTL_OBERTHUR_GENERATE_KEY:
  ------------------
  |  Branch (1440:2): [True: 0, False: 928]
  ------------------
 1441|      0|		return auth_generate_key(card, 0,
 1442|      0|				(struct sc_cardctl_oberthur_genkey_info *) ptr);
 1443|      0|	case SC_CARDCTL_OBERTHUR_UPDATE_KEY:
  ------------------
  |  Branch (1443:2): [True: 0, False: 928]
  ------------------
 1444|      0|		return auth_update_key(card,
 1445|      0|				(struct sc_cardctl_oberthur_updatekey_info *) ptr);
 1446|      3|	case SC_CARDCTL_OBERTHUR_CREATE_PIN:
  ------------------
  |  Branch (1446:2): [True: 3, False: 925]
  ------------------
 1447|      3|		return auth_create_reference_data(card,
 1448|      3|				(struct sc_cardctl_oberthur_createpin_info *) ptr);
 1449|     56|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (1449:2): [True: 56, False: 872]
  ------------------
 1450|     56|		return auth_get_serialnr(card, (struct sc_serial_number *)ptr);
 1451|      0|	case SC_CARDCTL_LIFECYCLE_GET:
  ------------------
  |  Branch (1451:2): [True: 0, False: 928]
  ------------------
 1452|    869|	case SC_CARDCTL_LIFECYCLE_SET:
  ------------------
  |  Branch (1452:2): [True: 869, False: 59]
  ------------------
 1453|    869|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    869|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1454|      0|	default:
  ------------------
  |  Branch (1454:2): [True: 0, False: 928]
  ------------------
 1455|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1456|    928|	}
 1457|    928|}
card-oberthur.c:auth_create_reference_data:
 1909|      3|{
 1910|      3|	struct sc_apdu apdu;
 1911|      3|	struct sc_pin_cmd_pin pin_info, puk_info;
 1912|      3|	int rv, len;
 1913|      3|	unsigned char sbuf[SC_MAX_APDU_BUFFER_SIZE];
 1914|       |
 1915|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1916|      3|	sc_log(card->ctx, "PIN reference %i", args->ref);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1917|       |
 1918|      3|	if (args->type != SC_AC_CHV)
  ------------------
  |  |  151|      3|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (1918:6): [True: 0, False: 3]
  ------------------
 1919|      3|		LOG_TEST_RET(card->ctx, SC_ERROR_NOT_SUPPORTED, "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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1920|       |
 1921|      3|	if (args->pin_tries < 1 || !args->pin || !args->pin_len)
  ------------------
  |  Branch (1921:6): [True: 0, False: 3]
  |  Branch (1921:29): [True: 0, False: 3]
  |  Branch (1921:43): [True: 0, False: 3]
  ------------------
 1922|      3|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS, "Invalid PIN options");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1923|       |
 1924|      3|	if (args->ref != OBERTHUR_PIN_REFERENCE_USER && args->ref != OBERTHUR_PIN_REFERENCE_PUK)
  ------------------
  |  |   42|      6|#define OBERTHUR_PIN_REFERENCE_USER	0x81
  ------------------
              	if (args->ref != OBERTHUR_PIN_REFERENCE_USER && args->ref != OBERTHUR_PIN_REFERENCE_PUK)
  ------------------
  |  |   45|      0|#define OBERTHUR_PIN_REFERENCE_PUK	0x84
  ------------------
  |  Branch (1924:6): [True: 0, False: 3]
  |  Branch (1924:50): [True: 0, False: 0]
  ------------------
 1925|      3|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_PIN_REFERENCE, "Invalid 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1926|       |
 1927|      3|	auth_init_pin_info(card, &puk_info, OBERTHUR_AUTH_TYPE_PUK);
  ------------------
  |  |   93|      3|#define OBERTHUR_AUTH_TYPE_PUK		2
  ------------------
 1928|      3|	auth_init_pin_info(card, &pin_info, OBERTHUR_AUTH_TYPE_PIN);
  ------------------
  |  |   92|      3|#define OBERTHUR_AUTH_TYPE_PIN		1
  ------------------
 1929|       |
 1930|      3|	if (args->puk && args->puk_len && (args->puk_len%puk_info.pad_length))
  ------------------
  |  Branch (1930:6): [True: 3, False: 0]
  |  Branch (1930:19): [True: 3, False: 0]
  |  Branch (1930:36): [True: 0, False: 3]
  ------------------
 1931|      3|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS, "Invalid PUK options");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1932|       |
 1933|      3|	len = 0;
 1934|      3|	sc_log(card->ctx, "len %i", len);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1935|      3|	sbuf[len++] = args->pin_tries;
 1936|      3|	sbuf[len++] = pin_info.pad_length;
 1937|      3|	sc_log(card->ctx, "len %i", len);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1938|      3|	memset(sbuf + len, pin_info.pad_char, pin_info.pad_length);
 1939|      3|	memcpy(sbuf + len, args->pin, args->pin_len);
 1940|      3|	len += pin_info.pad_length;
 1941|      3|	sc_log(card->ctx, "len %i", len);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1942|       |
 1943|      3|	if (args->puk && args->puk_len) {
  ------------------
  |  Branch (1943:6): [True: 3, False: 0]
  |  Branch (1943:19): [True: 3, False: 0]
  ------------------
 1944|      3|		sbuf[len++] = args->puk_tries;
 1945|      3|		sbuf[len++] = args->puk_len / puk_info.pad_length;
 1946|      3|		sc_log(card->ctx, "len %i", len);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1947|      3|		memcpy(sbuf + len, args->puk, args->puk_len);
 1948|      3|		len += args->puk_len;
 1949|      3|	}
 1950|       |
 1951|      3|	sc_log(card->ctx, "len %i", len);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1952|      3|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x24, 1, args->ref & ~OBERTHUR_PIN_LOCAL);
  ------------------
  |  |  293|      3|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
              	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x24, 1, args->ref & ~OBERTHUR_PIN_LOCAL);
  ------------------
  |  |   41|      3|#define OBERTHUR_PIN_LOCAL	0x80
  ------------------
 1953|      3|	apdu.data = sbuf;
 1954|      3|	apdu.datalen = len;
 1955|      3|	apdu.lc = len;
 1956|       |
 1957|      3|	rv = sc_transmit_apdu(card, &apdu);
 1958|      3|	sc_mem_clear(sbuf, sizeof(sbuf));
 1959|      3|	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|      3|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      3|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      3|	int _ret = (r); \
  |  |  |  |  168|      3|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      3|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1960|       |
 1961|      2|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1962|       |
 1963|      2|	LOG_FUNC_RETURN(card->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|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|      2|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      2|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      2|	return _ret; \
  |  |  |  |  163|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1964|      2|}
card-oberthur.c:auth_init_pin_info:
 1521|    689|{
 1522|    689|	pin->offset = 0;
 1523|    689|	pin->pad_char   = 0xFF;
 1524|    689|	pin->encoding   = SC_PIN_ENCODING_ASCII;
  ------------------
  |  |  425|    689|#define SC_PIN_ENCODING_ASCII	0
  ------------------
 1525|       |
 1526|    689|	if (type == OBERTHUR_AUTH_TYPE_PIN) {
  ------------------
  |  |   92|    689|#define OBERTHUR_AUTH_TYPE_PIN		1
  ------------------
  |  Branch (1526:6): [True: 686, False: 3]
  ------------------
 1527|    686|		pin->max_length = OBERTHUR_AUTH_MAX_LENGTH_PIN;
  ------------------
  |  |   95|    686|#define OBERTHUR_AUTH_MAX_LENGTH_PIN	64
  ------------------
 1528|    686|		pin->pad_length = OBERTHUR_AUTH_MAX_LENGTH_PIN;
  ------------------
  |  |   95|    686|#define OBERTHUR_AUTH_MAX_LENGTH_PIN	64
  ------------------
 1529|    686|	} else {
 1530|      3|		pin->max_length = OBERTHUR_AUTH_MAX_LENGTH_PUK;
  ------------------
  |  |   96|      3|#define OBERTHUR_AUTH_MAX_LENGTH_PUK	16
  ------------------
 1531|      3|		pin->pad_length = OBERTHUR_AUTH_MAX_LENGTH_PUK;
  ------------------
  |  |   96|      3|#define OBERTHUR_AUTH_MAX_LENGTH_PUK	16
  ------------------
 1532|      3|	}
 1533|    689|}
card-oberthur.c:auth_get_serialnr:
 2249|     56|{
 2250|     56|	if (!serial)
  ------------------
  |  Branch (2250:6): [True: 0, False: 56]
  ------------------
 2251|     56|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2252|       |
 2253|     56|	if (card->serialnr.len==0)
  ------------------
  |  Branch (2253:6): [True: 0, False: 56]
  ------------------
 2254|     56|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2255|       |
 2256|     56|	memcpy(serial, &card->serialnr, sizeof(*serial));
 2257|       |
 2258|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2259|     56|}
card-oberthur.c:auth_process_fci:
  297|  3.79k|{
  298|  3.79k|	unsigned char type;
  299|  3.79k|	const unsigned char *attr;
  300|  3.79k|	size_t attr_len = 0;
  301|       |
  302|  3.79k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  3.79k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.79k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.79k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.79k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.79k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  303|  3.79k|	attr = sc_asn1_find_tag(card->ctx, buf, buflen, 0x82, &attr_len);
  304|  3.79k|	if (!attr || attr_len < 1)
  ------------------
  |  Branch (304:6): [True: 1.55k, False: 2.23k]
  |  Branch (304:15): [True: 241, False: 1.99k]
  ------------------
  305|  3.79k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  306|  1.99k|	type = attr[0];
  307|       |
  308|  1.99k|	attr = sc_asn1_find_tag(card->ctx, buf, buflen, 0x83, &attr_len);
  309|  1.99k|	if (!attr || attr_len < 2)
  ------------------
  |  Branch (309:6): [True: 462, False: 1.53k]
  |  Branch (309:15): [True: 18, False: 1.51k]
  ------------------
  310|  1.99k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|    480|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    480|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    480|	int _ret = r; \
  |  |  |  |  155|    480|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 480, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    480|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    480|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 480, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    480|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    480|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    480|	return _ret; \
  |  |  |  |  163|    480|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  311|  1.51k|	file->id = attr[0]*0x100 + attr[1];
  312|       |
  313|  1.51k|	attr = sc_asn1_find_tag(card->ctx, buf, buflen, type==0x01 ? 0x80 : 0x85, &attr_len);
  ------------------
  |  Branch (313:50): [True: 791, False: 725]
  ------------------
  314|  1.51k|	switch (type) {
  315|    791|	case 0x01:
  ------------------
  |  Branch (315:2): [True: 791, False: 725]
  ------------------
  316|    791|		if (!attr || attr_len < 2)
  ------------------
  |  Branch (316:7): [True: 8, False: 783]
  |  Branch (316:16): [True: 10, False: 773]
  ------------------
  317|    791|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  318|    773|		file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|    773|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  319|    773|		file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|    773|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  320|    773|		file->size = attr[0]*0x100 + attr[1];
  321|    773|		break;
  322|     66|	case 0x04:
  ------------------
  |  Branch (322:2): [True: 66, False: 1.45k]
  ------------------
  323|     66|		if (!attr || attr_len < 1)
  ------------------
  |  Branch (323:7): [True: 18, False: 48]
  |  Branch (323:16): [True: 6, False: 42]
  ------------------
  324|     66|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  325|     42|		file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|     42|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  326|     42|		file->ef_structure = SC_FILE_EF_LINEAR_VARIABLE;
  ------------------
  |  |  224|     42|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  327|     42|		file->size = attr[0];
  328|     42|		attr = sc_asn1_find_tag(card->ctx, buf, buflen, 0x82, &attr_len);
  329|     42|		if (!attr || attr_len < 5)
  ------------------
  |  Branch (329:7): [True: 0, False: 42]
  |  Branch (329:16): [True: 22, False: 20]
  ------------------
  330|     42|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  331|     20|		file->record_length = attr[2]*0x100+attr[3];
  332|     20|		file->record_count = attr[4];
  333|     20|		break;
  334|     25|	case 0x11:
  ------------------
  |  Branch (334:2): [True: 25, False: 1.49k]
  ------------------
  335|     25|		if (!attr || attr_len < 2)
  ------------------
  |  Branch (335:7): [True: 18, False: 7]
  |  Branch (335:16): [True: 1, False: 6]
  ------------------
  336|     25|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|     19|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     19|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     19|	int _ret = r; \
  |  |  |  |  155|     19|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 19, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     19|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     19|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 19, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     19|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     19|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     19|	return _ret; \
  |  |  |  |  163|     19|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  337|      6|		file->type = SC_FILE_TYPE_INTERNAL_EF;
  ------------------
  |  |  215|      6|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  338|      6|		file->ef_structure = SC_CARDCTL_OBERTHUR_KEY_DES;
  339|      6|		file->size = attr[0]*0x100 + attr[1];
  340|      6|		file->size /= 8;
  341|      6|		break;
  342|    119|	case 0x12:
  ------------------
  |  Branch (342:2): [True: 119, False: 1.39k]
  ------------------
  343|    119|		if (!attr || attr_len < 2)
  ------------------
  |  Branch (343:7): [True: 11, False: 108]
  |  Branch (343:16): [True: 20, False: 88]
  ------------------
  344|    119|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|     31|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     31|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     31|	int _ret = r; \
  |  |  |  |  155|     31|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 31, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     31|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     31|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 31, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     31|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     31|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     31|	return _ret; \
  |  |  |  |  163|     31|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  345|     88|		file->type = SC_FILE_TYPE_INTERNAL_EF;
  ------------------
  |  |  215|     88|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  346|     88|		file->ef_structure = SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC;
  347|       |
  348|     88|		file->size = attr[0]*0x100 + attr[1];
  349|     88|		if (file->size==512)
  ------------------
  |  Branch (349:7): [True: 11, False: 77]
  ------------------
  350|     11|			file->size = PUBKEY_512_ASN1_SIZE;
  ------------------
  |  |  100|     11|#define PUBKEY_512_ASN1_SIZE	0x4A
  ------------------
  351|     77|		else if (file->size==1024)
  ------------------
  |  Branch (351:12): [True: 6, False: 71]
  ------------------
  352|      6|			file->size = PUBKEY_1024_ASN1_SIZE;
  ------------------
  |  |  101|      6|#define PUBKEY_1024_ASN1_SIZE	0x8C
  ------------------
  353|     71|		else if (file->size==2048)
  ------------------
  |  Branch (353:12): [True: 0, False: 71]
  ------------------
  354|      0|			file->size = PUBKEY_2048_ASN1_SIZE;
  ------------------
  |  |  102|      0|#define PUBKEY_2048_ASN1_SIZE	0x10E
  ------------------
  355|     71|		else {
  356|     71|			sc_log(card->ctx, "Not supported public key size: %zu", file->size);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  357|     71|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|     71|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     71|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     71|	int _ret = r; \
  |  |  |  |  155|     71|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 71, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     71|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     71|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 71, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     71|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     71|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     71|	return _ret; \
  |  |  |  |  163|     71|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  358|     71|		}
  359|     17|		break;
  360|     47|	case 0x14:
  ------------------
  |  Branch (360:2): [True: 47, False: 1.46k]
  ------------------
  361|     47|		if (!attr || attr_len < 2)
  ------------------
  |  Branch (361:7): [True: 18, False: 29]
  |  Branch (361:16): [True: 18, False: 11]
  ------------------
  362|     47|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  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|     36|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 36, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  363|     11|		file->type = SC_FILE_TYPE_INTERNAL_EF;
  ------------------
  |  |  215|     11|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  364|     11|		file->ef_structure = SC_CARDCTL_OBERTHUR_KEY_RSA_CRT;
  365|     11|		file->size = attr[0]*0x100 + attr[1];
  366|     11|		break;
  367|    438|	case 0x38:
  ------------------
  |  Branch (367:2): [True: 438, False: 1.07k]
  ------------------
  368|    438|		if (!attr || attr_len < 1)
  ------------------
  |  Branch (368:7): [True: 20, False: 418]
  |  Branch (368:16): [True: 18, False: 400]
  ------------------
  369|    438|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  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|     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|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  370|    400|		file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|    400|#define SC_FILE_TYPE_DF			0x04
  ------------------
  371|    400|		file->size = attr[0];
  372|    400|		if (SC_SUCCESS != sc_file_set_type_attr(file,attr,attr_len))
  ------------------
  |  |   28|    400|#define SC_SUCCESS				0
  ------------------
  |  Branch (372:7): [True: 0, False: 400]
  ------------------
  373|    400|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  374|    400|		break;
  375|    400|	default:
  ------------------
  |  Branch (375:2): [True: 30, False: 1.48k]
  ------------------
  376|     30|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|     30|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     30|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     30|	int _ret = r; \
  |  |  |  |  155|     30|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 30, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     30|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     30|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 30, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     30|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     30|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     30|	return _ret; \
  |  |  |  |  163|     30|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  377|  1.51k|	}
  378|       |
  379|  1.22k|	attr = sc_asn1_find_tag(card->ctx, buf, buflen, 0x86, &attr_len);
  380|  1.22k|	if (!attr || attr_len < 8)
  ------------------
  |  Branch (380:6): [True: 623, False: 604]
  |  Branch (380:15): [True: 454, False: 150]
  ------------------
  381|  1.22k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|  1.07k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.07k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.07k|	int _ret = r; \
  |  |  |  |  155|  1.07k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.07k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.07k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  1.07k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.07k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.07k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.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|  1.07k|	return _ret; \
  |  |  |  |  163|  1.07k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  382|       |
  383|    150|	if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|    150|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (383:6): [True: 112, False: 38]
  ------------------
  384|    112|		add_acl_entry(card, file, SC_AC_OP_CREATE, attr[0]);
  ------------------
  |  |  169|    112|#define SC_AC_OP_CREATE			3
  ------------------
  385|    112|		add_acl_entry(card, file, SC_AC_OP_CRYPTO, attr[1]);
  ------------------
  |  |  173|    112|#define SC_AC_OP_CRYPTO			7
  ------------------
  386|    112|		add_acl_entry(card, file, SC_AC_OP_LIST_FILES, attr[2]);
  ------------------
  |  |  172|    112|#define SC_AC_OP_LIST_FILES		6
  ------------------
  387|    112|		add_acl_entry(card, file, SC_AC_OP_DELETE, attr[3]);
  ------------------
  |  |  168|    112|#define SC_AC_OP_DELETE			2
  ------------------
  388|    112|		add_acl_entry(card, file, SC_AC_OP_PIN_DEFINE, attr[4]);
  ------------------
  |  |  183|    112|#define SC_AC_OP_PIN_DEFINE		17
  ------------------
  389|    112|		add_acl_entry(card, file, SC_AC_OP_PIN_CHANGE, attr[5]);
  ------------------
  |  |  184|    112|#define SC_AC_OP_PIN_CHANGE		18
  ------------------
  390|    112|		add_acl_entry(card, file, SC_AC_OP_PIN_RESET, attr[6]);
  ------------------
  |  |  185|    112|#define SC_AC_OP_PIN_RESET		19
  ------------------
  391|    112|		sc_log(card->ctx, "SC_FILE_TYPE_DF:CRYPTO %X", attr[1]);
  ------------------
  |  |   71|    112|#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|    112|	} else if (file->type == SC_FILE_TYPE_INTERNAL_EF) { /* EF */
  ------------------
  |  |  215|     38|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (392:13): [True: 16, False: 22]
  ------------------
  393|     16|		switch (file->ef_structure) {
  ------------------
  |  Branch (393:11): [True: 16, False: 0]
  ------------------
  394|      6|		case SC_CARDCTL_OBERTHUR_KEY_DES:
  ------------------
  |  Branch (394:3): [True: 6, False: 10]
  ------------------
  395|      6|			add_acl_entry(card, file, SC_AC_OP_UPDATE, attr[0]);
  ------------------
  |  |  189|      6|#define SC_AC_OP_UPDATE			23
  ------------------
  396|      6|			add_acl_entry(card, file, SC_AC_OP_PSO_DECRYPT, attr[1]);
  ------------------
  |  |  175|      6|#define SC_AC_OP_PSO_DECRYPT		9
  ------------------
  397|      6|			add_acl_entry(card, file, SC_AC_OP_PSO_ENCRYPT, attr[2]);
  ------------------
  |  |  176|      6|#define SC_AC_OP_PSO_ENCRYPT		10
  ------------------
  398|      6|			add_acl_entry(card, file, SC_AC_OP_PSO_COMPUTE_CHECKSUM, attr[3]);
  ------------------
  |  |  179|      6|#define SC_AC_OP_PSO_COMPUTE_CHECKSUM	13
  ------------------
  399|      6|			add_acl_entry(card, file, SC_AC_OP_PSO_VERIFY_CHECKSUM, attr[4]);
  ------------------
  |  |  180|      6|#define SC_AC_OP_PSO_VERIFY_CHECKSUM	14
  ------------------
  400|      6|			add_acl_entry(card, file, SC_AC_OP_INTERNAL_AUTHENTICATE, attr[5]);
  ------------------
  |  |  181|      6|#define SC_AC_OP_INTERNAL_AUTHENTICATE	15
  ------------------
  401|      6|			add_acl_entry(card, file, SC_AC_OP_EXTERNAL_AUTHENTICATE, attr[6]);
  ------------------
  |  |  182|      6|#define SC_AC_OP_EXTERNAL_AUTHENTICATE	16
  ------------------
  402|      6|			break;
  403|      2|		case SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC:
  ------------------
  |  Branch (403:3): [True: 2, False: 14]
  ------------------
  404|      2|			add_acl_entry(card, file, SC_AC_OP_UPDATE, attr[0]);
  ------------------
  |  |  189|      2|#define SC_AC_OP_UPDATE			23
  ------------------
  405|      2|			add_acl_entry(card, file, SC_AC_OP_PSO_ENCRYPT, attr[2]);
  ------------------
  |  |  176|      2|#define SC_AC_OP_PSO_ENCRYPT		10
  ------------------
  406|      2|			add_acl_entry(card, file, SC_AC_OP_PSO_VERIFY_SIGNATURE, attr[4]);
  ------------------
  |  |  178|      2|#define SC_AC_OP_PSO_VERIFY_SIGNATURE	12
  ------------------
  407|      2|			add_acl_entry(card, file, SC_AC_OP_EXTERNAL_AUTHENTICATE, attr[6]);
  ------------------
  |  |  182|      2|#define SC_AC_OP_EXTERNAL_AUTHENTICATE	16
  ------------------
  408|      2|			break;
  409|      8|		case SC_CARDCTL_OBERTHUR_KEY_RSA_CRT:
  ------------------
  |  Branch (409:3): [True: 8, False: 8]
  ------------------
  410|      8|			add_acl_entry(card, file, SC_AC_OP_UPDATE, attr[0]);
  ------------------
  |  |  189|      8|#define SC_AC_OP_UPDATE			23
  ------------------
  411|      8|			add_acl_entry(card, file, SC_AC_OP_PSO_DECRYPT, attr[1]);
  ------------------
  |  |  175|      8|#define SC_AC_OP_PSO_DECRYPT		9
  ------------------
  412|      8|			add_acl_entry(card, file, SC_AC_OP_PSO_COMPUTE_SIGNATURE, attr[3]);
  ------------------
  |  |  177|      8|#define SC_AC_OP_PSO_COMPUTE_SIGNATURE	11
  ------------------
  413|      8|			add_acl_entry(card, file, SC_AC_OP_INTERNAL_AUTHENTICATE, attr[5]);
  ------------------
  |  |  181|      8|#define SC_AC_OP_INTERNAL_AUTHENTICATE	15
  ------------------
  414|      8|			break;
  415|     16|		}
  416|     22|	} else {
  417|     22|		switch (file->ef_structure) {
  ------------------
  |  Branch (417:11): [True: 22, False: 0]
  ------------------
  418|     22|		case SC_FILE_EF_TRANSPARENT:
  ------------------
  |  |  221|     22|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (418:3): [True: 22, False: 0]
  ------------------
  419|     22|			add_acl_entry(card, file, SC_AC_OP_WRITE, attr[0]);
  ------------------
  |  |  190|     22|#define SC_AC_OP_WRITE			24
  ------------------
  420|     22|			add_acl_entry(card, file, SC_AC_OP_UPDATE, attr[1]);
  ------------------
  |  |  189|     22|#define SC_AC_OP_UPDATE			23
  ------------------
  421|     22|			add_acl_entry(card, file, SC_AC_OP_READ, attr[2]);
  ------------------
  |  |  188|     22|#define SC_AC_OP_READ			22
  ------------------
  422|     22|			add_acl_entry(card, file, SC_AC_OP_ERASE, attr[3]);
  ------------------
  |  |  202|     22|#define SC_AC_OP_ERASE			SC_AC_OP_DELETE
  |  |  ------------------
  |  |  |  |  168|     22|#define SC_AC_OP_DELETE			2
  |  |  ------------------
  ------------------
  423|     22|			break;
  424|      0|		case SC_FILE_EF_LINEAR_VARIABLE:
  ------------------
  |  |  224|      0|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  |  Branch (424:3): [True: 0, False: 22]
  ------------------
  425|      0|			add_acl_entry(card, file, SC_AC_OP_WRITE, attr[0]);
  ------------------
  |  |  190|      0|#define SC_AC_OP_WRITE			24
  ------------------
  426|      0|			add_acl_entry(card, file, SC_AC_OP_UPDATE, attr[1]);
  ------------------
  |  |  189|      0|#define SC_AC_OP_UPDATE			23
  ------------------
  427|      0|			add_acl_entry(card, file, SC_AC_OP_READ, attr[2]);
  ------------------
  |  |  188|      0|#define SC_AC_OP_READ			22
  ------------------
  428|      0|			add_acl_entry(card, file, SC_AC_OP_ERASE, attr[3]);
  ------------------
  |  |  202|      0|#define SC_AC_OP_ERASE			SC_AC_OP_DELETE
  |  |  ------------------
  |  |  |  |  168|      0|#define SC_AC_OP_DELETE			2
  |  |  ------------------
  ------------------
  429|      0|			break;
  430|     22|		}
  431|     22|	}
  432|       |
  433|    150|	file->status = SC_FILE_STATUS_ACTIVATED;
  ------------------
  |  |  236|    150|#define SC_FILE_STATUS_ACTIVATED	0x00 /* ISO7816-4: Operational state (activated)   (5, 7) */
  ------------------
  434|    150|	file->magic = SC_FILE_MAGIC;
  ------------------
  |  |   57|    150|#define SC_FILE_MAGIC			0x14426950
  ------------------
  435|       |
  436|    150|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    150|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    150|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    150|	int _ret = r; \
  |  |  |  |  155|    150|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 150, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    150|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 150]
  |  |  |  |  ------------------
  |  |  |  |  157|    150|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    150|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    150|	return _ret; \
  |  |  |  |  163|    150|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  437|    150|}
card-oberthur.c:add_acl_entry:
  260|    954|{
  261|    954|	if ((acl_byte & 0xE0) == 0x60) {
  ------------------
  |  Branch (261:6): [True: 116, False: 838]
  ------------------
  262|    116|		sc_log(card->ctx, "called; op 0x%X; SC_AC_PRO; ref 0x%X", op, acl_byte);
  ------------------
  |  |   71|    116|#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|    116|		sc_file_add_acl_entry(file, op, SC_AC_PRO, acl_byte);
  ------------------
  |  |  153|    116|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  264|    116|		return;
  265|    116|	}
  266|       |
  267|    838|	switch (acl_byte) {
  268|    108|	case 0x00:
  ------------------
  |  Branch (268:2): [True: 108, False: 730]
  ------------------
  269|    108|		sc_file_add_acl_entry(file, op, SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  150|    108|#define SC_AC_NONE			0x00000000
  ------------------
              		sc_file_add_acl_entry(file, op, SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|    108|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  270|    108|		break;
  271|       |	/* User and OneTime PINs are locals */
  272|     11|	case 0x21:
  ------------------
  |  Branch (272:2): [True: 11, False: 827]
  ------------------
  273|     26|	case 0x22:
  ------------------
  |  Branch (273:2): [True: 15, False: 823]
  ------------------
  274|     26|		sc_file_add_acl_entry(file, op, SC_AC_CHV, (acl_byte & 0x0F) | OBERTHUR_PIN_LOCAL);
  ------------------
  |  |  151|     26|#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|     26|#define OBERTHUR_PIN_LOCAL	0x80
  ------------------
  275|     26|		break;
  276|       |	/* Local SOPIN is only for the unblocking. */
  277|     22|	case 0x24:
  ------------------
  |  Branch (277:2): [True: 22, False: 816]
  ------------------
  278|     70|	case 0x25:
  ------------------
  |  Branch (278:2): [True: 48, False: 790]
  ------------------
  279|     70|		if (op == SC_AC_OP_PIN_RESET)
  ------------------
  |  |  185|     70|#define SC_AC_OP_PIN_RESET		19
  ------------------
  |  Branch (279:7): [True: 34, False: 36]
  ------------------
  280|     34|			sc_file_add_acl_entry(file, op, SC_AC_CHV, 0x84);
  ------------------
  |  |  151|     34|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  281|     36|		else
  282|     36|			sc_file_add_acl_entry(file, op, SC_AC_CHV, 0x04);
  ------------------
  |  |  151|     36|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  283|     70|		break;
  284|     36|	case 0xFF:
  ------------------
  |  Branch (284:2): [True: 36, False: 802]
  ------------------
  285|     36|		sc_file_add_acl_entry(file, op, SC_AC_NEVER, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  163|     36|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
              		sc_file_add_acl_entry(file, op, SC_AC_NEVER, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|     36|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  286|     36|		break;
  287|    598|	default:
  ------------------
  |  Branch (287:2): [True: 598, False: 240]
  ------------------
  288|    598|		sc_file_add_acl_entry(file, op, SC_AC_UNKNOWN, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  162|    598|#define SC_AC_UNKNOWN			0xFFFFFFFE
  ------------------
              		sc_file_add_acl_entry(file, op, SC_AC_UNKNOWN, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|    598|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  289|    598|		break;
  290|    838|	}
  291|    838|}
card-oberthur.c:auth_pin_cmd:
 1875|    739|{
 1876|    739|	int rv = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|    739|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1877|       |
 1878|    739|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    739|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    739|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    739|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    739|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 739]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1879|    739|	if (data->pin_type != SC_AC_CHV)
  ------------------
  |  |  151|    739|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (1879:6): [True: 0, False: 739]
  ------------------
 1880|    739|		LOG_TEST_RET(card->ctx, SC_ERROR_NOT_SUPPORTED, "auth_pin_cmd() unsupported PIN type");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1881|       |
 1882|    739|	sc_log(card->ctx, "PIN CMD:%i; reference:%i; pin1:%p/%zu, pin2:%p/%zu", data->cmd,
  ------------------
  |  |   71|    739|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1883|    739|			data->pin_reference, data->pin1.data, data->pin1.len,
 1884|    739|			data->pin2.data, data->pin2.len);
 1885|    739|	switch (data->cmd) {
 1886|    683|	case SC_PIN_CMD_VERIFY:
  ------------------
  |  |  415|    683|#define SC_PIN_CMD_VERIFY	0
  ------------------
  |  Branch (1886:2): [True: 683, False: 56]
  ------------------
 1887|    683|		rv = auth_pin_verify(card, SC_AC_CHV, data);
  ------------------
  |  |  151|    683|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1888|    683|		LOG_TEST_RET(card->ctx, rv, "CMD 'PIN VERIFY' failed");
  ------------------
  |  |  174|    683|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    683|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    683|	int _ret = (r); \
  |  |  |  |  168|    683|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 152, False: 531]
  |  |  |  |  ------------------
  |  |  |  |  169|    152|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    152|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    152|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    152|		return _ret; \
  |  |  |  |  172|    152|	} \
  |  |  |  |  173|    683|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 531]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1889|    531|		break;
 1890|    531|	case SC_PIN_CMD_CHANGE:
  ------------------
  |  |  416|      0|#define SC_PIN_CMD_CHANGE	1
  ------------------
  |  Branch (1890:2): [True: 0, False: 739]
  ------------------
 1891|      0|		rv = auth_pin_change(card, SC_AC_CHV, data);
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1892|      0|		LOG_TEST_RET(card->ctx, rv, "CMD 'PIN VERIFY' failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1893|      0|		break;
 1894|      0|	case SC_PIN_CMD_UNBLOCK:
  ------------------
  |  |  417|      0|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (1894:2): [True: 0, False: 739]
  ------------------
 1895|      0|		rv = auth_pin_reset(card, SC_AC_CHV, data);
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1896|      0|		LOG_TEST_RET(card->ctx, rv, "CMD 'PIN VERIFY' failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1897|      0|		break;
 1898|     56|	default:
  ------------------
  |  Branch (1898:2): [True: 56, False: 683]
  ------------------
 1899|     56|		LOG_TEST_RET(card->ctx, SC_ERROR_NOT_SUPPORTED, "Unsupported PIN operation");
  ------------------
  |  |  174|     56|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     56|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     56|	int _ret = (r); \
  |  |  |  |  168|     56|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 56, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|     56|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1900|    739|	}
 1901|       |
 1902|    531|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  164|    531|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    531|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    531|	int _ret = r; \
  |  |  |  |  155|    531|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 531, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    531|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 531]
  |  |  |  |  ------------------
  |  |  |  |  157|    531|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    531|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    531|	return _ret; \
  |  |  |  |  163|    531|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1903|    531|}
card-oberthur.c:auth_pin_verify:
 1595|    683|{
 1596|    683|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 1597|    683|	int rv;
 1598|       |
 1599|    683|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1600|       |
 1601|    683|	if (type != SC_AC_CHV)
  ------------------
  |  |  151|    683|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (1601:6): [True: 0, False: 683]
  ------------------
 1602|    683|		LOG_TEST_RET(card->ctx, SC_ERROR_NOT_SUPPORTED, "PIN type other then SC_AC_CHV is not supported");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1603|       |
 1604|    683|	data->flags |= SC_PIN_CMD_NEED_PADDING;
  ------------------
  |  |  422|    683|#define SC_PIN_CMD_NEED_PADDING		0x0002
  ------------------
 1605|       |
 1606|    683|	auth_init_pin_info(card, &data->pin1, OBERTHUR_AUTH_TYPE_PIN);
  ------------------
  |  |   92|    683|#define OBERTHUR_AUTH_TYPE_PIN		1
  ------------------
 1607|       |
 1608|       |	/* User PIN is always local. */
 1609|    683|	if (data->pin_reference == OBERTHUR_PIN_REFERENCE_USER
  ------------------
  |  |   42|  1.36k|#define OBERTHUR_PIN_REFERENCE_USER	0x81
  ------------------
  |  Branch (1609:6): [True: 282, False: 401]
  ------------------
 1610|    401|			|| data->pin_reference == OBERTHUR_PIN_REFERENCE_ONETIME)
  ------------------
  |  |   43|    401|#define OBERTHUR_PIN_REFERENCE_ONETIME	0x82
  ------------------
  |  Branch (1610:7): [True: 0, False: 401]
  ------------------
 1611|    282|		data->pin_reference  |= OBERTHUR_PIN_LOCAL;
  ------------------
  |  |   41|    282|#define OBERTHUR_PIN_LOCAL	0x80
  ------------------
 1612|       |
 1613|    683|        rv = auth_pin_is_verified(card, data->pin_reference, &data->pin1.tries_left);
 1614|    683|    	sc_log(card->ctx, "auth_pin_is_verified returned rv %i", rv);
  ------------------
  |  |   71|    683|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1615|       |
 1616|       |	/* Return if only PIN status has been asked. */
 1617|    683|	if (data->pin1.data && !data->pin1.len)
  ------------------
  |  Branch (1617:6): [True: 683, False: 0]
  |  Branch (1617:25): [True: 683, False: 0]
  ------------------
 1618|    683|		LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  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|    152|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 152, False: 531]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1619|       |
 1620|       |	/* Return SUCCESS without verifying if
 1621|       |	 * PIN has been already verified and PIN pad has to be used. */
 1622|      0|	if (!rv && !data->pin1.data && !data->pin1.len)
  ------------------
  |  Branch (1622:6): [True: 0, False: 0]
  |  Branch (1622:13): [True: 0, False: 0]
  |  Branch (1622:33): [True: 0, False: 0]
  ------------------
 1623|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1624|       |
 1625|      0|	if (!data->pin1.data && !data->pin1.len)
  ------------------
  |  Branch (1625:6): [True: 0, False: 0]
  |  Branch (1625:26): [True: 0, False: 0]
  ------------------
 1626|      0|		rv = auth_pin_verify_pinpad(card, data->pin_reference, &data->pin1.tries_left);
 1627|      0|	else
 1628|      0|		rv = iso_drv->ops->pin_cmd(card, data);
 1629|       |
 1630|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1631|      0|}
card-oberthur.c:auth_pin_is_verified:
 1636|    683|{
 1637|    683|	struct sc_apdu apdu;
 1638|    683|	int rv;
 1639|       |
 1640|    683|	sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x20, 0, pin_reference);
  ------------------
  |  |  291|    683|#define SC_APDU_CASE_1			0x01
  ------------------
 1641|       |
 1642|    683|	rv = sc_transmit_apdu(card, &apdu);
 1643|    683|	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|    683|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    683|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    683|	int _ret = (r); \
  |  |  |  |  168|    683|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 680]
  |  |  |  |  ------------------
  |  |  |  |  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|    683|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 680]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1644|       |
 1645|    680|	if (tries_left && apdu.sw1 == 0x63 && (apdu.sw2 & 0xF0) == 0xC0)
  ------------------
  |  Branch (1645:6): [True: 680, False: 0]
  |  Branch (1645:20): [True: 22, False: 658]
  |  Branch (1645:40): [True: 17, False: 5]
  ------------------
 1646|     17|		*tries_left = apdu.sw2 & 0x0F;
 1647|       |
 1648|       |	/* Replace 'no tries left' with 'auth method blocked' */
 1649|    680|	if (apdu.sw1 == 0x63 && apdu.sw2 == 0xC0) {
  ------------------
  |  Branch (1649:6): [True: 22, False: 658]
  |  Branch (1649:26): [True: 3, False: 19]
  ------------------
 1650|      3|		apdu.sw1 = 0x69;
 1651|      3|		apdu.sw2 = 0x83;
 1652|      3|	}
 1653|       |
 1654|    680|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1655|       |
 1656|    680|	return rv;
 1657|    683|}
card-oberthur.c:auth_check_sw:
 2272|  19.2k|{
 2273|  19.2k|	int ii;
 2274|       |
 2275|  38.3k|	for (ii = 0; auth_warnings[ii].SWs; ii++) {
  ------------------
  |  Branch (2275:15): [True: 19.2k, False: 19.0k]
  ------------------
 2276|  19.2k|		if (auth_warnings[ii].SWs == ((sw1 << 8) | sw2)) {
  ------------------
  |  Branch (2276:7): [True: 216, False: 19.0k]
  ------------------
 2277|    216|			sc_log(card->ctx, "%s", auth_warnings[ii].errorstr);
  ------------------
  |  |   71|    216|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2278|    216|			return auth_warnings[ii].errorno;
 2279|    216|		}
 2280|  19.2k|	}
 2281|       |
 2282|  19.0k|	return iso_ops->check_sw(card, sw1, sw2);
 2283|  19.2k|}

populate_blobs_to_mf:
  381|    883|{
  382|    883|	pgp_do_info_t	*info;
  383|       |
  384|    883|	if (priv->mf == NULL)
  ------------------
  |  Branch (384:6): [True: 0, False: 883]
  ------------------
  385|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  386|       |
  387|  56.8k|	for (info = priv->pgp_objects; (info != NULL) && (info->id > 0); info++) {
  ------------------
  |  Branch (387:33): [True: 56.8k, False: 0]
  |  Branch (387:51): [True: 55.9k, False: 883]
  ------------------
  388|  55.9k|		if (((info->access & READ_MASK) != READ_NEVER) && (info->get_fn != NULL)) {
  ------------------
  |  Branch (388:7): [True: 41.5k, False: 14.4k]
  |  Branch (388:53): [True: 17.7k, False: 23.8k]
  ------------------
  389|  17.7k|			pgp_blob_t *child = NULL;
  390|  17.7k|			sc_file_t *file = sc_file_new();
  391|       |
  392|  17.7k|			child = pgp_new_blob(card, priv->mf, info->id, file);
  393|       |
  394|       |			/* catch out of memory condition */
  395|  17.7k|			if (child == NULL) {
  ------------------
  |  Branch (395:8): [True: 0, False: 17.7k]
  ------------------
  396|      0|				sc_file_free(file);
  397|      0|				LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  398|      0|			}
  399|  17.7k|		}
  400|  55.9k|	}
  401|    883|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    883|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    883|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    883|	int _ret = r; \
  |  |  |  |  155|    883|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 883, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    883|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 883]
  |  |  |  |  ------------------
  |  |  |  |  157|    883|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    883|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    883|	return _ret; \
  |  |  |  |  163|    883|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  402|    883|}
_pgp_handle_curve25519:
  721|  2.29k|{
  722|  2.29k|	if (!card || !key_info)
  ------------------
  |  Branch (722:6): [True: 0, False: 2.29k]
  |  Branch (722:15): [True: 0, False: 2.29k]
  ------------------
  723|      0|		return 0;
  724|  2.29k|	if (!sc_compare_oid(&key_info->u.ec.oid, &curve25519_oid) &&
  ------------------
  |  Branch (724:6): [True: 2.29k, False: 0]
  ------------------
  725|  2.29k|			!sc_compare_oid(&key_info->u.ec.oid, &X25519_oid))
  ------------------
  |  Branch (725:4): [True: 694, False: 1.60k]
  ------------------
  726|    694|		return 0;
  727|       |
  728|       |	/* CKM_XEDDSA supports both Sign and Derive, but
  729|       |	* OpenPGP card supports only derivation using these
  730|       |	* keys as far as I know */
  731|  1.60k|	_sc_card_add_xeddsa_alg(card, key_info->u.ec.key_length,
  732|  1.60k|			SC_ALGORITHM_ECDH_CDH_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN, 0, &key_info->u.ec.oid);
  ------------------
  |  |  173|  1.60k|#define SC_ALGORITHM_ECDH_CDH_RAW	0x00200000
  ------------------
              			SC_ALGORITHM_ECDH_CDH_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN, 0, &key_info->u.ec.oid);
  ------------------
  |  |   93|  1.60k|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  733|  1.60k|	sc_log(card->ctx, "DO %uX: Added XEDDSA algorithm (%d), mod_len = %zu",
  ------------------
  |  |   71|  1.60k|#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)
  |  |  ------------------
  |  |  |  |  734|  1.60k|	    do_num, SC_ALGORITHM_XEDDSA, key_info->u.ec.key_length);
  |  |  |  |  ------------------
  |  |  |  |  |  |   73|  1.60k|#define SC_ALGORITHM_XEDDSA		5
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  734|  1.60k|	    do_num, SC_ALGORITHM_XEDDSA, key_info->u.ec.key_length);
  735|  1.60k|	return 1;
  736|  2.29k|}
_pgp_add_algo:
  740|  4.64k|{
  741|  4.64k|	unsigned long flags = 0, ext_flags = 0;
  742|       |
  743|  4.64k|	if (!card || !key_info)
  ------------------
  |  Branch (743:6): [True: 0, False: 4.64k]
  |  Branch (743:15): [True: 0, False: 4.64k]
  ------------------
  744|      0|		return 0;
  745|       |
  746|       |	/* [RFC 4880], [draft-ietf-openpgp-crypto-refresh] */
  747|  4.64k|	switch (key_info->algorithm) {
  748|  1.09k|	case SC_OPENPGP_KEYALGO_RSA:
  ------------------
  |  |  870|  1.09k|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  |  Branch (748:2): [True: 1.09k, False: 3.55k]
  ------------------
  749|       |		/* OpenPGP card spec 1.1 & 2.x, section 7.2.9 & 7.2.10 /
  750|       |		 * v3.x section 7.2.11 & 7.2.12 */
  751|  1.09k|		flags = SC_ALGORITHM_RSA_PAD_PKCS1 |
  ------------------
  |  |  111|  1.09k|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|  1.09k|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|  1.09k|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  752|  1.09k|			SC_ALGORITHM_RSA_HASH_NONE |
  ------------------
  |  |  133|  1.09k|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  753|  1.09k|			SC_ALGORITHM_ONBOARD_KEY_GEN;	/* key gen on card */
  ------------------
  |  |   93|  1.09k|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  754|       |
  755|  1.09k|		_sc_card_add_rsa_alg(card, key_info->u.rsa.modulus_len, flags, 0);
  756|  1.09k|		sc_log(card->ctx, "DO %uX: Added RSA algorithm, mod_len = %zu",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  757|  1.09k|				do_num, key_info->u.rsa.modulus_len);
  758|  1.09k|		break;
  759|    745|	case SC_OPENPGP_KEYALGO_ECDH:
  ------------------
  |  |  871|    745|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (759:2): [True: 745, False: 3.90k]
  ------------------
  760|       |		/* The montgomery curve (curve25519) needs to go through
  761|       |		 * different paths, otherwise we handle it as a normal EC key */
  762|    745|		if (_pgp_handle_curve25519(card, key_info, do_num))
  ------------------
  |  Branch (762:7): [True: 274, False: 471]
  ------------------
  763|    274|			break;
  764|       |		/* fall through */
  765|  1.72k|	case SC_OPENPGP_KEYALGO_ECDSA:
  ------------------
  |  |  872|  1.72k|#define	SC_OPENPGP_KEYALGO_ECDSA	0x13
  ------------------
  |  Branch (765:2): [True: 1.25k, False: 3.39k]
  ------------------
  766|       |		/* v3.0+: ECC [RFC 4880 & 6637] */
  767|       |
  768|       |		/* Allow curve to be used by both ECDH and ECDSA.
  769|       |		 * pgp_init set these flags the same way */
  770|  1.72k|		flags = SC_ALGORITHM_ECDH_CDH_RAW;
  ------------------
  |  |  173|  1.72k|#define SC_ALGORITHM_ECDH_CDH_RAW	0x00200000
  ------------------
  771|  1.72k|		flags |= SC_ALGORITHM_ECDSA_RAW;
  ------------------
  |  |  174|  1.72k|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
  772|  1.72k|		flags |= SC_ALGORITHM_ECDSA_HASH_NONE;
  ------------------
  |  |  175|  1.72k|#define SC_ALGORITHM_ECDSA_HASH_NONE		SC_ALGORITHM_RSA_HASH_NONE
  |  |  ------------------
  |  |  |  |  133|  1.72k|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  ------------------
  773|  1.72k|		flags |= SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|  1.72k|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  774|  1.72k|		ext_flags = SC_ALGORITHM_EXT_EC_NAMEDCURVE;
  ------------------
  |  |  201|  1.72k|#define SC_ALGORITHM_EXT_EC_NAMEDCURVE   0x00000008
  ------------------
  775|       |
  776|  1.72k|		_sc_card_add_ec_alg(card, key_info->u.ec.key_length, flags, ext_flags,
  777|  1.72k|			&key_info->u.ec.oid);
  778|  1.72k|		sc_log(card->ctx, "DO %uX: Added EC algorithm (%d), mod_len = %zu" ,
  ------------------
  |  |   71|  1.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__
  |  |  ------------------
  ------------------
  779|  1.72k|			do_num, key_info->algorithm, key_info->u.ec.key_length);
  780|  1.72k|		break;
  781|  1.55k|	case SC_OPENPGP_KEYALGO_EDDSA:
  ------------------
  |  |  873|  1.55k|#define	SC_OPENPGP_KEYALGO_EDDSA	0x16
  ------------------
  |  Branch (781:2): [True: 1.55k, False: 3.09k]
  ------------------
  782|       |		/* EdDSA from draft-ietf-openpgp-rfc4880bis-08 */
  783|       |		/* Handle Yubikey bug, that in DO FA curve25519 has EDDSA algo */
  784|  1.55k|		if (_pgp_handle_curve25519(card, key_info, do_num))
  ------------------
  |  Branch (784:7): [True: 1.32k, False: 223]
  ------------------
  785|  1.32k|			break;
  786|    223|		_sc_card_add_eddsa_alg(card, key_info->u.ec.key_length,
  787|    223|				SC_ALGORITHM_EDDSA_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN, 0, &key_info->u.ec.oid);
  ------------------
  |  |  188|    223|#define SC_ALGORITHM_EDDSA_RAW		0x00400000
  ------------------
              				SC_ALGORITHM_EDDSA_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN, 0, &key_info->u.ec.oid);
  ------------------
  |  |   93|    223|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  788|       |
  789|    223|		sc_log(card->ctx, "DO %uX: Added EDDSA algorithm (%d), mod_len = %zu" ,
  ------------------
  |  |   71|    223|#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|    223|			do_num, key_info->algorithm, key_info->u.ec.key_length);
  791|    223|		break;
  792|      0|	default:
  ------------------
  |  Branch (792:2): [True: 0, False: 4.64k]
  ------------------
  793|      0|		sc_log(card->ctx, "DO %uX: Unknown algorithm ID (%d)" ,
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  794|      0|			do_num, key_info->algorithm);
  795|       |		/* return "false" if we do not understand algo */
  796|      0|		return 0;
  797|  4.64k|	}
  798|       |	/* return true */
  799|  4.64k|	return 1;
  800|  4.64k|}
sc_get_openpgp_driver:
 4209|  16.3k|{
 4210|  16.3k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 4211|       |
 4212|  16.3k|	iso_ops = iso_drv->ops;
 4213|       |
 4214|  16.3k|	pgp_ops = *iso_ops;
 4215|  16.3k|	pgp_ops.match_card	= pgp_match_card;
 4216|  16.3k|	pgp_ops.init		= pgp_init;
 4217|  16.3k|	pgp_ops.finish		= pgp_finish;
 4218|  16.3k|	pgp_ops.select_file	= pgp_select_file;
 4219|  16.3k|	pgp_ops.list_files	= pgp_list_files;
 4220|  16.3k|	pgp_ops.get_challenge	= pgp_get_challenge;
 4221|  16.3k|	pgp_ops.read_binary	= pgp_read_binary;
 4222|  16.3k|	pgp_ops.write_binary	= NULL;
 4223|  16.3k|	pgp_ops.pin_cmd		= pgp_pin_cmd;
 4224|  16.3k|	pgp_ops.logout		= pgp_logout;
 4225|  16.3k|	pgp_ops.get_data	= pgp_get_data;
 4226|  16.3k|	pgp_ops.put_data	= pgp_put_data;
 4227|  16.3k|	pgp_ops.set_security_env= pgp_set_security_env;
 4228|  16.3k|	pgp_ops.compute_signature= pgp_compute_signature;
 4229|  16.3k|	pgp_ops.decipher	= pgp_decipher;
 4230|  16.3k|	pgp_ops.card_ctl	= pgp_card_ctl;
 4231|  16.3k|	pgp_ops.delete_file	= pgp_delete_file;
 4232|  16.3k|	pgp_ops.update_binary	= pgp_update_binary;
 4233|  16.3k|	pgp_ops.card_reader_lock_obtained = pgp_card_reader_lock_obtained;
 4234|       |
 4235|  16.3k|	return &pgp_drv;
 4236|  16.3k|}
card-openpgp.c:pgp_new_blob:
 1240|  60.3k|{
 1241|  60.3k|	pgp_blob_t *blob = NULL;
 1242|       |
 1243|  60.3k|	if (file == NULL)
  ------------------
  |  Branch (1243:6): [True: 0, False: 60.3k]
  ------------------
 1244|      0|		return NULL;
 1245|       |
 1246|  60.3k|	if ((blob = calloc(1, sizeof(pgp_blob_t))) != NULL) {
  ------------------
  |  Branch (1246:6): [True: 60.3k, False: 0]
  ------------------
 1247|  60.3k|		struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|  60.3k|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 1248|  60.3k|		pgp_do_info_t *info;
 1249|       |
 1250|  60.3k|		blob->file = file;
 1251|       |
 1252|  60.3k|		blob->file->type         = SC_FILE_TYPE_WORKING_EF; /* default */
  ------------------
  |  |  216|  60.3k|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
 1253|  60.3k|		blob->file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|  60.3k|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
 1254|  60.3k|		blob->file->id           = file_id;
 1255|       |
 1256|  60.3k|		blob->id     = file_id;
 1257|  60.3k|		blob->parent = parent;
 1258|       |
 1259|  60.3k|		if (parent != NULL) {
  ------------------
  |  Branch (1259:7): [True: 59.4k, False: 883]
  ------------------
 1260|  59.4k|			pgp_blob_t **p;
 1261|       |
 1262|       |			/* set file's path = parent's path + file's id */
 1263|  59.4k|			blob->file->path = parent->file->path;
 1264|  59.4k|			sc_append_file_id(&blob->file->path, file_id);
 1265|       |
 1266|       |			/* append blob to list of parent's children */
 1267|  6.06M|			for (p = &parent->files; *p != NULL; p = &(*p)->next)
  ------------------
  |  Branch (1267:29): [True: 6.00M, False: 59.4k]
  ------------------
 1268|  6.00M|				;
 1269|  59.4k|			*p = blob;
 1270|  59.4k|		}
 1271|    883|		else {
 1272|    883|			char path[10] = "0000";	/* long enough */
 1273|       |
 1274|       |			/* no parent: set file's path = file's id */
 1275|    883|			if (4 != snprintf(path, sizeof(path), "%04X", file_id & 0xFFFF)) {
  ------------------
  |  Branch (1275:8): [True: 0, False: 883]
  ------------------
 1276|      0|				free(blob);
 1277|      0|				return NULL;
 1278|      0|			}
 1279|       |
 1280|    883|			sc_format_path(path, &blob->file->path);
 1281|    883|		}
 1282|       |
 1283|       |		/* find matching DO info: set file type depending on it */
 1284|  2.78M|		for (info = priv->pgp_objects; (info != NULL) && (info->id > 0); info++) {
  ------------------
  |  Branch (1284:34): [True: 2.78M, False: 0]
  |  Branch (1284:52): [True: 2.76M, False: 20.6k]
  ------------------
 1285|  2.76M|			if (info->id == file_id) {
  ------------------
  |  Branch (1285:8): [True: 39.7k, False: 2.72M]
  ------------------
 1286|  39.7k|				blob->info = info;
 1287|  39.7k|				blob->file->type = blob->info->type;
 1288|  39.7k|				pgp_attach_acl(card, blob->file, info);
 1289|  39.7k|				break;
 1290|  39.7k|			}
 1291|  2.76M|		}
 1292|  60.3k|	}
 1293|       |
 1294|  60.3k|	return blob;
 1295|  60.3k|}
card-openpgp.c:pgp_attach_acl:
 1172|  39.7k|{
 1173|  39.7k|	unsigned int method = SC_AC_NONE;
  ------------------
  |  |  150|  39.7k|#define SC_AC_NONE			0x00000000
  ------------------
 1174|  39.7k|	unsigned long key_ref = SC_AC_KEY_REF_NONE;
  ------------------
  |  |  204|  39.7k|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
 1175|       |
 1176|       |	/* Write access */
 1177|  39.7k|	switch (info->access & WRITE_MASK) {
  ------------------
  |  Branch (1177:10): [True: 39.7k, False: 0]
  ------------------
 1178|  11.2k|	case WRITE_NEVER:
  ------------------
  |  Branch (1178:2): [True: 11.2k, False: 28.4k]
  ------------------
 1179|  11.2k|		method = SC_AC_NEVER;
  ------------------
  |  |  163|  11.2k|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
 1180|  11.2k|		break;
 1181|      0|	case WRITE_PIN1:
  ------------------
  |  Branch (1181:2): [True: 0, False: 39.7k]
  ------------------
 1182|      0|		method = SC_AC_CHV;
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1183|      0|		key_ref = 0x01;
 1184|      0|		break;
 1185|  1.76k|	case WRITE_PIN2:
  ------------------
  |  Branch (1185:2): [True: 1.76k, False: 37.9k]
  ------------------
 1186|  1.76k|		method = SC_AC_CHV;
  ------------------
  |  |  151|  1.76k|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1187|  1.76k|		key_ref = 0x02;
 1188|  1.76k|		break;
 1189|  26.6k|	case WRITE_PIN3:
  ------------------
  |  Branch (1189:2): [True: 26.6k, False: 13.0k]
  ------------------
 1190|  26.6k|		method = SC_AC_CHV;
  ------------------
  |  |  151|  26.6k|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1191|  26.6k|		key_ref = 0x03;
 1192|  26.6k|		break;
 1193|  39.7k|	}
 1194|       |
 1195|  39.7k|	if (method != SC_AC_NONE || key_ref != SC_AC_KEY_REF_NONE) {
  ------------------
  |  |  150|  79.4k|#define SC_AC_NONE			0x00000000
  ------------------
              	if (method != SC_AC_NONE || key_ref != SC_AC_KEY_REF_NONE) {
  ------------------
  |  |  204|      0|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  |  Branch (1195:6): [True: 39.7k, False: 0]
  |  Branch (1195:30): [True: 0, False: 0]
  ------------------
 1196|  39.7k|		sc_file_add_acl_entry(file, SC_AC_OP_WRITE, method, key_ref);
  ------------------
  |  |  190|  39.7k|#define SC_AC_OP_WRITE			24
  ------------------
 1197|  39.7k|		sc_file_add_acl_entry(file, SC_AC_OP_UPDATE, method, key_ref);
  ------------------
  |  |  189|  39.7k|#define SC_AC_OP_UPDATE			23
  ------------------
 1198|  39.7k|		sc_file_add_acl_entry(file, SC_AC_OP_DELETE, method, key_ref);
  ------------------
  |  |  168|  39.7k|#define SC_AC_OP_DELETE			2
  ------------------
 1199|  39.7k|		sc_file_add_acl_entry(file, SC_AC_OP_CREATE, method, key_ref);
  ------------------
  |  |  169|  39.7k|#define SC_AC_OP_CREATE			3
  ------------------
 1200|  39.7k|	}
 1201|      0|	else {
 1202|       |		/* When SC_AC_OP_DELETE is absent, we need to provide
 1203|       |		 * SC_AC_OP_DELETE_SELF for sc_pkcs15init_delete_by_path() */
 1204|      0|		sc_file_add_acl_entry(file, SC_AC_OP_DELETE_SELF, method, key_ref);
  ------------------
  |  |  174|      0|#define SC_AC_OP_DELETE_SELF		8
  ------------------
 1205|      0|	}
 1206|       |
 1207|  39.7k|	method = SC_AC_NONE;
  ------------------
  |  |  150|  39.7k|#define SC_AC_NONE			0x00000000
  ------------------
 1208|  39.7k|	key_ref = SC_AC_KEY_REF_NONE;
  ------------------
  |  |  204|  39.7k|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
 1209|       |	/* Read access */
 1210|  39.7k|	switch (info->access & READ_MASK) {
  ------------------
  |  Branch (1210:10): [True: 2.31k, False: 37.3k]
  ------------------
 1211|    548|	case READ_NEVER:
  ------------------
  |  Branch (1211:2): [True: 548, False: 39.1k]
  ------------------
 1212|    548|		method = SC_AC_NEVER;
  ------------------
  |  |  163|    548|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
 1213|    548|		break;
 1214|      0|	case READ_PIN1:
  ------------------
  |  Branch (1214:2): [True: 0, False: 39.7k]
  ------------------
 1215|      0|		method = SC_AC_CHV;
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1216|      0|		key_ref = 0x01;
 1217|      0|		break;
 1218|    883|	case READ_PIN2:
  ------------------
  |  Branch (1218:2): [True: 883, False: 38.8k]
  ------------------
 1219|    883|		method = SC_AC_CHV;
  ------------------
  |  |  151|    883|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1220|    883|		key_ref = 0x02;
 1221|    883|		break;
 1222|    883|	case READ_PIN3:
  ------------------
  |  Branch (1222:2): [True: 883, False: 38.8k]
  ------------------
 1223|    883|		method = SC_AC_CHV;
  ------------------
  |  |  151|    883|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1224|    883|		key_ref = 0x03;
 1225|    883|		break;
 1226|  39.7k|	}
 1227|       |
 1228|  39.7k|	if (method != SC_AC_NONE || key_ref != SC_AC_KEY_REF_NONE) {
  ------------------
  |  |  150|  79.4k|#define SC_AC_NONE			0x00000000
  ------------------
              	if (method != SC_AC_NONE || key_ref != SC_AC_KEY_REF_NONE) {
  ------------------
  |  |  204|  37.3k|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  |  Branch (1228:6): [True: 2.31k, False: 37.3k]
  |  Branch (1228:30): [True: 0, False: 37.3k]
  ------------------
 1229|  2.31k|		sc_file_add_acl_entry(file, SC_AC_OP_READ, method, key_ref);
  ------------------
  |  |  188|  2.31k|#define SC_AC_OP_READ			22
  ------------------
 1230|  2.31k|	}
 1231|  39.7k|}
card-openpgp.c:pgp_match_card:
  326|  3.34k|{
  327|  3.34k|	int i;
  328|       |
  329|  3.34k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  3.34k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.34k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.34k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.34k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.34k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  330|       |
  331|  3.34k|	i = _sc_match_atr(card, pgp_atrs, &card->type);
  332|  3.34k|	if (i >= 0) {
  ------------------
  |  Branch (332:6): [True: 29, False: 3.31k]
  ------------------
  333|     29|		card->name = pgp_atrs[i].name;
  334|     29|		LOG_FUNC_RETURN(card->ctx, 1);
  ------------------
  |  |  164|     29|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     29|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     29|	int _ret = r; \
  |  |  |  |  155|     29|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 29]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     29|	} else { \
  |  |  |  |  159|     29|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     29|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     29|	} \
  |  |  |  |  162|     29|	return _ret; \
  |  |  |  |  163|     29|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  335|     29|	}
  336|  3.31k|	else {
  337|  3.31k|		sc_path_t	partial_aid;
  338|  3.31k|		sc_file_t *file = NULL;
  339|       |
  340|       |		/* select application "OpenPGP" */
  341|  3.31k|		sc_format_path("D276:0001:2401", &partial_aid);
  342|  3.31k|		partial_aid.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|  3.31k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  343|       |		/* OpenPGP card only supports selection *with* requested FCI */
  344|  3.31k|		i = iso_ops->select_file(card, &partial_aid, &file);
  345|  3.31k|		if (SC_SUCCESS == i) {
  ------------------
  |  |   28|  3.31k|#define SC_SUCCESS				0
  ------------------
  |  Branch (345:7): [True: 893, False: 2.41k]
  ------------------
  346|    893|			card->type = SC_CARD_TYPE_OPENPGP_BASE;
  347|    893|			card->name = default_cardname;
  348|       |
  349|    893|			if (file->namelen != 16)
  ------------------
  |  Branch (349:8): [True: 892, False: 1]
  ------------------
  350|    892|				(void) get_full_pgp_aid(card, file);
  351|    893|			if (file->namelen == 16) {
  ------------------
  |  Branch (351:8): [True: 66, False: 827]
  ------------------
  352|     66|				unsigned char major = BCD2UCHAR(file->name[6]);
  ------------------
  |  |  216|     66|#define BCD2UCHAR(x) (((((x) & 0xF0) >> 4) * 10) + ((x) & 0x0F))
  ------------------
  353|       |
  354|     66|				switch (major) {
  355|      5|					case 1:
  ------------------
  |  Branch (355:6): [True: 5, False: 61]
  ------------------
  356|      5|						card->type = SC_CARD_TYPE_OPENPGP_V1;
  357|      5|						card->name = default_cardname_v1;
  358|      5|						break;
  359|     14|					case 2:
  ------------------
  |  Branch (359:6): [True: 14, False: 52]
  ------------------
  360|     14|						card->type = SC_CARD_TYPE_OPENPGP_V2;
  361|     14|						card->name = default_cardname_v2;
  362|     14|						break;
  363|     26|					case 3:
  ------------------
  |  Branch (363:6): [True: 26, False: 40]
  ------------------
  364|     26|						card->type = SC_CARD_TYPE_OPENPGP_V3;
  365|     26|						card->name = default_cardname_v3;
  366|     26|						break;
  367|     21|					default:
  ------------------
  |  Branch (367:6): [True: 21, False: 45]
  ------------------
  368|     21|						break;
  369|     66|				}
  370|     66|			}
  371|    893|			sc_file_free(file);
  372|    893|			LOG_FUNC_RETURN(card->ctx, 1);
  ------------------
  |  |  164|    893|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    893|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    893|	int _ret = r; \
  |  |  |  |  155|    893|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 893]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    893|	} else { \
  |  |  |  |  159|    893|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    893|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    893|	} \
  |  |  |  |  162|    893|	return _ret; \
  |  |  |  |  163|    893|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  373|    893|		}
  374|  3.31k|	}
  375|  2.41k|	LOG_FUNC_RETURN(card->ctx, 0);
  ------------------
  |  |  164|  2.41k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.41k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.41k|	int _ret = r; \
  |  |  |  |  155|  2.41k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.41k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.41k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, 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.41k]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.41k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.41k|	} else { \
  |  |  |  |  159|      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.41k|	return _ret; \
  |  |  |  |  163|  2.41k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  376|  2.41k|}
card-openpgp.c:get_full_pgp_aid:
  307|  1.78k|{
  308|  1.78k|	int r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|  1.78k|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  309|       |
  310|  1.78k|	if (file != NULL) {
  ------------------
  |  Branch (310:6): [True: 1.78k, False: 0]
  ------------------
  311|       |		/* explicitly get the full aid */
  312|  1.78k|		r = sc_get_data(card, 0x004F, file->name, sizeof file->name);
  313|  1.78k|		file->namelen = MAX(r, 0);
  ------------------
  |  |   67|  1.78k|#define MAX(x, y) (((x) > (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (67:20): [True: 966, False: 821]
  |  |  ------------------
  ------------------
  314|  1.78k|	}
  315|       |
  316|  1.78k|	return r;
  317|  1.78k|}
card-openpgp.c:pgp_init:
  409|    922|{
  410|    922|	struct pgp_priv_data *priv;
  411|    922|	sc_path_t	path;
  412|    922|	sc_file_t	*file = NULL;
  413|    922|	int		r, i;
  414|       |
  415|    922|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    922|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    922|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    922|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    922|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 922]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  416|       |
  417|    922|	priv = calloc (1, sizeof *priv);
  418|    922|	if (!priv)
  ------------------
  |  Branch (418:6): [True: 0, False: 922]
  ------------------
  419|    922|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  420|    922|	card->drv_data = priv;
  421|       |
  422|    922|	card->cla = 0x00;
  423|       |
  424|       |	/* select application "OpenPGP" */
  425|    922|	sc_format_path("D276:0001:2401", &path);
  426|    922|	path.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|    922|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  427|    922|	if ((r = iso_ops->select_file(card, &path, &file)) < 0) {
  ------------------
  |  Branch (427:6): [True: 26, False: 896]
  ------------------
  428|     26|		sc_file_free(file);
  429|     26|		pgp_finish(card);
  430|     26|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_CARD);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  431|     26|	}
  432|       |
  433|       |	/* defensive programming check */
  434|    896|	if (!file)   {
  ------------------
  |  Branch (434:6): [True: 0, False: 896]
  ------------------
  435|      0|		pgp_finish(card);
  436|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_CARD);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  437|      0|	}
  438|       |
  439|    896|	if (file->namelen != 16) {
  ------------------
  |  Branch (439:6): [True: 895, False: 1]
  ------------------
  440|       |		/* explicitly get the full aid */
  441|    895|		r = get_full_pgp_aid(card, file);
  442|    895|		if (r < 0) {
  ------------------
  |  Branch (442:7): [True: 13, False: 882]
  ------------------
  443|     13|			sc_file_free(file);
  444|     13|			pgp_finish(card);
  445|     13|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_CARD);
  ------------------
  |  |  164|     13|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     13|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     13|	int _ret = r; \
  |  |  |  |  155|     13|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 13, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     13|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     13|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 13, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     13|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     13|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     13|	return _ret; \
  |  |  |  |  163|     13|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  446|     13|		}
  447|    895|	}
  448|       |
  449|       |	/* read information from AID */
  450|    883|	if (file->namelen == 16) {
  ------------------
  |  Branch (450:6): [True: 783, False: 100]
  ------------------
  451|    783|		static char card_name[SC_MAX_APDU_BUFFER_SIZE] = "OpenPGP card";
  452|       |
  453|       |		/* OpenPGP card spec 1.1, 2.x & 3.x, section 4.2.1 & 4.1.2.1 */
  454|    783|		priv->bcd_version = bebytes2ushort(file->name + 6);
  455|    783|		card->version.fw_major = card->version.hw_major = BCD2UCHAR(file->name[6]);
  ------------------
  |  |  216|    783|#define BCD2UCHAR(x) (((((x) & 0xF0) >> 4) * 10) + ((x) & 0x0F))
  ------------------
  456|    783|		card->version.fw_minor = card->version.hw_minor = BCD2UCHAR(file->name[7]);
  ------------------
  |  |  216|    783|#define BCD2UCHAR(x) (((((x) & 0xF0) >> 4) * 10) + ((x) & 0x0F))
  ------------------
  457|       |
  458|       |		/* for "standard" cards, include detailed card version & serial no. in card name */
  459|    783|		if (card->name == default_cardname_v1 ||
  ------------------
  |  Branch (459:7): [True: 3, False: 780]
  ------------------
  460|    780|		    card->name == default_cardname_v2 ||
  ------------------
  |  Branch (460:7): [True: 3, False: 777]
  ------------------
  461|    777|		    card->name == default_cardname_v3) {
  ------------------
  |  Branch (461:7): [True: 20, False: 757]
  ------------------
  462|     26|			snprintf(card_name, sizeof(card_name),
  463|     26|				 "OpenPGP card v%u.%u (%04X %08lX)",
  464|     26|				 card->version.hw_major, card->version.hw_minor,
  465|     26|				 bebytes2ushort(file->name + 8),
  466|     26|				 bebytes2ulong(file->name + 10));
  467|     26|		}
  468|    757|		else if (card->name != NULL) {
  ------------------
  |  Branch (468:12): [True: 757, False: 0]
  ------------------
  469|       |			/* for other cards, append serial number to the card name */
  470|    757|			snprintf(card_name, sizeof(card_name),
  471|    757|				 "%s (%04X %08lX)",
  472|    757|				 card->name,
  473|    757|				 bebytes2ushort(file->name + 8),
  474|    757|				 bebytes2ulong(file->name + 10));
  475|    757|		}
  476|    783|		card->name = card_name;
  477|       |
  478|       |		/* GPG compatibility: set card's serial number to manufacturer ID + serial number */
  479|    783|		memcpy(card->serialnr.value, file->name + 8, 6);
  480|    783|		card->serialnr.len = 6;
  481|    783|	} else {
  482|       |		/* set detailed card version */
  483|    100|		switch (card->type) {
  484|      5|			case SC_CARD_TYPE_OPENPGP_V3:
  ------------------
  |  Branch (484:4): [True: 5, False: 95]
  ------------------
  485|      5|				priv->bcd_version = OPENPGP_CARD_3_0;
  486|      5|				break;
  487|      7|			case SC_CARD_TYPE_OPENPGP_GNUK:
  ------------------
  |  Branch (487:4): [True: 7, False: 93]
  ------------------
  488|     17|			case SC_CARD_TYPE_OPENPGP_V2:
  ------------------
  |  Branch (488:4): [True: 10, False: 90]
  ------------------
  489|     17|				priv->bcd_version = OPENPGP_CARD_2_0;
  490|     17|				break;
  491|     78|			default:
  ------------------
  |  Branch (491:4): [True: 78, False: 22]
  ------------------
  492|     78|				priv->bcd_version = OPENPGP_CARD_1_1;
  493|     78|				break;
  494|    100|		}
  495|    100|	}
  496|       |
  497|       |	/* set pointer to correct list of card objects */
  498|    883|	priv->pgp_objects = (priv->bcd_version < OPENPGP_CARD_2_0) ? pgp1x_objects
  ------------------
  |  Branch (498:22): [True: 118, False: 765]
  ------------------
  499|    883|			  : (priv->bcd_version < OPENPGP_CARD_2_1) ? pgp20_objects
  ------------------
  |  Branch (499:8): [True: 21, False: 744]
  ------------------
  500|    765|			  : (priv->bcd_version < OPENPGP_CARD_3_0) ? pgp21_objects
  ------------------
  |  Branch (500:8): [True: 13, False: 731]
  ------------------
  501|    744|			  : (priv->bcd_version < OPENPGP_CARD_3_3) ? pgp30_objects
  ------------------
  |  Branch (501:8): [True: 6, False: 725]
  ------------------
  502|    731|			  : (priv->bcd_version < OPENPGP_CARD_3_4) ? pgp33_objects
  ------------------
  |  Branch (502:8): [True: 1, False: 724]
  ------------------
  503|    725|			  :					     pgp34_objects;
  504|       |
  505|       |	/* With gnuk, we use different curves */
  506|    883|	if (card->type == SC_CARD_TYPE_OPENPGP_GNUK) {
  ------------------
  |  Branch (506:6): [True: 27, False: 856]
  ------------------
  507|     27|		priv->ec_curves = ec_curves_gnuk;
  508|    856|	} else if (priv->bcd_version >= OPENPGP_CARD_3_4) {
  ------------------
  |  Branch (508:13): [True: 715, False: 141]
  ------------------
  509|    715|		priv->ec_curves = ec_curves_openpgp34;
  510|    715|	} else {
  511|    141|		priv->ec_curves = ec_curves_openpgp;
  512|    141|	}
  513|       |
  514|       |	/* change file path to MF for reuse in MF */
  515|    883|	sc_format_path("3f00", &file->path);
  516|       |
  517|       |	/* set up the root of our fake file tree */
  518|       |	/* Transfers ownership of the file to the priv->mf structure */
  519|    883|	priv->mf = pgp_new_blob(card, NULL, 0x3f00, file);
  520|    883|	if (!priv->mf) {
  ------------------
  |  Branch (520:6): [True: 0, False: 883]
  ------------------
  521|      0|		sc_file_free(file);
  522|      0|		pgp_finish(card);
  523|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  524|      0|	}
  525|       |
  526|       |	/* select MF */
  527|    883|	priv->current = priv->mf;
  528|       |
  529|    883|	r = populate_blobs_to_mf(card, priv);
  530|    883|	if (r < 0) {
  ------------------
  |  Branch (530:6): [True: 0, False: 883]
  ------------------
  531|      0|		pgp_finish(card);
  532|      0|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  533|      0|	}
  534|       |
  535|       |	/* get card_features from ATR & DOs */
  536|    883|	if (pgp_get_card_features(card)) {
  ------------------
  |  Branch (536:6): [True: 136, False: 747]
  ------------------
  537|    136|		LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    136|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    136|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    136|	int _ret = r; \
  |  |  |  |  155|    136|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 136, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    136|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 136]
  |  |  |  |  ------------------
  |  |  |  |  157|    136|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    136|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    136|	return _ret; \
  |  |  |  |  163|    136|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  538|    136|	}
  539|       |
  540|       |	/* if algorithm attributes can be changed,
  541|       |	 * add supported algorithms based on specification for pkcs15-init */
  542|    747|	if (priv->ext_caps & EXT_CAP_ALG_ATTR_CHANGEABLE) {
  ------------------
  |  Branch (542:6): [True: 284, False: 463]
  ------------------
  543|    284|		unsigned long flags_rsa, flags_ecc, ext_flags;
  544|    284|		unsigned long flags_eddsa, flags_xeddsa;
  545|       |
  546|       |		/* OpenPGP card spec 1.1 & 2.x, section 7.2.9 & 7.2.10 / v3.x section 7.2.11 & 7.2.12 */
  547|    284|		flags_rsa = SC_ALGORITHM_RSA_PAD_PKCS1|
  ------------------
  |  |  111|    284|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|    284|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|    284|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  548|    284|			    SC_ALGORITHM_RSA_HASH_NONE|
  ------------------
  |  |  133|    284|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  549|    284|			    SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|    284|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  550|    284|		flags_ecc = SC_ALGORITHM_ECDSA_RAW|
  ------------------
  |  |  174|    284|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
  551|    284|			    SC_ALGORITHM_ECDH_CDH_RAW|
  ------------------
  |  |  173|    284|#define SC_ALGORITHM_ECDH_CDH_RAW	0x00200000
  ------------------
  552|    284|			    SC_ALGORITHM_ECDSA_HASH_NONE|
  ------------------
  |  |  175|    284|#define SC_ALGORITHM_ECDSA_HASH_NONE		SC_ALGORITHM_RSA_HASH_NONE
  |  |  ------------------
  |  |  |  |  133|    284|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  ------------------
  553|    284|			    SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|    284|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  554|    284|		ext_flags = SC_ALGORITHM_EXT_EC_NAMEDCURVE;
  ------------------
  |  |  201|    284|#define SC_ALGORITHM_EXT_EC_NAMEDCURVE   0x00000008
  ------------------
  555|       |
  556|    284|		flags_eddsa = SC_ALGORITHM_EDDSA_RAW |
  ------------------
  |  |  188|    284|#define SC_ALGORITHM_EDDSA_RAW		0x00400000
  ------------------
  557|    284|			      SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|    284|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  558|       |		/* xeddsa may allow signing at some time */
  559|    284|		flags_xeddsa = SC_ALGORITHM_ECDH_CDH_RAW |
  ------------------
  |  |  173|    284|#define SC_ALGORITHM_ECDH_CDH_RAW	0x00200000
  ------------------
  560|    284|			       SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|    284|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  561|       |
  562|    284|		switch (card->type) {
  563|     11|			case SC_CARD_TYPE_OPENPGP_V3:
  ------------------
  |  Branch (563:4): [True: 11, False: 273]
  ------------------
  564|       |				/* RSA 1024 was removed for v3+ */
  565|     11|				_sc_card_add_rsa_alg(card, 4096, flags_rsa, 0);
  566|     11|				_sc_card_add_rsa_alg(card, 3072, flags_rsa, 0);
  567|       |				/* fallthrough */
  568|     16|			case SC_CARD_TYPE_OPENPGP_GNUK:
  ------------------
  |  Branch (568:4): [True: 5, False: 279]
  ------------------
  569|     16|				_sc_card_add_rsa_alg(card, 2048, flags_rsa, 0);
  570|    169|				for (i=0; priv->ec_curves[i].oid.value[0] >= 0; i++)
  ------------------
  |  Branch (570:15): [True: 153, False: 16]
  ------------------
  571|    153|				{
  572|    153|					if (priv->ec_curves[i].key_type == SC_ALGORITHM_EC)
  ------------------
  |  |   70|    153|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (572:10): [True: 109, False: 44]
  ------------------
  573|    109|						_sc_card_add_ec_alg(card, priv->ec_curves[i].size,
  574|    109|								flags_ecc, ext_flags, &priv->ec_curves[i].oid);
  575|     44|					else if (priv->ec_curves[i].key_type == SC_ALGORITHM_EDDSA)
  ------------------
  |  |   72|     44|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (575:15): [True: 22, False: 22]
  ------------------
  576|     22|						_sc_card_add_eddsa_alg(card, priv->ec_curves[i].size,
  577|     22|								flags_eddsa, ext_flags, &priv->ec_curves[i].oid);
  578|     22|					else if (priv->ec_curves[i].key_type == SC_ALGORITHM_XEDDSA)
  ------------------
  |  |   73|     22|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (578:15): [True: 22, False: 0]
  ------------------
  579|     22|						_sc_card_add_xeddsa_alg(card, priv->ec_curves[i].size,
  580|     22|								flags_xeddsa, ext_flags, &priv->ec_curves[i].oid);
  581|      0|					else
  582|      0|						LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  583|    153|				}
  584|     16|				break;
  585|     16|			case SC_CARD_TYPE_OPENPGP_V2:
  ------------------
  |  Branch (585:4): [True: 7, False: 277]
  ------------------
  586|    268|			default:
  ------------------
  |  Branch (586:4): [True: 261, False: 23]
  ------------------
  587|    268|				_sc_card_add_rsa_alg(card, 1024, flags_rsa, 0);
  588|    268|				_sc_card_add_rsa_alg(card, 2048, flags_rsa, 0);
  589|    268|				_sc_card_add_rsa_alg(card, 3072, flags_rsa, 0);
  590|    268|				_sc_card_add_rsa_alg(card, 4096, flags_rsa, 0);
  591|    268|				break;
  592|    284|		}
  593|    284|	}
  594|       |
  595|    747|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    747|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    747|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    747|	int _ret = r; \
  |  |  |  |  155|    747|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 747, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    747|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 747]
  |  |  |  |  ------------------
  |  |  |  |  157|    747|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    747|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    747|	return _ret; \
  |  |  |  |  163|    747|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  596|    747|}
card-openpgp.c:pgp_get_pubkey:
 1790|    589|{
 1791|    589|	sc_apdu_t	apdu;
 1792|    589|	u8 apdu_case = (card->type == SC_CARD_TYPE_OPENPGP_GNUK)
  ------------------
  |  Branch (1792:17): [True: 3, False: 586]
  ------------------
 1793|    589|			? SC_APDU_CASE_4_SHORT : SC_APDU_CASE_4;
  ------------------
  |  |  294|      3|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
              			? SC_APDU_CASE_4_SHORT : SC_APDU_CASE_4;
  ------------------
  |  |  303|  1.17k|#define SC_APDU_CASE_4			0x24
  ------------------
 1794|    589|	u8		idbuf[2];
 1795|    589|	int		r;
 1796|       |
 1797|    589|	sc_log(card->ctx, "called, tag=%04x\n", tag);
  ------------------
  |  |   71|    589|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1798|       |
 1799|    589|	sc_format_apdu(card, &apdu, apdu_case, 0x47, 0x81, 0);
 1800|    589|	apdu.lc = 2;
 1801|    589|	apdu.data = ushort2bebytes(idbuf, tag);
 1802|    589|	apdu.datalen = 2;
 1803|    589|	apdu.le = ((buf_len >= 256) && !(card->caps & SC_CARD_CAP_APDU_EXT)) ? 256 : buf_len;
  ------------------
  |  |  547|    589|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (1803:13): [True: 589, False: 0]
  |  Branch (1803:33): [True: 552, False: 37]
  ------------------
 1804|    589|	apdu.resp = buf;
 1805|    589|	apdu.resplen = buf_len;
 1806|       |
 1807|    589|	r = sc_transmit_apdu(card, &apdu);
 1808|    589|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    589|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    589|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    589|	int _ret = (r); \
  |  |  |  |  168|    589|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 29, False: 560]
  |  |  |  |  ------------------
  |  |  |  |  169|     29|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     29|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     29|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     29|		return _ret; \
  |  |  |  |  172|     29|	} \
  |  |  |  |  173|    589|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 560]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1809|       |
 1810|    560|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1811|    560|	LOG_TEST_RET(card->ctx, r, "Card returned error");
  ------------------
  |  |  174|    560|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    560|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    560|	int _ret = (r); \
  |  |  |  |  168|    560|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 449, False: 111]
  |  |  |  |  ------------------
  |  |  |  |  169|    449|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    449|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    449|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    449|		return _ret; \
  |  |  |  |  172|    449|	} \
  |  |  |  |  173|    560|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 111]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1812|       |
 1813|    111|	LOG_FUNC_RETURN(card->ctx, (int)apdu.resplen);
  ------------------
  |  |  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: 58, False: 53]
  |  |  |  |  ------------------
  |  |  |  |  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|     53|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     53|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     53|	} \
  |  |  |  |  162|    111|	return _ret; \
  |  |  |  |  163|    111|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1814|    111|}
card-openpgp.c:pgp_get_pubkey_pem:
 1822|      4|{
 1823|      4|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|      4|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 1824|      4|	pgp_blob_t	*blob, *mod_blob, *exp_blob, *pubkey_blob, *blob6e, *blob73, *aa_blob;
 1825|      4|	sc_pkcs15_pubkey_t p15pubkey;
 1826|      4|	sc_cardctl_openpgp_key_gen_store_info_t key_info;
 1827|      4|	unsigned int	aa_tag = 0;
 1828|      4|	u8		*data = NULL;
 1829|      4|	size_t		len = 0;
 1830|      4|	int		r;
 1831|       |
 1832|      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__
  |  |  ------------------
  ------------------
 1833|      4|	memset(&p15pubkey, 0, sizeof(p15pubkey));
 1834|       |
 1835|      4|	if ((r = pgp_get_blob(card, priv->mf, tag & 0xFFFE, &blob)) < 0
  ------------------
  |  Branch (1835:6): [True: 0, False: 4]
  ------------------
 1836|      4|		|| (r = pgp_get_blob(card, blob, 0x7F49, &blob)) < 0)
  ------------------
  |  Branch (1836:6): [True: 4, False: 0]
  ------------------
 1837|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1838|       |
 1839|       |	/* RSA */
 1840|      0|	if ((r = pgp_get_blob(card, blob, 0x0081, &mod_blob)) >= 0
  ------------------
  |  Branch (1840:6): [True: 0, False: 0]
  ------------------
 1841|      0|		&& (r = pgp_get_blob(card, blob, 0x0082, &exp_blob)) >= 0
  ------------------
  |  Branch (1841:6): [True: 0, False: 0]
  ------------------
 1842|      0|		&& (r = pgp_read_blob(card, mod_blob)) >= 0
  ------------------
  |  Branch (1842:6): [True: 0, False: 0]
  ------------------
 1843|      0|		&& (r = pgp_read_blob(card, exp_blob)) >= 0) {
  ------------------
  |  Branch (1843:6): [True: 0, False: 0]
  ------------------
 1844|       |
 1845|      0|		p15pubkey.algorithm = SC_ALGORITHM_RSA;
  ------------------
  |  |   69|      0|#define SC_ALGORITHM_RSA		0
  ------------------
 1846|      0|		p15pubkey.u.rsa.modulus.data  = mod_blob->data;
 1847|      0|		p15pubkey.u.rsa.modulus.len   = mod_blob->len;
 1848|      0|		p15pubkey.u.rsa.exponent.data = exp_blob->data;
 1849|      0|		p15pubkey.u.rsa.exponent.len  = exp_blob->len;
 1850|      0|		r = sc_pkcs15_encode_pubkey(card->ctx, &p15pubkey, &data, &len);
 1851|      0|	}
 1852|       |	/* ECC */
 1853|      0|	else if ((r = pgp_get_blob(card, blob, 0x0086, &pubkey_blob)) >= 0
  ------------------
  |  Branch (1853:11): [True: 0, False: 0]
  ------------------
 1854|      0|		&& (r = pgp_read_blob(card, pubkey_blob)) >= 0) {
  ------------------
  |  Branch (1854:6): [True: 0, False: 0]
  ------------------
 1855|       |
 1856|      0|		switch(tag & 0xFFFE) {
 1857|      0|			case DO_SIGN: aa_tag = 0x00C1; break;
  ------------------
  |  |  141|      0|#define DO_SIGN                  0xb600
  ------------------
  |  Branch (1857:4): [True: 0, False: 0]
  ------------------
 1858|      0|			case DO_ENCR: aa_tag = 0x00C2; break;
  ------------------
  |  |  142|      0|#define DO_ENCR                  0xb800
  ------------------
  |  Branch (1858:4): [True: 0, False: 0]
  ------------------
 1859|      0|			case DO_AUTH: aa_tag = 0x00C3; break;
  ------------------
  |  |  143|      0|#define DO_AUTH                  0xa400
  ------------------
  |  Branch (1859:4): [True: 0, False: 0]
  ------------------
 1860|      0|			default: r = SC_ERROR_INCORRECT_PARAMETERS;
  ------------------
  |  |   55|      0|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
  |  Branch (1860:4): [True: 0, False: 0]
  ------------------
 1861|      0|		}
 1862|       |
 1863|       |		/* Get EC parameters from Algorithm Attribute if present */
 1864|       |
 1865|      0|		if (aa_tag && ((r = pgp_get_blob(card, priv->mf, 0x006e, &blob6e)) >= 0) &&
  ------------------
  |  Branch (1865:7): [True: 0, False: 0]
  |  Branch (1865:17): [True: 0, False: 0]
  ------------------
 1866|      0|				((r = pgp_get_blob(card, blob6e, 0x0073, &blob73)) >= 0) &&
  ------------------
  |  Branch (1866:5): [True: 0, False: 0]
  ------------------
 1867|      0|				((r = pgp_get_blob(card, blob73, aa_tag, &aa_blob)) >= 0) &&
  ------------------
  |  Branch (1867:5): [True: 0, False: 0]
  ------------------
 1868|      0|				((r = pgp_parse_algo_attr_blob(card, aa_blob, &key_info)) >= 0)) {
  ------------------
  |  Branch (1868:5): [True: 0, False: 0]
  ------------------
 1869|      0|			switch (key_info.algorithm) {
 1870|      0|			case SC_OPENPGP_KEYALGO_EDDSA:
  ------------------
  |  |  873|      0|#define	SC_OPENPGP_KEYALGO_EDDSA	0x16
  ------------------
  |  Branch (1870:4): [True: 0, False: 0]
  ------------------
 1871|       |				/* In EDDSA key case we do not have to care about OIDs
 1872|       |				 * as we support only one for now */
 1873|      0|				p15pubkey.algorithm = SC_ALGORITHM_EDDSA;
  ------------------
  |  |   72|      0|#define SC_ALGORITHM_EDDSA		4
  ------------------
 1874|      0|				p15pubkey.u.ec.ecpointQ.value = pubkey_blob->data;
 1875|      0|				p15pubkey.u.ec.ecpointQ.len = pubkey_blob->len;
 1876|       |				/* PKCS#11 3.0: 2.3.5 Edwards EC public keys only support the use
 1877|       |				 * of the curveName selection to specify a curve name as defined
 1878|       |				 * in [RFC 8032] */
 1879|      0|				r = sc_pkcs15_encode_pubkey_as_spki(card->ctx, &p15pubkey, &data, &len);
 1880|      0|				break;
 1881|      0|			case SC_OPENPGP_KEYALGO_ECDH:
  ------------------
  |  |  871|      0|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (1881:4): [True: 0, False: 0]
  ------------------
 1882|       |				/* This yields either EC(DSA) key or EC_MONTGOMERY (curve25519) key */
 1883|      0|				if (sc_compare_oid(&key_info.u.ec.oid, &curve25519_oid)) {
  ------------------
  |  Branch (1883:9): [True: 0, False: 0]
  ------------------
 1884|      0|					p15pubkey.algorithm = SC_ALGORITHM_XEDDSA;
  ------------------
  |  |   73|      0|#define SC_ALGORITHM_XEDDSA		5
  ------------------
 1885|      0|					p15pubkey.u.ec.ecpointQ.value = pubkey_blob->data;
 1886|      0|					p15pubkey.u.ec.ecpointQ.len = pubkey_blob->len;
 1887|       |					/* PKCS#11 3.0 2.3.7 Montgomery EC public keys only support
 1888|       |					 * the use of the curveName selection to specify a curve
 1889|       |					 * name as defined in [RFC7748] */
 1890|       |					/* XXX only curve25519 supported now. Theoretically could be
 1891|       |					 * also curve448 or OIDs */
 1892|       |
 1893|      0|					r = sc_pkcs15_encode_pubkey_as_spki(card->ctx, &p15pubkey, &data, &len);
 1894|      0|					break;
 1895|      0|				}
 1896|       |				/* fall through */
 1897|      0|			case SC_OPENPGP_KEYALGO_ECDSA:
  ------------------
  |  |  872|      0|#define	SC_OPENPGP_KEYALGO_ECDSA	0x13
  ------------------
  |  Branch (1897:4): [True: 0, False: 0]
  ------------------
 1898|      0|				if ((r = sc_encode_oid(card->ctx, &key_info.u.ec.oid,
  ------------------
  |  Branch (1898:9): [True: 0, False: 0]
  ------------------
 1899|      0|						&p15pubkey.u.ec.params.der.value,
 1900|      0|						&p15pubkey.u.ec.params.der.len)) == 0) {
 1901|      0|					p15pubkey.algorithm = SC_ALGORITHM_EC;
  ------------------
  |  |   70|      0|#define SC_ALGORITHM_EC		2
  ------------------
 1902|      0|					p15pubkey.u.ec.ecpointQ.value = pubkey_blob->data;
 1903|      0|					p15pubkey.u.ec.ecpointQ.len = pubkey_blob->len;
 1904|      0|					p15pubkey.u.ec.params.type = 1;
 1905|      0|					r = sc_pkcs15_encode_pubkey_as_spki(card->ctx, &p15pubkey, &data, &len);
 1906|      0|				} else {
 1907|      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__
  |  |  ------------------
  ------------------
 1908|      0|				}
 1909|      0|				break;
 1910|      0|			default:
  ------------------
  |  Branch (1910:4): [True: 0, False: 0]
  ------------------
 1911|      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__
  |  |  ------------------
  ------------------
 1912|      0|				break;
 1913|      0|			}
 1914|      0|		} else {
 1915|      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__
  |  |  ------------------
  ------------------
 1916|      0|		}
 1917|      0|	} else {
 1918|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1919|      0|	}
 1920|       |
 1921|       |	/* clean up anything we may have set in p15pubkey that can not be freed */
 1922|      0|	if (p15pubkey.algorithm == SC_ALGORITHM_RSA) {
  ------------------
  |  |   69|      0|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (1922:6): [True: 0, False: 0]
  ------------------
 1923|      0|		p15pubkey.u.rsa.modulus.data  = NULL;
 1924|      0|		p15pubkey.u.rsa.modulus.len = 0;
 1925|      0|		p15pubkey.u.rsa.exponent.data  = NULL;
 1926|      0|		p15pubkey.u.rsa.exponent.len = 0;
 1927|      0|	} else if (p15pubkey.algorithm == SC_ALGORITHM_EC ||
  ------------------
  |  |   70|      0|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (1927:13): [True: 0, False: 0]
  ------------------
 1928|      0|			p15pubkey.algorithm == SC_ALGORITHM_EDDSA ||
  ------------------
  |  |   72|      0|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (1928:4): [True: 0, False: 0]
  ------------------
 1929|      0|			p15pubkey.algorithm == SC_ALGORITHM_XEDDSA) {
  ------------------
  |  |   73|      0|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (1929:4): [True: 0, False: 0]
  ------------------
 1930|      0|		p15pubkey.u.ec.ecpointQ.value = NULL;
 1931|      0|		p15pubkey.u.ec.ecpointQ.len = 0;
 1932|       |		/* p15pubkey.u.ec.params.der and named_curve will be freed by sc_pkcs15_erase_pubkey */
 1933|      0|	}
 1934|      0|	sc_pkcs15_erase_pubkey(&p15pubkey);
 1935|       |
 1936|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1937|       |
 1938|      0|	if (len > buf_len)
  ------------------
  |  Branch (1938:6): [True: 0, False: 0]
  ------------------
 1939|      0|		len = buf_len;
 1940|      0|	memcpy(buf, data, len);
 1941|      0|	free(data);
 1942|       |
 1943|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1944|      0|}
card-openpgp.c:pgp_get_blob:
 1480|  29.5k|{
 1481|  29.5k|	pgp_blob_t		*child;
 1482|  29.5k|	int			r;
 1483|       |
 1484|  29.5k|	if ((r = pgp_enumerate_blob(card, blob)) < 0)
  ------------------
  |  Branch (1484:6): [True: 8.06k, False: 21.4k]
  ------------------
 1485|  8.06k|		return r;
 1486|       |
 1487|   116k|	for (child = blob->files; child; child = child->next) {
  ------------------
  |  Branch (1487:28): [True: 100k, False: 16.0k]
  ------------------
 1488|   100k|		if (child->id == id) {
  ------------------
  |  Branch (1488:7): [True: 5.37k, False: 94.6k]
  ------------------
 1489|  5.37k|			(void) pgp_read_blob(card, child);
 1490|  5.37k|			*ret = child;
 1491|  5.37k|			return SC_SUCCESS;
  ------------------
  |  |   28|  5.37k|#define SC_SUCCESS				0
  ------------------
 1492|  5.37k|		}
 1493|   100k|	}
 1494|       |
 1495|       |	/* This part is for "NOT FOUND" cases */
 1496|       |
 1497|       |	/* Special case:
 1498|       |	 * Gnuk does not have default value for children of DO 65 (DOs 5B, 5F2D, 5F35)
 1499|       |	 * So, if these blob was not found, we create it. */
 1500|  16.0k|	if (blob->id == DO_CARDHOLDER && (id == DO_NAME || id == DO_LANG_PREF || id == DO_SEX)) {
  ------------------
  |  |  154|  32.1k|#define DO_CARDHOLDER            0x65
  ------------------
              	if (blob->id == DO_CARDHOLDER && (id == DO_NAME || id == DO_LANG_PREF || id == DO_SEX)) {
  ------------------
  |  |  155|  2.10k|#define DO_NAME                  0x5b
  ------------------
              	if (blob->id == DO_CARDHOLDER && (id == DO_NAME || id == DO_LANG_PREF || id == DO_SEX)) {
  ------------------
  |  |  156|  2.10k|#define DO_LANG_PREF             0x5f2d
  ------------------
              	if (blob->id == DO_CARDHOLDER && (id == DO_NAME || id == DO_LANG_PREF || id == DO_SEX)) {
  ------------------
  |  |  157|    916|#define DO_SEX                   0x5f35
  ------------------
  |  Branch (1500:6): [True: 1.05k, False: 15.0k]
  |  Branch (1500:36): [True: 0, False: 1.05k]
  |  Branch (1500:53): [True: 135, False: 916]
  |  Branch (1500:75): [True: 0, False: 916]
  ------------------
 1501|    135|		sc_log(card->ctx, "Create blob %X under %X", id, blob->id);
  ------------------
  |  |   71|    135|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1502|    135|		child = pgp_new_blob(card, blob, id, sc_file_new());
 1503|    135|		if (child) {
  ------------------
  |  Branch (1503:7): [True: 135, False: 0]
  ------------------
 1504|    135|			pgp_set_blob(child, NULL, 0);
 1505|    135|			*ret = child;
 1506|    135|			return SC_SUCCESS;
  ------------------
  |  |   28|    135|#define SC_SUCCESS				0
  ------------------
 1507|    135|		}
 1508|      0|		else
 1509|      0|			sc_log(card->ctx,
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1510|    135|			       "Not enough memory to create blob for DO %X",
 1511|    135|			       id);
 1512|    135|	}
 1513|       |
 1514|  15.9k|	return SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|  15.9k|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
 1515|  16.0k|}
card-openpgp.c:pgp_enumerate_blob:
 1398|  30.2k|{
 1399|  30.2k|	const u8	*in;
 1400|  30.2k|	int		r;
 1401|  30.2k|	sc_file_t	*file = NULL;
 1402|       |
 1403|  30.2k|	if (blob->files != NULL)
  ------------------
  |  Branch (1403:6): [True: 12.4k, False: 17.8k]
  ------------------
 1404|  12.4k|		return SC_SUCCESS;
  ------------------
  |  |   28|  12.4k|#define SC_SUCCESS				0
  ------------------
 1405|       |
 1406|  17.8k|	if ((r = pgp_read_blob(card, blob)) < 0)
  ------------------
  |  Branch (1406:6): [True: 2.44k, False: 15.4k]
  ------------------
 1407|  2.44k|		return r;
 1408|       |
 1409|  15.4k|	in = blob->data;
 1410|       |
 1411|  57.7k|	while ((int) blob->len > (in - blob->data)) {
  ------------------
  |  Branch (1411:9): [True: 48.6k, False: 9.13k]
  ------------------
 1412|  48.6k|		unsigned int	cla, tag, tmptag;
 1413|  48.6k|		size_t		len;
 1414|  48.6k|		const u8	*data = in;
 1415|  48.6k|		pgp_blob_t	*new;
 1416|       |
 1417|  48.6k|		if (!in)
  ------------------
  |  Branch (1417:7): [True: 0, False: 48.6k]
  ------------------
 1418|      0|			return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
 1419|       |
 1420|  48.6k|		r = sc_asn1_read_tag(&data, blob->len - (in - blob->data),
 1421|  48.6k|					&cla, &tag, &len);
 1422|  48.6k|		if (r == SC_ERROR_INVALID_ASN1_OBJECT) {
  ------------------
  |  |   82|  48.6k|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  |  Branch (1422:7): [True: 1.57k, False: 47.0k]
  ------------------
 1423|  1.57k|			sc_log(card->ctx, "Invalid ASN.1 object");
  ------------------
  |  |   71|  1.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__
  |  |  ------------------
  ------------------
 1424|  1.57k|			return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|  1.57k|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
 1425|  1.57k|		}
 1426|       |		/* Check for unknown error, or empty data */
 1427|  47.0k|		if (((r < 0) && (r != SC_ERROR_ASN1_END_OF_CONTENTS)) ||
  ------------------
  |  |   84|  3.75k|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (1427:8): [True: 3.75k, False: 43.3k]
  |  Branch (1427:19): [True: 0, False: 3.75k]
  ------------------
 1428|  47.0k|		    (data == NULL)) {
  ------------------
  |  Branch (1428:7): [True: 1.06k, False: 45.9k]
  ------------------
 1429|  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__
  |  |  ------------------
  ------------------
 1430|  1.06k|			return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|  1.06k|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
 1431|  1.06k|		}
 1432|       |
 1433|       |		/* undo ASN1's split of tag & class */
 1434|  47.5k|		for (tmptag = tag; tmptag > 0x0FF; tmptag >>= 8) {
  ------------------
  |  Branch (1434:22): [True: 1.52k, False: 45.9k]
  ------------------
 1435|  1.52k|			cla <<= 8;
 1436|  1.52k|		}
 1437|  45.9k|		tag |= cla;
 1438|       |		/* Check for length mismatch */
 1439|  45.9k|		if ((r == SC_ERROR_ASN1_END_OF_CONTENTS) ||
  ------------------
  |  |   84|  45.9k|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (1439:7): [True: 3.75k, False: 42.2k]
  ------------------
 1440|  42.2k|		    (data + len > blob->data + blob->len)) {
  ------------------
  |  Branch (1440:7): [True: 0, False: 42.2k]
  ------------------
 1441|       |			// Check if it is not known Yubikey 5 issue
 1442|  3.75k|			if ((tag != blob->id) || (tag != 0xfa)) {
  ------------------
  |  Branch (1442:8): [True: 2.80k, False: 946]
  |  Branch (1442:29): [True: 823, False: 123]
  ------------------
 1443|  3.62k|				sc_log(card->ctx, "Unexpected end of contents");
  ------------------
  |  |   71|  3.62k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1444|  3.62k|				return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|  3.62k|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
 1445|  3.62k|			}
 1446|  3.75k|		}
 1447|       |
 1448|       |		/* Awful hack for composite DOs that have
 1449|       |		 * a TLV with the DO's id encompassing the
 1450|       |		 * entire blob. Example: Yubikey Neo */
 1451|  42.3k|		if (tag == blob->id) {
  ------------------
  |  Branch (1451:7): [True: 749, False: 41.6k]
  ------------------
 1452|    749|			in = data;
 1453|    749|			continue;
 1454|    749|		}
 1455|       |
 1456|       |		/* create fake file system hierarchy by
 1457|       |		 * using constructed DOs as DF */
 1458|  41.6k|		file = sc_file_new();
 1459|  41.6k|		if ((new = pgp_new_blob(card, blob, tag, file)) == NULL) {
  ------------------
  |  Branch (1459:7): [True: 0, False: 41.6k]
  ------------------
 1460|      0|			sc_file_free(file);
 1461|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1462|      0|		}
 1463|  41.6k|		if (pgp_set_blob(new, data, len) != SC_SUCCESS) {
  ------------------
  |  |   28|  41.6k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1463:7): [True: 0, False: 41.6k]
  ------------------
 1464|      0|			sc_file_free(file);
 1465|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1466|      0|		}
 1467|  41.6k|		in = data + len;
 1468|  41.6k|	}
 1469|       |
 1470|  9.13k|	return SC_SUCCESS;
  ------------------
  |  |   28|  9.13k|#define SC_SUCCESS				0
  ------------------
 1471|  15.4k|}
card-openpgp.c:pgp_set_blob:
 1140|  44.0k|{
 1141|  44.0k|	if (blob->data)
  ------------------
  |  Branch (1141:6): [True: 71, False: 44.0k]
  ------------------
 1142|     71|		free(blob->data);
 1143|  44.0k|	blob->data = NULL;
 1144|  44.0k|	blob->len    = 0;
 1145|  44.0k|	blob->status = 0;
 1146|       |
 1147|  44.0k|	if (len > 0) {
  ------------------
  |  Branch (1147:6): [True: 25.1k, False: 18.9k]
  ------------------
 1148|  25.1k|		void *tmp = calloc(1, len);
 1149|       |
 1150|  25.1k|		if (tmp == NULL)
  ------------------
  |  Branch (1150:7): [True: 0, False: 25.1k]
  ------------------
 1151|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1152|       |
 1153|  25.1k|		blob->data = tmp;
 1154|  25.1k|		blob->len  = (unsigned int)len;
 1155|  25.1k|		if (data != NULL)
  ------------------
  |  Branch (1155:7): [True: 25.1k, False: 0]
  ------------------
 1156|  25.1k|			memcpy(blob->data, data, len);
 1157|  25.1k|	}
 1158|       |
 1159|  44.0k|	if (blob->file)
  ------------------
  |  Branch (1159:6): [True: 44.0k, False: 0]
  ------------------
 1160|  44.0k|		blob->file->size = len;
 1161|       |
 1162|  44.0k|	return SC_SUCCESS;
  ------------------
  |  |   28|  44.0k|#define SC_SUCCESS				0
  ------------------
 1163|  44.0k|}
card-openpgp.c:pgp_read_blob:
 1348|  23.9k|{
 1349|  23.9k|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|  23.9k|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 1350|       |
 1351|  23.9k|	if (blob->data != NULL)
  ------------------
  |  Branch (1351:6): [True: 9.53k, False: 14.4k]
  ------------------
 1352|  9.53k|		return SC_SUCCESS;
  ------------------
  |  |   28|  9.53k|#define SC_SUCCESS				0
  ------------------
 1353|  14.4k|	if (blob->info == NULL)
  ------------------
  |  Branch (1353:6): [True: 6.56k, False: 7.87k]
  ------------------
 1354|  6.56k|		return blob->status;
 1355|       |
 1356|  7.87k|	if (blob->info->get_fn) {	/* readable, top-level DO */
  ------------------
  |  Branch (1356:6): [True: 6.81k, False: 1.05k]
  ------------------
 1357|  6.81k|		u8 	buffer[MAX_OPENPGP_DO_SIZE];
 1358|  6.81k|		size_t	buf_len = sizeof(buffer);
 1359|  6.81k|		int r = SC_SUCCESS;
  ------------------
  |  |   28|  6.81k|#define SC_SUCCESS				0
  ------------------
 1360|       |
 1361|       |		/* buffer length for certificate */
 1362|  6.81k|		if (blob->id == DO_CERT && priv->max_cert_size > 0) {
  ------------------
  |  |  138|  13.6k|#define DO_CERT                  0x7f21
  ------------------
  |  Branch (1362:7): [True: 0, False: 6.81k]
  |  Branch (1362:30): [True: 0, False: 0]
  ------------------
 1363|      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]
  |  |  ------------------
  ------------------
 1364|      0|		}
 1365|       |
 1366|       |		/* buffer length for Gnuk pubkey */
 1367|  6.81k|		if (card->type == SC_CARD_TYPE_OPENPGP_GNUK &&
  ------------------
  |  Branch (1367:7): [True: 166, False: 6.64k]
  ------------------
 1368|    166|		    (blob->id == DO_AUTH ||
  ------------------
  |  |  143|    332|#define DO_AUTH                  0xa400
  ------------------
  |  Branch (1368:8): [True: 1, False: 165]
  ------------------
 1369|    165|		     blob->id == DO_SIGN ||
  ------------------
  |  |  141|    331|#define DO_SIGN                  0xb600
  ------------------
  |  Branch (1369:8): [True: 1, False: 164]
  ------------------
 1370|    164|		     blob->id == DO_ENCR ||
  ------------------
  |  |  142|    330|#define DO_ENCR                  0xb800
  ------------------
  |  Branch (1370:8): [True: 1, False: 163]
  ------------------
 1371|    163|		     blob->id == DO_AUTH_SYM ||
  ------------------
  |  |  147|    329|#define DO_AUTH_SYM              0xa401
  ------------------
  |  Branch (1371:8): [True: 0, False: 163]
  ------------------
 1372|    163|		     blob->id == DO_SIGN_SYM ||
  ------------------
  |  |  145|    329|#define DO_SIGN_SYM              0xb601
  ------------------
  |  Branch (1372:8): [True: 0, False: 163]
  ------------------
 1373|    163|		     blob->id == DO_ENCR_SYM)) {
  ------------------
  |  |  146|    163|#define DO_ENCR_SYM              0xb801
  ------------------
  |  Branch (1373:8): [True: 0, False: 163]
  ------------------
 1374|      3|			buf_len = MIN(MAXLEN_RESP_PUBKEY_GNUK, sizeof(buffer));
  ------------------
  |  |   70|      3|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 3, Folded]
  |  |  ------------------
  ------------------
 1375|      3|		}
 1376|       |
 1377|  6.81k|		r = blob->info->get_fn(card, blob->id, buffer, buf_len);
 1378|       |
 1379|  6.81k|		if (r < 0) {	/* an error occurred */
  ------------------
  |  Branch (1379:7): [True: 4.62k, False: 2.18k]
  ------------------
 1380|  4.62k|			blob->status = r;
 1381|  4.62k|			return r;
 1382|  4.62k|		}
 1383|       |
 1384|  2.18k|		return pgp_set_blob(blob, buffer, r);
 1385|  6.81k|	}
 1386|  1.05k|	else {		/* un-readable DO or part of a constructed DO */
 1387|  1.05k|		return SC_SUCCESS;
  ------------------
  |  |   28|  1.05k|#define SC_SUCCESS				0
  ------------------
 1388|  1.05k|	}
 1389|  7.87k|}
card-openpgp.c:pgp_parse_algo_attr_blob:
  634|  16.8k|{
  635|  16.8k|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|  16.8k|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
  636|  16.8k|	struct sc_object_id oid;
  637|  16.8k|	unsigned int j, r;
  638|       |
  639|  16.8k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  16.8k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  16.8k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  16.8k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  16.8k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 16.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  640|       |
  641|  16.8k|	if (blob == NULL || blob->data == NULL || blob->len == 0 ||
  ------------------
  |  Branch (641:6): [True: 0, False: 16.8k]
  |  Branch (641:22): [True: 2.09k, False: 14.7k]
  |  Branch (641:44): [True: 0, False: 14.7k]
  ------------------
  642|  14.7k|	    blob->id < 0x00c1 || blob->id > 0x00c3 || key_info == NULL) {
  ------------------
  |  Branch (642:6): [True: 0, False: 14.7k]
  |  Branch (642:27): [True: 0, False: 14.7k]
  |  Branch (642:48): [True: 0, False: 14.7k]
  ------------------
  643|  2.09k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS);
  ------------------
  |  |  164|  2.09k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.09k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.09k|	int _ret = r; \
  |  |  |  |  155|  2.09k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.09k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.09k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  2.09k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.09k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.09k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.09k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|  2.09k|	return _ret; \
  |  |  |  |  163|  2.09k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  644|  2.09k|	}
  645|       |
  646|  14.7k|	key_info->key_id = blob->id - 0x00c0;	/* attribute algorithm blobs are C1 - C3 */
  647|       |
  648|  14.7k|	switch (blob->data[0]) {
  649|  3.44k|		case SC_OPENPGP_KEYALGO_RSA:
  ------------------
  |  |  870|  3.44k|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  |  Branch (649:3): [True: 3.44k, False: 11.2k]
  ------------------
  650|  3.44k|			if (blob->len < 5) {
  ------------------
  |  Branch (650:8): [True: 2.34k, False: 1.09k]
  ------------------
  651|  2.34k|				LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS);
  ------------------
  |  |  164|  2.34k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.34k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.34k|	int _ret = r; \
  |  |  |  |  155|  2.34k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.34k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.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|  2.34k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.34k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.34k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.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|  2.34k|	return _ret; \
  |  |  |  |  163|  2.34k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  652|  2.34k|			}
  653|       |
  654|  1.09k|			key_info->algorithm = SC_OPENPGP_KEYALGO_RSA;
  ------------------
  |  |  870|  1.09k|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  655|  1.09k|			key_info->u.rsa.modulus_len = bebytes2ushort(blob->data + 1);
  656|  1.09k|			key_info->u.rsa.exponent_len = bebytes2ushort(blob->data + 3);
  657|       |
  658|  1.09k|			key_info->u.rsa.keyformat = (blob->len > 5)
  ------------------
  |  Branch (658:32): [True: 554, False: 542]
  ------------------
  659|  1.09k|						  ? blob->data[5]
  660|  1.09k|						  : SC_OPENPGP_KEYFORMAT_RSA_STD;
  ------------------
  |  |  875|  1.63k|#define SC_OPENPGP_KEYFORMAT_RSA_STD	0    /* See 4.3.3.6 Algorithm Attributes */
  ------------------
  661|  1.09k|			break;
  662|  5.59k|		case SC_OPENPGP_KEYALGO_ECDH:
  ------------------
  |  |  871|  5.59k|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (662:3): [True: 5.59k, False: 9.11k]
  ------------------
  663|  7.33k|		case SC_OPENPGP_KEYALGO_ECDSA:
  ------------------
  |  |  872|  7.33k|#define	SC_OPENPGP_KEYALGO_ECDSA	0x13
  ------------------
  |  Branch (663:3): [True: 1.73k, False: 12.9k]
  ------------------
  664|  9.18k|		case SC_OPENPGP_KEYALGO_EDDSA:
  ------------------
  |  |  873|  9.18k|#define	SC_OPENPGP_KEYALGO_EDDSA	0x16
  ------------------
  |  Branch (664:3): [True: 1.85k, False: 12.8k]
  ------------------
  665|       |
  666|       |			/* SC_OPENPGP_KEYALGO_ECDH || SC_OPENPGP_KEYALGO_ECDSA || SC_OPENPGP_KEYALGO_EDDSA */
  667|  9.18k|			key_info->algorithm = blob->data[0];
  668|       |
  669|       |			/* last byte is set to 0xFF if pubkey import is supported */
  670|  9.18k|			if (blob->data[blob->len-1] == SC_OPENPGP_KEYFORMAT_EC_STDPUB){
  ------------------
  |  |  881|  9.18k|#define SC_OPENPGP_KEYFORMAT_EC_STDPUB	0xFF
  ------------------
  |  Branch (670:8): [True: 2.78k, False: 6.40k]
  ------------------
  671|  2.78k|				if (blob->len < 3)
  ------------------
  |  Branch (671:9): [True: 510, False: 2.27k]
  ------------------
  672|    510|					return SC_ERROR_INCORRECT_PARAMETERS;
  ------------------
  |  |   55|    510|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
  673|  2.27k|				key_info->u.ec.oidv_len = blob->len - 2;
  674|  2.27k|				key_info->u.ec.keyformat = SC_OPENPGP_KEYFORMAT_EC_STDPUB;
  ------------------
  |  |  881|  2.27k|#define SC_OPENPGP_KEYFORMAT_EC_STDPUB	0xFF
  ------------------
  675|  2.27k|			}
  676|  6.40k|			else {
  677|       |				/* otherwise, last byte could be 00, so let's ignore it, as
  678|       |				 * it is not part of OID */
  679|  6.40k|				if (blob->len < 2)
  ------------------
  |  Branch (679:9): [True: 1.34k, False: 5.05k]
  ------------------
  680|  1.34k|					return SC_ERROR_INCORRECT_PARAMETERS;
  ------------------
  |  |   55|  1.34k|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
  681|  5.05k|				if (blob->data[blob->len-1] == SC_OPENPGP_KEYFORMAT_EC_STD)
  ------------------
  |  |  880|  5.05k|#define SC_OPENPGP_KEYFORMAT_EC_STD	0
  ------------------
  |  Branch (681:9): [True: 621, False: 4.43k]
  ------------------
  682|    621|					key_info->u.ec.oidv_len = blob->len - 2;
  683|  4.43k|				else
  684|  4.43k|					key_info->u.ec.oidv_len = blob->len - 1;
  685|  5.05k|				key_info->u.ec.keyformat = SC_OPENPGP_KEYFORMAT_EC_STD;
  ------------------
  |  |  880|  5.05k|#define SC_OPENPGP_KEYFORMAT_EC_STD	0
  ------------------
  686|  5.05k|			}
  687|       |
  688|       |			/* Create copy of oid from blob */
  689|  7.33k|			sc_init_oid(&oid);
  690|  7.33k|			r = sc_asn1_decode_object_id(&blob->data[1], key_info->u.ec.oidv_len, &oid);
  691|       |
  692|       |			/* decoding failed, return sc_asn1_decode_object_id error code */
  693|  7.33k|			if (r > 0){
  ------------------
  |  Branch (693:8): [True: 2.51k, False: 4.81k]
  ------------------
  694|  2.51k|				return r;
  695|  2.51k|			}
  696|       |			/* compare with list of supported ec_curves */
  697|  30.6k|			for (j = 0; priv->ec_curves[j].oid.value[0] >= 0; j++) {
  ------------------
  |  Branch (697:16): [True: 29.3k, False: 1.26k]
  ------------------
  698|  29.3k|				if (sc_compare_oid(&priv->ec_curves[j].oid, &oid)) {
  ------------------
  |  Branch (698:9): [True: 3.55k, False: 25.8k]
  ------------------
  699|  3.55k|					sc_log(card->ctx, "Matched EC oid %s (%d)",
  ------------------
  |  |   71|  3.55k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  700|  3.55k|						sc_dump_oid(&oid), j);
  701|  3.55k|					key_info->u.ec.oid = priv->ec_curves[j].oid;
  702|  3.55k|					key_info->u.ec.key_length = priv->ec_curves[j].size;
  703|  3.55k|					break;
  704|  3.55k|				}
  705|  29.3k|			}
  706|       |			/* We did not match the OID */
  707|  4.81k|			if (priv->ec_curves[j].oid.value[0] < 0) {
  ------------------
  |  Branch (707:8): [True: 1.26k, False: 3.55k]
  ------------------
  708|  1.26k|				LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|  1.26k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.26k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.26k|	int _ret = r; \
  |  |  |  |  155|  1.26k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.26k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.26k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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.26k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.26k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.26k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.26k|	} else { \
  |  |  |  |  159|      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.26k|	return _ret; \
  |  |  |  |  163|  1.26k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  709|  1.26k|			}
  710|  3.55k|			break;
  711|  3.55k|		default:
  ------------------
  |  Branch (711:3): [True: 2.08k, False: 12.6k]
  ------------------
  712|  2.08k|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|  2.08k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.08k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.08k|	int _ret = r; \
  |  |  |  |  155|  2.08k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.08k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.08k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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.08k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.08k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.08k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.08k|	} else { \
  |  |  |  |  159|      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.08k|	return _ret; \
  |  |  |  |  163|  2.08k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  713|  14.7k|	}
  714|       |
  715|  4.65k|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|  4.65k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  4.65k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  4.65k|	int _ret = r; \
  |  |  |  |  155|  4.65k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4.65k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  4.65k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 4.65k]
  |  |  |  |  ------------------
  |  |  |  |  157|  4.65k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  4.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|  4.65k|	return _ret; \
  |  |  |  |  163|  4.65k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  716|  4.65k|}
card-openpgp.c:pgp_get_card_features:
  909|    883|{
  910|    883|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|    883|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
  911|    883|	u8 *hist_bytes = card->reader->atr_info.hist_bytes;
  912|    883|	size_t hist_bytes_len = card->reader->atr_info.hist_bytes_len;
  913|    883|	unsigned int i;
  914|    883|	pgp_blob_t *blob, *blob6e, *blob73, *blobfa;
  915|    883|	int handled_algos = 0;
  916|       |
  917|    883|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    883|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    883|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    883|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    883|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 883]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  918|       |
  919|       |	/* parse card capabilities from historical bytes in ATR */
  920|    883|	if (hist_bytes_len > 0) {
  ------------------
  |  Branch (920:6): [True: 296, False: 587]
  ------------------
  921|       |		/* category indicator 0x00, 0x10 or 0x80 => compact TLV (ISO) */
  922|    296|		switch (hist_bytes[0]) {
  ------------------
  |  Branch (922:11): [True: 211, False: 85]
  ------------------
  923|    192|			case 0x00:
  ------------------
  |  Branch (923:4): [True: 192, False: 104]
  ------------------
  924|    192|				if (hist_bytes_len > 4) {
  ------------------
  |  Branch (924:9): [True: 51, False: 141]
  ------------------
  925|     51|					pgp_parse_hist_bytes(card, hist_bytes+1, hist_bytes_len-4);
  926|     51|				}
  927|    192|				break;
  928|     15|			case 0x80:
  ------------------
  |  Branch (928:4): [True: 15, False: 281]
  ------------------
  929|     15|				if (hist_bytes_len > 1) {
  ------------------
  |  Branch (929:9): [True: 14, False: 1]
  ------------------
  930|     14|					pgp_parse_hist_bytes(card, hist_bytes+1, hist_bytes_len-1);
  931|     14|				}
  932|     15|				break;
  933|      4|			case 0x10:
  ------------------
  |  Branch (933:4): [True: 4, False: 292]
  ------------------
  934|      4|				if (hist_bytes_len > 2) {
  ------------------
  |  Branch (934:9): [True: 3, False: 1]
  ------------------
  935|      3|					pgp_parse_hist_bytes(card, hist_bytes+2, hist_bytes_len-2);
  936|      3|				}
  937|      4|				break;
  938|    296|		}
  939|    296|	}
  940|       |
  941|       |	/* v1.1 does not support lifecycle via ACTIVATE & TERMINATE: set default */
  942|    883|	priv->ext_caps &= ~EXT_CAP_LCS;
  943|       |
  944|    883|	if (priv->bcd_version >= OPENPGP_CARD_2_0) {
  ------------------
  |  Branch (944:6): [True: 765, False: 118]
  ------------------
  945|       |		/* get card capabilities from "historical bytes" DO */
  946|    765|		if ((pgp_get_blob(card, priv->mf, 0x5f52, &blob) >= 0) &&
  ------------------
  |  Branch (946:7): [True: 765, False: 0]
  ------------------
  947|    765|		    (blob->data != NULL) && (blob->data[0] == 0x00)) {
  ------------------
  |  Branch (947:7): [True: 43, False: 722]
  |  Branch (947:31): [True: 34, False: 9]
  ------------------
  948|       |
  949|     34|			if (blob->len > 4) {
  ------------------
  |  Branch (949:8): [True: 30, False: 4]
  ------------------
  950|     30|				pgp_parse_hist_bytes(card, blob->data+1, blob->len-4);
  951|     30|			}
  952|       |
  953|       |			/* get card status from historical bytes status indicator */
  954|     34|			if ((blob->data[0] == 0x00) && (blob->len >= 4)) {
  ------------------
  |  Branch (954:8): [True: 34, False: 0]
  |  Branch (954:35): [True: 32, False: 2]
  ------------------
  955|     32|				priv->state = blob->data[blob->len-3];
  956|       |				/* state not CARD_STATE_UNKNOWN => LCS supported */
  957|     32|				if (priv->state != CARD_STATE_UNKNOWN)
  ------------------
  |  Branch (957:9): [True: 26, False: 6]
  ------------------
  958|     26|					priv->ext_caps |= EXT_CAP_LCS;
  959|     32|			}
  960|     34|		}
  961|    765|	}
  962|       |
  963|    883|	if (priv->bcd_version >= OPENPGP_CARD_3_1) {
  ------------------
  |  Branch (963:6): [True: 725, False: 158]
  ------------------
  964|    725|		card->caps |= SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  553|    725|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
  965|    725|	}
  966|       |
  967|    883|	if (priv->bcd_version >= OPENPGP_CARD_3_4) {
  ------------------
  |  Branch (967:6): [True: 724, False: 159]
  ------------------
  968|       |		/* Parse supported algorithms from Algorithm Information DO
  969|       |		 * see OpenPGP card spec 3.4 section 4.4.3.11 */
  970|    724|		if (pgp_get_blob(card, priv->mf, 0x00fa, &blobfa) >= 0) {
  ------------------
  |  Branch (970:7): [True: 724, False: 0]
  ------------------
  971|    724|			pgp_blob_t *child;
  972|    724|			pgp_enumerate_blob(card, blobfa);
  973|       |			/* There will be multiple children with the same ID, but
  974|       |			 * different algos, so we need to iterate over all of them */
  975|  32.1k|			for (child = blobfa->files; child; child = child->next) {
  ------------------
  |  Branch (975:32): [True: 31.4k, False: 724]
  ------------------
  976|  31.4k|				if ((child->id < 0x00c1) || (child->id > 0x00c3))
  ------------------
  |  Branch (976:9): [True: 13.6k, False: 17.7k]
  |  Branch (976:33): [True: 1.19k, False: 16.5k]
  ------------------
  977|  14.8k|					continue;
  978|  16.5k|				sc_cardctl_openpgp_key_gen_store_info_t key_info;
  979|  16.5k|				if (pgp_parse_algo_attr_blob(card, child, &key_info) >= 0)
  ------------------
  |  Branch (979:9): [True: 4.64k, False: 11.9k]
  ------------------
  980|  4.64k|					handled_algos += _pgp_add_algo(card, &key_info, 0x00fa);
  981|  16.5k|			}
  982|    724|		}
  983|    724|	}
  984|       |
  985|       |	/* v1.1 & v2.x: special DOs are limited to 254 bytes */
  986|    883|	priv->max_specialDO_size = 254;
  987|       |
  988|    883|	if ((pgp_get_blob(card, priv->mf, 0x006e, &blob6e) >= 0) &&
  ------------------
  |  Branch (988:6): [True: 883, False: 0]
  ------------------
  989|    883|	    (pgp_get_blob(card, blob6e, 0x0073, &blob73) >= 0)) {
  ------------------
  |  Branch (989:6): [True: 328, False: 555]
  ------------------
  990|       |
  991|       |		/* get "extended capabilities" DO */
  992|    328|		if ((pgp_get_blob(card, blob73, 0x00c0, &blob) >= 0) &&
  ------------------
  |  Branch (992:7): [True: 297, False: 31]
  ------------------
  993|    297|		    (blob->data != NULL) && (blob->len > 0)) {
  ------------------
  |  Branch (993:7): [True: 296, False: 1]
  |  Branch (993:31): [True: 296, False: 0]
  ------------------
  994|    296|			if ((blob->data[0] & 0x01) && (priv->bcd_version >= OPENPGP_CARD_3_3)) {
  ------------------
  |  Branch (994:8): [True: 33, False: 263]
  |  Branch (994:34): [True: 19, False: 14]
  ------------------
  995|     19|				priv->ext_caps |= EXT_CAP_KDF_DO;
  996|     19|			}
  997|       |			/* v2.0+: bit 0x04 in first byte means "algorithm attributes changeable" */
  998|    296|			if ((blob->data[0] & 0x04) &&
  ------------------
  |  Branch (998:8): [True: 287, False: 9]
  ------------------
  999|    287|					(priv->bcd_version >= OPENPGP_CARD_2_0))
  ------------------
  |  Branch (999:6): [True: 284, False: 3]
  ------------------
 1000|    284|				priv->ext_caps |= EXT_CAP_ALG_ATTR_CHANGEABLE;
 1001|       |			/* bit 0x08 in first byte means "support for private use DOs" */
 1002|    296|			if (blob->data[0] & 0x08)
  ------------------
  |  Branch (1002:8): [True: 32, False: 264]
  ------------------
 1003|     32|				priv->ext_caps |= EXT_CAP_PRIVATE_DO;
 1004|       |			/* bit 0x10 in first byte means "support for CHV status byte changeable" */
 1005|    296|			if (blob->data[0] & 0x10)
  ------------------
  |  Branch (1005:8): [True: 59, False: 237]
  ------------------
 1006|     59|				priv->ext_caps |= EXT_CAP_C4_CHANGEABLE;
 1007|       |			/* bit 0x20 in first byte means "support for Key Import" */
 1008|    296|			if (blob->data[0] & 0x20)
  ------------------
  |  Branch (1008:8): [True: 65, False: 231]
  ------------------
 1009|     65|				priv->ext_caps |= EXT_CAP_KEY_IMPORT;
 1010|       |			/* bit 0x40 in first byte means "support for Get Challenge" */
 1011|    296|			if (blob->data[0] & 0x40) {
  ------------------
  |  Branch (1011:8): [True: 20, False: 276]
  ------------------
 1012|     20|				card->caps |= SC_CARD_CAP_RNG;
  ------------------
  |  |  550|     20|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
 1013|     20|				priv->ext_caps |= EXT_CAP_GET_CHALLENGE;
 1014|     20|			}
 1015|       |			/* v2.0+: bit 0x80 in first byte means "support Secure Messaging" */
 1016|    296|			if ((blob->data[0] & 0x80) &&
  ------------------
  |  Branch (1016:8): [True: 57, False: 239]
  ------------------
 1017|     57|					(priv->bcd_version >= OPENPGP_CARD_2_0))
  ------------------
  |  Branch (1017:6): [True: 54, False: 3]
  ------------------
 1018|     54|				priv->ext_caps |= EXT_CAP_SM;
 1019|       |
 1020|    296|			if ((priv->bcd_version >= OPENPGP_CARD_2_0) && (blob->len >= 10)) {
  ------------------
  |  Branch (1020:8): [True: 291, False: 5]
  |  Branch (1020:51): [True: 288, False: 3]
  ------------------
 1021|       |				/* v2.0+: max. challenge size is at bytes 3-4 */
 1022|    288|				priv->max_challenge_size = bebytes2ushort(blob->data + 2);
 1023|       |				/* v2.0+: max. cert size it at bytes 5-6 */
 1024|    288|				priv->max_cert_size = bebytes2ushort(blob->data + 4);
 1025|       |
 1026|    288|				if (priv->bcd_version < OPENPGP_CARD_3_0) {
  ------------------
  |  Branch (1026:9): [True: 12, False: 276]
  ------------------
 1027|       |					/* v2.x: SM algorithm is at byte 2: 0 == 3DES */
 1028|     12|					priv->sm_algo = blob->data[1];
 1029|     12|					if ((priv->sm_algo == SM_ALGO_NONE) && (priv->ext_caps & EXT_CAP_SM))
  ------------------
  |  Branch (1029:10): [True: 7, False: 5]
  |  Branch (1029:45): [True: 1, False: 6]
  ------------------
 1030|      1|						priv->sm_algo = SM_ALGO_3DES;
 1031|       |
 1032|       |					/* v2.x: max. send/receive sizes are at bytes 7-8 resp. 9-10 */
 1033|     12|					card->max_send_size = bebytes2ushort(blob->data + 6);
 1034|     12|					card->max_recv_size = bebytes2ushort(blob->data + 8);
 1035|     12|				}
 1036|    276|				else {
 1037|       |					/* v3.0+: SM algorithm is at byte 2: 0 == UNKNOWN */
 1038|    276|					priv->sm_algo = blob->data[1];
 1039|    276|					if ((priv->sm_algo == SM_ALGO_NONE) && (priv->ext_caps & EXT_CAP_SM))
  ------------------
  |  Branch (1039:10): [True: 119, False: 157]
  |  Branch (1039:45): [True: 4, False: 115]
  ------------------
 1040|      4|						priv->sm_algo = SM_ALGO_UNKNOWN;
 1041|       |
 1042|       |					/* v3.0+: max. size of special DOs is at bytes 7-8 */
 1043|    276|					priv->max_specialDO_size = bebytes2ushort(blob->data + 6);
 1044|    276|				}
 1045|    288|				if (priv->bcd_version >= OPENPGP_CARD_3_3 && (blob->len >= 10)) {
  ------------------
  |  Branch (1045:9): [True: 273, False: 15]
  |  Branch (1045:50): [True: 273, False: 0]
  ------------------
 1046|       |					/* v3.3+: MSE for key numbers 2(DEC) and 3(AUT) supported */
 1047|    273|					if (blob->data[9])
  ------------------
  |  Branch (1047:10): [True: 149, False: 124]
  ------------------
 1048|    149|						priv->ext_caps |= EXT_CAP_MSE;
 1049|    273|				}
 1050|    288|			}
 1051|    296|		}
 1052|       |
 1053|       |		/* get max. PIN length from "CHV status bytes" DO */
 1054|    328|		if ((pgp_get_blob(card, blob73, 0x00c4, &blob) >= 0) &&
  ------------------
  |  Branch (1054:7): [True: 99, False: 229]
  ------------------
 1055|     99|			(blob->data != NULL) && (blob->len > 1)) {
  ------------------
  |  Branch (1055:4): [True: 75, False: 24]
  |  Branch (1055:28): [True: 72, False: 3]
  ------------------
 1056|       |			/* 2nd byte in "CHV status bytes" DO means "max. PIN length" */
 1057|     72|			card->max_pin_len = blob->data[1];
 1058|     72|		}
 1059|       |
 1060|    328|		if (priv->bcd_version >= OPENPGP_CARD_3_0) {
  ------------------
  |  Branch (1060:7): [True: 299, False: 29]
  ------------------
 1061|       |			/* v3.0+: get length info from "extended length information" DO */
 1062|    299|			if ((pgp_get_blob(card, blob6e, 0x7f66, &blob) >= 0) &&
  ------------------
  |  Branch (1062:8): [True: 2, False: 297]
  ------------------
 1063|      2|				(blob->data != NULL) && (blob->len >= 8)) {
  ------------------
  |  Branch (1063:5): [True: 1, False: 1]
  |  Branch (1063:29): [True: 1, False: 0]
  ------------------
 1064|       |				/* kludge: treat as SIMPLE DO and use appropriate offsets */
 1065|      1|				card->max_send_size = bebytes2ushort(blob->data + 2);
 1066|      1|				card->max_recv_size = bebytes2ushort(blob->data + 6);
 1067|      1|			}
 1068|    299|		}
 1069|       |
 1070|    328|#ifdef ENABLE_OPENSSL
 1071|    328|		if (priv->ext_caps & EXT_CAP_KDF_DO) {
  ------------------
  |  Branch (1071:7): [True: 19, False: 309]
  ------------------
 1072|     19|			int r = pgp_decode_kdf_do(card, priv);
 1073|     19|			if (r != SC_SUCCESS) {
  ------------------
  |  |   28|     19|#define SC_SUCCESS				0
  ------------------
  |  Branch (1073:8): [True: 17, False: 2]
  ------------------
 1074|     17|				sc_log(card->ctx, "Failed to decode KDF DO: %s", sc_strerror(r));
  ------------------
  |  |   71|     17|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1075|     17|			}
 1076|     19|		}
 1077|    328|#endif /* ENABLE_OPENSSL */
 1078|       |
 1079|       |		/* if we found at least one usable algo, let's skip other ways to find them */
 1080|    328|		if (handled_algos) {
  ------------------
  |  Branch (1080:7): [True: 3, False: 325]
  ------------------
 1081|      3|			sc_log(card->ctx, "Algo list populated from Algorithm Information DO");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1082|      3|			LOG_FUNC_RETURN(card->ctx, handled_algos);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1083|      3|		}
 1084|       |
 1085|       |		/* get _current_ algorithms & key lengths from "algorithm attributes" DOs
 1086|       |		 *
 1087|       |		 * All available algorithms should be already provided by pgp_init. However, if another
 1088|       |		 * algorithm is found in the "algorithm attributes" DOs, it is supported by the card as
 1089|       |		 * well and therefore added
 1090|       |		 * see OpenPGP card spec 1.1 & 2.x section 4.3.3.6 / v3.x section 4.4.3.7 */
 1091|  1.30k|		for (i = 0x00c1; i <= 0x00c3; i++) {
  ------------------
  |  Branch (1091:20): [True: 975, False: 325]
  ------------------
 1092|    975|			sc_cardctl_openpgp_key_gen_store_info_t key_info;
 1093|       |
 1094|    975|			sc_log(card->ctx, "Parsing algorithm attributes DO %uX" , i);
  ------------------
  |  |   71|    975|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1095|       |
 1096|       |			/* OpenPGP card spec 1.1 & 2.x section 4.3.3.6 / v3.x section 4.4.3.7 */
 1097|    975|			if ((pgp_get_blob(card, blob73, i, &blob) >= 0) &&
  ------------------
  |  Branch (1097:8): [True: 203, False: 772]
  ------------------
 1098|    203|			    (pgp_parse_algo_attr_blob(card, blob, &key_info) >= 0)) {
  ------------------
  |  Branch (1098:8): [True: 1, False: 202]
  ------------------
 1099|      1|				if (!_pgp_add_algo(card, &key_info, i))
  ------------------
  |  Branch (1099:9): [True: 0, False: 1]
  ------------------
 1100|      1|					LOG_TEST_RET(card->ctx, SC_ERROR_INTERNAL, "Cannot add algorithm");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1101|      1|			}
 1102|    975|		}
 1103|       |
 1104|    325|	}
 1105|       |
 1106|    880|	LOG_FUNC_RETURN(card->ctx, handled_algos);
  ------------------
  |  |  164|    880|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    880|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    880|	int _ret = r; \
  |  |  |  |  155|    880|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 747, False: 133]
  |  |  |  |  ------------------
  |  |  |  |  156|    747|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 747]
  |  |  |  |  ------------------
  |  |  |  |  157|    747|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    747|	} 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|    880|	return _ret; \
  |  |  |  |  163|    880|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1107|    880|}
card-openpgp.c:pgp_parse_hist_bytes:
  604|     98|{
  605|     98|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|     98|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
  606|     98|	const u8 *ptr;
  607|       |
  608|       |	/* IS07816-4 hist bytes: 3rd function table */
  609|     98|	if ((ptr = sc_compacttlv_find_tag(ctlv, ctlv_len, 0x73, NULL)) != NULL) {
  ------------------
  |  Branch (609:6): [True: 69, False: 29]
  ------------------
  610|       |		/* bit 0x40 in byte 3 of TL 0x73 means "extended Le/Lc" */
  611|     69|		if (ptr[2] & 0x40) {
  ------------------
  |  Branch (611:7): [True: 28, False: 41]
  ------------------
  612|     28|			card->caps |= SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  547|     28|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  613|     28|			priv->ext_caps |= EXT_CAP_APDU_EXT;
  614|     28|		}
  615|       |		/* bit 0x80 in byte 3 of TL 0x73 means "Command chaining" */
  616|     69|		if (ptr[2] & 0x80) {
  ------------------
  |  Branch (616:7): [True: 53, False: 16]
  ------------------
  617|     53|			priv->ext_caps |= EXT_CAP_CHAINING;
  618|     53|		}
  619|     69|	}
  620|       |
  621|     98|	if ((priv->bcd_version >= OPENPGP_CARD_3_0) &&
  ------------------
  |  Branch (621:6): [True: 66, False: 32]
  ------------------
  622|     66|	    ((ptr = sc_compacttlv_find_tag(ctlv, ctlv_len, 0x31, NULL)) != NULL)) {
  ------------------
  |  Branch (622:6): [True: 20, False: 46]
  ------------------
  623|       |		// ToDo ...
  624|     20|	}
  625|     98|}
card-openpgp.c:pgp_decode_kdf_do:
  805|     19|{
  806|     19|	pgp_pin_kdf_info_t *pin_kdf_info = (pgp_pin_kdf_info_t *)calloc(1, sizeof(pgp_pin_kdf_info_t));
  807|     19|	int r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|     19|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  808|     19|	pgp_blob_t *kdf_blob;
  809|     19|	const uint8_t *data;
  810|     19|	size_t data_len;
  811|     19|	size_t tag_len;
  812|     19|	const uint8_t *p;
  813|     19|	pgp_blob_t *blob;
  814|       |
  815|     19|	if (!pin_kdf_info) {
  ------------------
  |  Branch (815:6): [True: 0, False: 19]
  ------------------
  816|      0|		return r;
  817|      0|	}
  818|       |
  819|     19|	r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|     19|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  820|     19|	priv->pin_kdf_info = NULL;
  821|     19|	if ((pgp_get_blob(card, priv->mf, DO_KDF, &kdf_blob) != SC_SUCCESS) || (kdf_blob->len < 3)) {
  ------------------
  |  |  159|     19|#define DO_KDF                   0xf9
  ------------------
              	if ((pgp_get_blob(card, priv->mf, DO_KDF, &kdf_blob) != SC_SUCCESS) || (kdf_blob->len < 3)) {
  ------------------
  |  |   28|     19|#define SC_SUCCESS				0
  ------------------
  |  Branch (821:6): [True: 0, False: 19]
  |  Branch (821:73): [True: 5, False: 14]
  ------------------
  822|      5|		sc_log(card->ctx, "KDF DO does not exists or contains invalid data but card claims to support it");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  823|      5|		goto out;
  824|      5|	}
  825|       |
  826|     14|	data = kdf_blob->data;
  827|     14|	data_len = kdf_blob->len;
  828|     14|	p = sc_asn1_find_tag(card->ctx, data, data_len, 0x81, &tag_len);
  829|     14|	if (!p) {
  ------------------
  |  Branch (829:6): [True: 2, False: 12]
  ------------------
  830|      2|		sc_log(card->ctx, "KDF algorithm byte not found");
  ------------------
  |  |   71|      2|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  831|      2|		goto out;
  832|      2|	}
  833|     12|	if (tag_len != 1) {
  ------------------
  |  Branch (833:6): [True: 1, False: 11]
  ------------------
  834|      1|		sc_log(card->ctx, "Unexpected KDF algorithm byte length, expects 1, got %zu", tag_len);
  ------------------
  |  |   71|      1|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  835|      1|		goto out;
  836|      1|	}
  837|       |
  838|     11|	if (*p != 0x3) {
  ------------------
  |  Branch (838:6): [True: 2, False: 9]
  ------------------
  839|      2|		if (*p == 0x0) {
  ------------------
  |  Branch (839:7): [True: 1, False: 1]
  ------------------
  840|      1|			r = SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
  841|      1|			sc_log(card->ctx, "KDF derived PIN format disabled");
  ------------------
  |  |   71|      1|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  842|      1|		} else {
  843|      1|			sc_log(card->ctx, "Unknown KDF algorithm ID %x", *p);
  ------------------
  |  |   71|      1|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  844|      1|		}
  845|      2|		goto out;
  846|      2|	}
  847|       |
  848|      9|	p = sc_asn1_find_tag(card->ctx, data, data_len, 0x82, &tag_len);
  849|      9|	if (!p) {
  ------------------
  |  Branch (849:6): [True: 1, False: 8]
  ------------------
  850|      1|		sc_log(card->ctx, "KDF hash algorithm byte not found");
  ------------------
  |  |   71|      1|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  851|      1|		goto out;
  852|      1|	}
  853|      8|	if (tag_len != 1) {
  ------------------
  |  Branch (853:6): [True: 1, False: 7]
  ------------------
  854|      1|		sc_log(card->ctx, "Unexpected KDF hash algorithm byte length, expects 1, got %zu", tag_len);
  ------------------
  |  |   71|      1|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  855|      1|		goto out;
  856|      1|	}
  857|       |
  858|      7|	switch (*p) {
  859|      5|	case 0x08:
  ------------------
  |  Branch (859:2): [True: 5, False: 2]
  ------------------
  860|      5|		pin_kdf_info->hash_algo = "SHA256";
  861|      5|		break;
  862|      1|	case 0x0A:
  ------------------
  |  Branch (862:2): [True: 1, False: 6]
  ------------------
  863|      1|		pin_kdf_info->hash_algo = "SHA512";
  864|      1|		break;
  865|      1|	default:
  ------------------
  |  Branch (865:2): [True: 1, False: 6]
  ------------------
  866|      1|		sc_log(card->ctx, "Unknown KDF hash algorithm ID %x", *p);
  ------------------
  |  |   71|      1|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  867|      1|		goto out;
  868|      7|	}
  869|       |
  870|      6|	p = sc_asn1_find_tag(card->ctx, data, data_len, 0x83, &tag_len);
  871|      6|	if (!p) {
  ------------------
  |  Branch (871:6): [True: 1, False: 5]
  ------------------
  872|      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__
  |  |  ------------------
  ------------------
  873|      1|		goto out;
  874|      1|	}
  875|      5|	if (tag_len != 4) {
  ------------------
  |  Branch (875:6): [True: 2, False: 3]
  ------------------
  876|      2|		sc_log(card->ctx, "Unexpected KDF iteration count length, expects 4, got %zu", tag_len);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  877|      2|		goto out;
  878|      2|	}
  879|      3|	pin_kdf_info->iterations = (uint32_t)bebytes2ulong(p);
  880|       |
  881|      3|	r = pgp_get_blob(card, kdf_blob, 0x84, &blob);
  882|      3|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|      3|#define SC_SUCCESS				0
  ------------------
  |  Branch (882:6): [True: 1, False: 2]
  ------------------
  883|      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__
  |  |  ------------------
  ------------------
  884|      1|		goto out;
  885|      1|	}
  886|      2|	pin_kdf_info->userpw_salt = blob;
  887|       |
  888|      2|	r = pgp_get_blob(card, kdf_blob, 0x86, &blob);
  889|      2|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|      2|#define SC_SUCCESS				0
  ------------------
  |  Branch (889:6): [True: 1, False: 1]
  ------------------
  890|      1|		sc_log(card->ctx, "Failed to get salt bytes of admin password");
  ------------------
  |  |   71|      1|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  891|      1|		goto out;
  892|      1|	}
  893|      1|	pin_kdf_info->adminpw_salt = blob;
  894|       |
  895|      1|	sc_log(card->ctx, "KDF derived PIN format enabled");
  ------------------
  |  |   71|      1|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  896|      1|	priv->pin_kdf_info = pin_kdf_info;
  897|      1|	return r;
  898|     18|out:
  899|     18|	free(pin_kdf_info);
  900|     18|	return r;
  901|      2|}
card-openpgp.c:pgp_finish:
 1115|    922|{
 1116|    922|	if (card != NULL) {
  ------------------
  |  Branch (1116:6): [True: 922, False: 0]
  ------------------
 1117|    922|		struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|    922|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 1118|       |
 1119|    922|		if (priv != NULL) {
  ------------------
  |  Branch (1119:7): [True: 922, False: 0]
  ------------------
 1120|       |			/* delete fake file hierarchy */
 1121|    922|			pgp_free_blobs(priv->mf);
 1122|       |
 1123|       |			/* delete kdf do related data if exists */
 1124|    922|			free(priv->pin_kdf_info);
 1125|       |
 1126|       |			/* delete private data */
 1127|    922|			free(priv);
 1128|    922|		}
 1129|    922|		card->drv_data = NULL;
 1130|    922|	}
 1131|    922|	return SC_SUCCESS;
  ------------------
  |  |   28|    922|#define SC_SUCCESS				0
  ------------------
 1132|    922|}
card-openpgp.c:pgp_free_blobs:
 1328|  60.4k|{
 1329|  60.4k|	if (blob) {
  ------------------
  |  Branch (1329:6): [True: 60.3k, False: 39]
  ------------------
 1330|  60.3k|		pgp_blob_t *child = blob->files;
 1331|       |
 1332|   119k|		while (child != NULL) {
  ------------------
  |  Branch (1332:10): [True: 59.4k, False: 60.3k]
  ------------------
 1333|  59.4k|			pgp_blob_t *next = child->next;
 1334|       |
 1335|  59.4k|			pgp_free_blobs(child);
 1336|  59.4k|			child = next;
 1337|  59.4k|		}
 1338|  60.3k|		pgp_free_blob(blob);
 1339|  60.3k|	}
 1340|  60.4k|}
card-openpgp.c:pgp_free_blob:
 1303|  60.3k|{
 1304|  60.3k|	if (blob) {
  ------------------
  |  Branch (1304:6): [True: 60.3k, False: 0]
  ------------------
 1305|  60.3k|		if (blob->parent) {
  ------------------
  |  Branch (1305:7): [True: 59.4k, False: 883]
  ------------------
 1306|  59.4k|			pgp_blob_t **p;
 1307|       |
 1308|       |			/* remove blob from list of parent's children */
 1309|  59.4k|			for (p = &blob->parent->files; *p != NULL && *p != blob; p = &(*p)->next)
  ------------------
  |  Branch (1309:35): [True: 59.4k, False: 0]
  |  Branch (1309:49): [True: 0, False: 59.4k]
  ------------------
 1310|      0|				;
 1311|  59.4k|			if (*p == blob)
  ------------------
  |  Branch (1311:8): [True: 59.4k, False: 0]
  ------------------
 1312|  59.4k|				*p = blob->next;
 1313|  59.4k|		}
 1314|       |
 1315|  60.3k|		sc_file_free(blob->file);
 1316|  60.3k|		if (blob->data)
  ------------------
  |  Branch (1316:7): [True: 25.0k, False: 35.2k]
  ------------------
 1317|  25.0k|			free(blob->data);
 1318|  60.3k|		free(blob);
 1319|  60.3k|	}
 1320|  60.3k|}
card-openpgp.c:pgp_select_file:
 1614|  5.55k|{
 1615|  5.55k|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|  5.55k|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 1616|  5.55k|	pgp_blob_t	*blob;
 1617|  5.55k|	unsigned int	path_start = 0;
 1618|  5.55k|	unsigned int	n;
 1619|  5.55k|	sc_path_t dummy_path;
 1620|       |
 1621|  5.55k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  5.55k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  5.55k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  5.55k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  5.55k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 5.55k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1622|       |
 1623|  5.55k|	if (path->type == SC_PATH_TYPE_DF_NAME)
  ------------------
  |  |  118|  5.55k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (1623:6): [True: 1.66k, False: 3.88k]
  ------------------
 1624|  5.55k|		LOG_FUNC_RETURN(card->ctx, iso_ops->select_file(card, path, ret));
  ------------------
  |  |  164|  1.66k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.66k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.66k|	int _ret = r; \
  |  |  |  |  155|  1.66k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.66k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.66k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    992|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 992, False: 673]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.66k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.66k|	} else { \
  |  |  |  |  159|      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.66k|	return _ret; \
  |  |  |  |  163|  1.66k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1625|       |
 1626|  3.88k|	if (path->len < 2 || (path->len & 1))
  ------------------
  |  Branch (1626:6): [True: 0, False: 3.88k]
  |  Branch (1626:23): [True: 0, False: 3.88k]
  ------------------
 1627|  3.88k|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS,
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1628|  3.88k|				"invalid path length");
 1629|       |
 1630|  3.88k|	if (path->type == SC_PATH_TYPE_FILE_ID && path->len != 2)
  ------------------
  |  |  117|  7.77k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (1630:6): [True: 0, False: 3.88k]
  |  Branch (1630:44): [True: 0, False: 0]
  ------------------
 1631|  3.88k|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS,
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1632|  3.88k|				"invalid path type");
 1633|       |
 1634|       |	/* Due to pkcs15init implementation, sometimes a file at path "11001101"
 1635|       |	 * need to be written (one use case is when importing key&cert from p12 file).
 1636|       |	 * This file does not exist in OpenPGP but pkcs15 requires that
 1637|       |	 * writing this file must be successful.
 1638|       |	 * So, we pretend that selecting & writing this file is successful.
 1639|       |	 * The "11001101"is defined in sc_pkcs15emu_get_df() function, pkcs15-sync.c file. */
 1640|  3.88k|	sc_format_path("11001101", &dummy_path);
 1641|  3.88k|	if (sc_compare_path(path, &dummy_path)) {
  ------------------
  |  Branch (1641:6): [True: 0, False: 3.88k]
  ------------------
 1642|      0|		if (ret != NULL) {
  ------------------
  |  Branch (1642:7): [True: 0, False: 0]
  ------------------
 1643|      0|			*ret = sc_file_new();
 1644|       |			/* One use case of this dummy file is after writing certificate in pkcs15init.
 1645|       |			 * So we set its size to be the same as max certificate size the card supports. */
 1646|      0|			(*ret)->size = priv->max_cert_size;
 1647|      0|		}
 1648|      0|		LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1649|      0|	}
 1650|       |
 1651|       |	/* ignore explicitly mentioned MF at the path's beginning */
 1652|  3.88k|	path_start = pgp_strip_path(card, path);
 1653|       |
 1654|       |	/* starting with the MF ... */
 1655|  3.88k|	blob = priv->mf;
 1656|       |	/* ... recurse through the tree following the path */
 1657|  5.61k|	for (n = path_start; n < path->len; n += 2) {
  ------------------
  |  Branch (1657:23): [True: 4.37k, False: 1.24k]
  ------------------
 1658|  4.37k|		unsigned int	id = bebytes2ushort(path->value + n);
 1659|  4.37k|		int		r = pgp_get_blob(card, blob, id, &blob);
 1660|       |
 1661|       |		/* This file ID is referred when importing key&certificate via pkcs15init, like above.
 1662|       |		 * We pretend to successfully find this inexistent file. */
 1663|  4.37k|		if (id == 0x4402 || id == 0x5f48) {
  ------------------
  |  Branch (1663:7): [True: 0, False: 4.37k]
  |  Branch (1663:23): [True: 0, False: 4.37k]
  ------------------
 1664|      0|			if (ret == NULL)
  ------------------
  |  Branch (1664:8): [True: 0, False: 0]
  ------------------
 1665|       |				/* No need to return file */
 1666|      0|				LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1667|       |
 1668|       |			/* Else, need to return file */
 1669|      0|			*ret = sc_file_new();
 1670|      0|			(*ret)->size = priv->max_cert_size;
 1671|      0|			LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1672|      0|		}
 1673|       |
 1674|  4.37k|		if (r < 0) {	/* failure */
  ------------------
  |  Branch (1674:7): [True: 2.64k, False: 1.72k]
  ------------------
 1675|  2.64k|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  2.64k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.64k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.64k|	int _ret = r; \
  |  |  |  |  155|  2.64k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.64k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.64k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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.64k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.64k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.64k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.64k|	} else { \
  |  |  |  |  159|      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.64k|	return _ret; \
  |  |  |  |  163|  2.64k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1676|  2.64k|		}
 1677|  4.37k|	}
 1678|       |
 1679|       |	/* success: select file = set "current" pointer to blob found */
 1680|  1.24k|	priv->current = blob;
 1681|       |
 1682|  1.24k|	if (ret)
  ------------------
  |  Branch (1682:6): [True: 612, False: 632]
  ------------------
 1683|    612|		sc_file_dup(ret, blob->file);
 1684|       |
 1685|  1.24k|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|  1.24k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.24k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.24k|	int _ret = r; \
  |  |  |  |  155|  1.24k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.24k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.24k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, 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.24k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.24k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.24k|	} else { \
  |  |  |  |  159|      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.24k|	return _ret; \
  |  |  |  |  163|  1.24k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1686|  1.24k|}
card-openpgp.c:pgp_strip_path:
 1595|  3.88k|{
 1596|  3.88k|	unsigned int start_point = 0;
 1597|       |	/* start_point will move through the path string */
 1598|  3.88k|	if (path->len == 0)
  ------------------
  |  Branch (1598:6): [True: 0, False: 3.88k]
  ------------------
 1599|      0|		return 0;
 1600|       |
 1601|       |	/* ignore 3F00 (MF) at the beginning */
 1602|  3.88k|	start_point = (memcmp(path->value, "\x3f\x00", 2) == 0) ? 2 : 0;
  ------------------
  |  Branch (1602:16): [True: 2.49k, False: 1.39k]
  ------------------
 1603|       |	/* strip path of PKCS15-App DF (5015) */
 1604|  3.88k|	start_point += (memcmp(path->value + start_point, "\x50\x15", 2) == 0) ? 2 : 0;
  ------------------
  |  Branch (1604:17): [True: 2.14k, False: 1.74k]
  ------------------
 1605|  3.88k|	return start_point;
 1606|  3.88k|}
card-openpgp.c:pgp_read_binary:
 1755|    740|{
 1756|    740|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|    740|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 1757|    740|	pgp_blob_t	*blob;
 1758|    740|	int		r;
 1759|       |
 1760|    740|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    740|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    740|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    740|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    740|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 740]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1761|       |
 1762|       |	/* jump to selected file */
 1763|    740|	blob = priv->current;
 1764|       |
 1765|    740|	if (blob == NULL)
  ------------------
  |  Branch (1765:6): [True: 0, False: 740]
  ------------------
 1766|    740|		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|    740|	if (blob->file->type != SC_FILE_TYPE_WORKING_EF)
  ------------------
  |  |  216|    740|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (1768:6): [True: 0, False: 740]
  ------------------
 1769|    740|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_FILE_NOT_FOUND);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1770|       |
 1771|    740|	if ((r = pgp_read_blob(card, blob)) < 0)
  ------------------
  |  Branch (1771:6): [True: 263, False: 477]
  ------------------
 1772|    740|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    263|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    263|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    263|	int _ret = r; \
  |  |  |  |  155|    263|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 263, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    263|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    263|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 263, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    263|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    263|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    263|	return _ret; \
  |  |  |  |  163|    263|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1773|       |
 1774|    477|	if (idx > blob->len)
  ------------------
  |  Branch (1774:6): [True: 0, False: 477]
  ------------------
 1775|    477|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1776|       |
 1777|    477|	if (idx + count > blob->len)
  ------------------
  |  Branch (1777:6): [True: 76, False: 401]
  ------------------
 1778|     76|		count = blob->len - idx;
 1779|    477|	memcpy(buf, blob->data + idx, count);
 1780|       |
 1781|    477|	LOG_FUNC_RETURN(card->ctx, (int)count);
  ------------------
  |  |  164|    477|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    477|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    477|	int _ret = r; \
  |  |  |  |  155|    477|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 58, False: 419]
  |  |  |  |  ------------------
  |  |  |  |  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|    419|	} else { \
  |  |  |  |  159|    419|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    419|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    419|	} \
  |  |  |  |  162|    477|	return _ret; \
  |  |  |  |  163|    477|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1782|    477|}
card-openpgp.c:pgp_pin_cmd:
 2388|    355|{
 2389|    355|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|    355|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 2390|    355|	struct sc_card_operations ops = {.pin_cmd = iso_ops->pin_cmd};
 2391|       |
 2392|    355|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    355|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    355|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    355|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    355|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 355]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2393|       |
 2394|    355|	if (data->pin_type != SC_AC_CHV)
  ------------------
  |  |  151|    355|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (2394:6): [True: 0, False: 355]
  ------------------
 2395|    355|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS,
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2396|    355|				"invalid PIN type");
 2397|       |
 2398|       |	/* In general, the PIN Reference is extracted from the key-id,
 2399|       |	 * for example, CHV0 -> Ref=0, CHV1 -> Ref=1.
 2400|       |	 * However, in the case of OpenPGP, the PIN Ref to compose APDU
 2401|       |	 * must be 81, 82, 83.
 2402|       |	 * So, if we receive Ref=1, Ref=2, we must convert to 81, 82...
 2403|       |	 * In OpenPGP v1, the PINs are named CHV1, CHV2, CHV3.
 2404|       |	 * In v2, they are named PW1, PW3 (PW1 operates in 2 modes).
 2405|       |	 *
 2406|       |	 * The PIN references (P2 in APDU) for "VERIFY" are the same in both versions:
 2407|       |	 * 81 (CHV1 or PW1), 82 (CHV2 or PW1-mode 2), 83 (CHV3 or PW3),
 2408|       |	 * On the other hand from version 2.0 "CHANGE REFERENCE DATA" and
 2409|       |	 * "RESET RETRY COUNTER" don't support PW1-mode 2 (82) and need this
 2410|       |	 * value changed to PW1 (81).
 2411|       |	 * Both of these commands also differ between card versions in that
 2412|       |	 * v1 cards can use only implicit old PIN or CHV3 test for both commands
 2413|       |	 * whereas v2 can use both implicit (for PW3) and explicit
 2414|       |	 * (for special "Resetting Code") PIN test for "RESET RETRY COUNTER"
 2415|       |	 * and only explicit test for "CHANGE REFERENCE DATA".
 2416|       |	 *
 2417|       |	 * Note that if this function is called from sc_pkcs15_verify_pin() in pkcs15-pin.c,
 2418|       |	 * the Ref is already 81, 82, 83.
 2419|       |	 */
 2420|       |
 2421|       |	/* convert the PIN Reference if needed */
 2422|    355|	data->pin_reference |= 0x80;
 2423|       |
 2424|       |	/* check version-dependent constraints */
 2425|    355|	if (data->cmd == SC_PIN_CMD_CHANGE || data->cmd == SC_PIN_CMD_UNBLOCK) {
  ------------------
  |  |  416|    710|#define SC_PIN_CMD_CHANGE	1
  ------------------
              	if (data->cmd == SC_PIN_CMD_CHANGE || data->cmd == SC_PIN_CMD_UNBLOCK) {
  ------------------
  |  |  417|    355|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (2425:6): [True: 0, False: 355]
  |  Branch (2425:40): [True: 0, False: 355]
  ------------------
 2426|      0|		if (priv->bcd_version >= OPENPGP_CARD_2_0) {
  ------------------
  |  Branch (2426:7): [True: 0, False: 0]
  ------------------
 2427|      0|			if (data->pin_reference == 0x82)
  ------------------
  |  Branch (2427:8): [True: 0, False: 0]
  ------------------
 2428|      0|				data->pin_reference = 0x81;
 2429|       |
 2430|      0|			if (data->cmd == SC_PIN_CMD_CHANGE) {
  ------------------
  |  |  416|      0|#define SC_PIN_CMD_CHANGE	1
  ------------------
  |  Branch (2430:8): [True: 0, False: 0]
  ------------------
 2431|      0|				if (data->pin1.len == 0 &&
  ------------------
  |  Branch (2431:9): [True: 0, False: 0]
  ------------------
 2432|      0|				    !(data->flags & SC_PIN_CMD_USE_PINPAD))
  ------------------
  |  |  421|      0|#define SC_PIN_CMD_USE_PINPAD		0x0001
  ------------------
  |  Branch (2432:9): [True: 0, False: 0]
  ------------------
 2433|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2434|      0|							"v2 cards don't support implicit old PIN for PIN change");
 2435|       |
 2436|      0|				data->flags &= ~SC_PIN_CMD_IMPLICIT_CHANGE;
  ------------------
  |  |  423|      0|#define SC_PIN_CMD_IMPLICIT_CHANGE	0x0004
  ------------------
 2437|      0|			}
 2438|      0|		} else {
 2439|      0|			if (data->pin1.len != 0) {
  ------------------
  |  Branch (2439:8): [True: 0, False: 0]
  ------------------
 2440|      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__
  |  |  ------------------
  ------------------
 2441|      0|				       "v1 cards don't support explicit old or CHV3 PIN, PIN ignored.");
 2442|      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__
  |  |  ------------------
  ------------------
 2443|      0|				       "please make sure that you have verified the relevant PIN first.");
 2444|      0|				data->pin1.len = 0;
 2445|      0|			}
 2446|       |
 2447|      0|			data->flags |= SC_PIN_CMD_IMPLICIT_CHANGE;
  ------------------
  |  |  423|      0|#define SC_PIN_CMD_IMPLICIT_CHANGE	0x0004
  ------------------
 2448|      0|		}
 2449|      0|	}
 2450|       |
 2451|    355|	if (data->cmd == SC_PIN_CMD_UNBLOCK && data->pin2.len == 0 &&
  ------------------
  |  |  417|    710|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (2451:6): [True: 0, False: 355]
  |  Branch (2451:41): [True: 0, False: 0]
  ------------------
 2452|      0|	    !(data->flags & SC_PIN_CMD_USE_PINPAD))
  ------------------
  |  |  421|      0|#define SC_PIN_CMD_USE_PINPAD		0x0001
  ------------------
  |  Branch (2452:6): [True: 0, False: 0]
  ------------------
 2453|    355|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS,
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2454|    355|				"new PIN must be provided for unblock operation");
 2455|       |
 2456|       |	/* ensure pin_reference is 81, 82, 83 */
 2457|    355|	if (data->pin_reference < 0x81 || data->pin_reference > 0x83)
  ------------------
  |  Branch (2457:6): [True: 0, False: 355]
  |  Branch (2457:36): [True: 0, False: 355]
  ------------------
 2458|    355|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS,
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2459|    355|				"Invalid key ID; must be 1, 2, or 3");
 2460|       |
 2461|       |	/* emulate SC_PIN_CMD_GET_INFO command for cards not supporting it */
 2462|    355|	if (data->cmd == SC_PIN_CMD_GET_INFO && (card->caps & SC_CARD_CAP_ISO7816_PIN_INFO) == 0) {
  ------------------
  |  |  418|    710|#define SC_PIN_CMD_GET_INFO	3
  ------------------
              	if (data->cmd == SC_PIN_CMD_GET_INFO && (card->caps & SC_CARD_CAP_ISO7816_PIN_INFO) == 0) {
  ------------------
  |  |  553|    355|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
  |  Branch (2462:6): [True: 355, False: 0]
  |  Branch (2462:42): [True: 30, False: 325]
  ------------------
 2463|     30|		u8 c4data[10];
 2464|     30|		int r;
 2465|       |
 2466|     30|		r = sc_get_data(card, 0x00c4, c4data, sizeof(c4data));
 2467|     30|		LOG_TEST_RET(card->ctx, r, "reading CHV status bytes 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: 23, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  169|     23|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     23|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     23|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     23|		return _ret; \
  |  |  |  |  172|     23|	} \
  |  |  |  |  173|     30|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2468|       |
 2469|      7|		if (r != 7)
  ------------------
  |  Branch (2469:7): [True: 5, False: 2]
  ------------------
 2470|      7|			LOG_TEST_RET(card->ctx, SC_ERROR_OBJECT_NOT_VALID,
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2471|      2|				"CHV status bytes have unexpected length");
 2472|       |
 2473|       |		/* The definition of fields of DO C4 changed between OpenPGP
 2474|       |		 * card specification v1.1 and v2.0. There is no longer a separate
 2475|       |		 * CHV2 retry counter but only one retry counter for both PW1 mode 1
 2476|       |		 * and mode 2 at byte 5 (count from 1) of the DO.
 2477|       |		 */
 2478|      2|		if (priv->bcd_version >= OPENPGP_CARD_2_0 && data->pin_reference == 0x82)
  ------------------
  |  Branch (2478:7): [True: 1, False: 1]
  |  Branch (2478:48): [True: 1, False: 0]
  ------------------
 2479|      1|			data->pin_reference = 0x81;
 2480|       |
 2481|      2|		data->pin1.tries_left = c4data[3 + (data->pin_reference & 0x0F)];
 2482|      2|		data->pin1.max_tries = 3;
 2483|      2|		data->pin1.logged_in = SC_PIN_STATE_UNKNOWN;
  ------------------
  |  |  430|      2|#define SC_PIN_STATE_UNKNOWN	0
  ------------------
 2484|       |
 2485|      2|		LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|      2|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      2|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      2|	int _ret = r; \
  |  |  |  |  155|      2|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      2|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  157|      2|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      2|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      2|	return _ret; \
  |  |  |  |  163|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2486|      2|	}
 2487|       |
 2488|    325|#ifdef ENABLE_OPENSSL
 2489|    325|	if (priv->pin_kdf_info) {
  ------------------
  |  Branch (2489:6): [True: 0, False: 325]
  ------------------
 2490|      0|		ops.pin_cmd = &pgp_kdf_do_pin_cmd;
 2491|      0|	}
 2492|    325|#endif /* ENABLE_OPENSSL */
 2493|       |
 2494|    325|	LOG_FUNC_RETURN(card->ctx, ops.pin_cmd(card, data));
  ------------------
  |  |  164|    325|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    325|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    325|	int _ret = r; \
  |  |  |  |  155|    325|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 325, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    325|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    223|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 223, False: 102]
  |  |  |  |  ------------------
  |  |  |  |  157|    325|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    325|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    325|	return _ret; \
  |  |  |  |  163|    325|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2495|    325|}
card-openpgp.c:pgp_get_data:
 1994|  8.03k|{
 1995|  8.03k|	sc_apdu_t	apdu;
 1996|  8.03k|	int		r;
 1997|       |
 1998|  8.03k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  8.03k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  8.03k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  8.03k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  8.03k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 8.03k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1999|       |
 2000|  8.03k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0xCA, tag >> 8, tag);
  ------------------
  |  |  301|  8.03k|#define SC_APDU_CASE_2			0x22
  ------------------
 2001|  8.03k|	apdu.le = ((buf_len >= 256) && !(card->caps & SC_CARD_CAP_APDU_EXT)) ? 256 : buf_len;
  ------------------
  |  |  547|  6.22k|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (2001:13): [True: 6.22k, False: 1.81k]
  |  Branch (2001:33): [True: 5.92k, False: 295]
  ------------------
 2002|  8.03k|	apdu.resp = buf;
 2003|  8.03k|	apdu.resplen = buf_len;
 2004|       |
 2005|  8.03k|	r = sc_transmit_apdu(card, &apdu);
 2006|  8.03k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  8.03k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  8.03k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  8.03k|	int _ret = (r); \
  |  |  |  |  168|  8.03k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 154, False: 7.88k]
  |  |  |  |  ------------------
  |  |  |  |  169|    154|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    154|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    154|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    154|		return _ret; \
  |  |  |  |  172|    154|	} \
  |  |  |  |  173|  8.03k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 7.88k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2007|       |
 2008|  7.88k|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 2009|       |
 2010|       |	/* Gnuk returns an error instead of empty data if there is no certificate or private DO.
 2011|       |	 * So, for this case, we ignore error and consider success */
 2012|  7.88k|	if (card->type == SC_CARD_TYPE_OPENPGP_GNUK &&
  ------------------
  |  Branch (2012:6): [True: 200, False: 7.68k]
  ------------------
 2013|    200|	    (tag == DO_CERT  ||
  ------------------
  |  |  138|    400|#define DO_CERT                  0x7f21
  ------------------
  |  Branch (2013:7): [True: 0, False: 200]
  ------------------
 2014|    200|	     tag == DO_PRIV1 ||
  ------------------
  |  |  149|    400|#define DO_PRIV1                 0x0101
  ------------------
  |  Branch (2014:7): [True: 21, False: 179]
  ------------------
 2015|    179|	     tag == DO_PRIV2 ||
  ------------------
  |  |  150|    379|#define DO_PRIV2                 0x0102
  ------------------
  |  Branch (2015:7): [True: 0, False: 179]
  ------------------
 2016|    179|	     tag == DO_PRIV3 ||
  ------------------
  |  |  151|    379|#define DO_PRIV3                 0x0103
  ------------------
  |  Branch (2016:7): [True: 0, False: 179]
  ------------------
 2017|    179|	     tag == DO_PRIV4)) {
  ------------------
  |  |  152|    179|#define DO_PRIV4                 0x0104
  ------------------
  |  Branch (2017:7): [True: 0, False: 179]
  ------------------
 2018|     21|		if (r == SC_ERROR_DATA_OBJECT_NOT_FOUND) {
  ------------------
  |  |   66|     21|#define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
  ------------------
  |  Branch (2018:7): [True: 1, False: 20]
  ------------------
 2019|      1|			r = SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
 2020|      1|			apdu.resplen = 0;
 2021|      1|		}
 2022|     21|	}
 2023|  7.88k|	LOG_TEST_RET(card->ctx, r, "Card returned error");
  ------------------
  |  |  174|  7.88k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  7.88k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  7.88k|	int _ret = (r); \
  |  |  |  |  168|  7.88k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 4.32k, False: 3.55k]
  |  |  |  |  ------------------
  |  |  |  |  169|  4.32k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.32k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  4.32k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  4.32k|		return _ret; \
  |  |  |  |  172|  4.32k|	} \
  |  |  |  |  173|  7.88k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3.55k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2024|       |
 2025|  3.55k|	LOG_FUNC_RETURN(card->ctx, (int)apdu.resplen);
  ------------------
  |  |  164|  3.55k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.55k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.55k|	int _ret = r; \
  |  |  |  |  155|  3.55k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.00k, False: 2.55k]
  |  |  |  |  ------------------
  |  |  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 1.00k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.00k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.55k|	} else { \
  |  |  |  |  159|  2.55k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  2.55k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  2.55k|	} \
  |  |  |  |  162|  3.55k|	return _ret; \
  |  |  |  |  163|  3.55k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2026|  3.55k|}
card-openpgp.c:pgp_put_data:
 2141|    401|{
 2142|    401|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|    401|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 2143|    401|	pgp_blob_t *affected_blob = NULL;
 2144|    401|	pgp_do_info_t *dinfo = NULL;
 2145|    401|	int r;
 2146|       |
 2147|    401|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    401|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    401|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    401|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    401|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 401]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2148|       |
 2149|       |	/* Check if there is a blob for the given tag */
 2150|    401|	affected_blob = pgp_find_blob(card, tag);
 2151|       |
 2152|       |	/* Non-readable DOs have no represented blob, we have to check from pgp_get_info_by_tag */
 2153|    401|	if (affected_blob == NULL)
  ------------------
  |  Branch (2153:6): [True: 150, False: 251]
  ------------------
 2154|    150|		dinfo = pgp_get_info_by_tag(card, tag);
 2155|    251|	else
 2156|    251|		dinfo = affected_blob->info;
 2157|       |
 2158|       |	/* Make sure the DO exists and is writeable */
 2159|    401|	if (dinfo == NULL) {
  ------------------
  |  Branch (2159:6): [True: 0, False: 401]
  ------------------
 2160|      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__
  |  |  ------------------
  ------------------
 2161|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2162|      0|	}
 2163|    401|	else if ((dinfo->access & WRITE_MASK) == WRITE_NEVER) {
  ------------------
  |  Branch (2163:11): [True: 0, False: 401]
  ------------------
 2164|      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__
  |  |  ------------------
  ------------------
 2165|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2166|      0|	}
 2167|       |
 2168|       |	/* Check data size.
 2169|       |	 * We won't check other DOs than 7F21 (certificate), because their capacity
 2170|       |	 * is hard-coded and may change in various version of the card.
 2171|       |	 * If we check here, the driver may be stuck to a limit version number of card.
 2172|       |	 * 7F21 size is soft-coded, so we can check it. */
 2173|    401|	if (tag == DO_CERT && buf_len > priv->max_cert_size) {
  ------------------
  |  |  138|    802|#define DO_CERT                  0x7f21
  ------------------
  |  Branch (2173:6): [True: 0, False: 401]
  |  Branch (2173:24): [True: 0, False: 0]
  ------------------
 2174|      0|		sc_log(card->ctx, "Data size %zu exceeds DO size limit %zu.", buf_len, priv->max_cert_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__
  |  |  ------------------
  ------------------
 2175|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2176|      0|	}
 2177|       |
 2178|    401|	if (tag == DO_CERT && card->type == SC_CARD_TYPE_OPENPGP_GNUK) {
  ------------------
  |  |  138|    802|#define DO_CERT                  0x7f21
  ------------------
  |  Branch (2178:6): [True: 0, False: 401]
  |  Branch (2178:24): [True: 0, False: 0]
  ------------------
 2179|       |		/* Gnuk need a special way to write certificate. */
 2180|      0|		r = gnuk_write_certificate(card, buf, buf_len);
 2181|      0|	}
 2182|    401|	else {
 2183|    401|		r = pgp_put_data_plain(card, tag, buf, buf_len);
 2184|    401|	}
 2185|       |
 2186|       |	/* instruct more in case of error */
 2187|    401|	if (r == SC_ERROR_SECURITY_STATUS_NOT_SATISFIED) {
  ------------------
  |  |   61|    401|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
  |  Branch (2187:6): [True: 1, False: 400]
  ------------------
 2188|      1|		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Please verify PIN first.");
  ------------------
  |  |   70|      1|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2189|      1|	}
 2190|    401|	LOG_TEST_RET(card->ctx, r, "PUT DATA returned error");
  ------------------
  |  |  174|    401|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    401|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    401|	int _ret = (r); \
  |  |  |  |  168|    401|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 217, False: 184]
  |  |  |  |  ------------------
  |  |  |  |  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|    401|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 184]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2191|       |
 2192|    184|	if (affected_blob) {
  ------------------
  |  Branch (2192:6): [True: 153, False: 31]
  ------------------
 2193|       |		/* update the corresponding file */
 2194|    153|		sc_log(card->ctx, "Updating the corresponding blob data");
  ------------------
  |  |   71|    153|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2195|    153|		r = pgp_set_blob(affected_blob, buf, buf_len);
 2196|    153|		if (r < 0)
  ------------------
  |  Branch (2196:7): [True: 0, False: 153]
  ------------------
 2197|      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__
  |  |  ------------------
  ------------------
 2198|       |		/* pgp_set_blob()'s failures do not impact pgp_put_data()'s result */
 2199|    153|	}
 2200|       |
 2201|    184|	LOG_FUNC_RETURN(card->ctx, (int)buf_len);
  ------------------
  |  |  164|    184|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    184|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    184|	int _ret = r; \
  |  |  |  |  155|    184|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 184]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    184|	} else { \
  |  |  |  |  159|    184|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    184|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    184|	} \
  |  |  |  |  162|    184|	return _ret; \
  |  |  |  |  163|    184|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2202|    184|}
card-openpgp.c:pgp_find_blob:
 1552|    419|{
 1553|    419|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|    419|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 1554|    419|	pgp_blob_t *blob = NULL;
 1555|    419|	int r;
 1556|       |
 1557|       |	/* check if current selected blob is which we want to test */
 1558|    419|	if (priv->current->id == tag) {
  ------------------
  |  Branch (1558:6): [True: 24, False: 395]
  ------------------
 1559|     24|		return priv->current;
 1560|     24|	}
 1561|       |	/* look for the blob representing the DO */
 1562|    395|	r = pgp_seek_blob(card, priv->mf, tag, &blob);
 1563|    395|	if (r < 0) {
  ------------------
  |  Branch (1563:6): [True: 163, False: 232]
  ------------------
 1564|    163|		sc_log(card->ctx, "Failed to seek the blob representing the tag %04X. Error %d.", tag, r);
  ------------------
  |  |   71|    163|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1565|    163|		return NULL;
 1566|    163|	}
 1567|    232|	return blob;
 1568|    395|}
card-openpgp.c:pgp_seek_blob:
 1524|  19.9k|{
 1525|  19.9k|	pgp_blob_t	*child;
 1526|  19.9k|	int			r;
 1527|       |
 1528|  19.9k|	if ((r = pgp_get_blob(card, root, id, ret)) == 0)
  ------------------
  |  Branch (1528:6): [True: 454, False: 19.4k]
  ------------------
 1529|       |		/* the sought blob is right under root */
 1530|    454|		return r;
 1531|       |
 1532|       |	/* not found, seek deeper */
 1533|  43.1k|	for (child = root->files; child; child = child->next) {
  ------------------
  |  Branch (1533:28): [True: 24.6k, False: 18.4k]
  ------------------
 1534|       |		/* The DO of SIMPLE type or the DO holding certificate
 1535|       |		 * does not contain children */
 1536|  24.6k|		if ((child->info && child->info->type == SIMPLE) || child->id == DO_CERT)
  ------------------
  |  |  138|  19.2k|#define DO_CERT                  0x7f21
  ------------------
  |  Branch (1536:8): [True: 10.9k, False: 13.6k]
  |  Branch (1536:23): [True: 5.38k, False: 5.60k]
  |  Branch (1536:55): [True: 0, False: 19.2k]
  ------------------
 1537|  5.38k|			continue;
 1538|  19.2k|		r = pgp_seek_blob(card, child, id, ret);
 1539|  19.2k|		if (r == 0)
  ------------------
  |  Branch (1539:7): [True: 1.00k, False: 18.2k]
  ------------------
 1540|  1.00k|			return r;
 1541|  19.2k|	}
 1542|       |
 1543|  18.4k|	return SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|  18.4k|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
 1544|  19.4k|}
card-openpgp.c:pgp_get_info_by_tag:
 1576|    150|{
 1577|    150|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|    150|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 1578|    150|	pgp_do_info_t *info;
 1579|       |
 1580|  6.30k|	for (info = priv->pgp_objects; (info != NULL) && (info->id > 0); info++)
  ------------------
  |  Branch (1580:33): [True: 6.30k, False: 0]
  |  Branch (1580:51): [True: 6.30k, False: 0]
  ------------------
 1581|  6.30k|		if (tag == info->id)
  ------------------
  |  Branch (1581:7): [True: 150, False: 6.15k]
  ------------------
 1582|    150|			return info;
 1583|       |
 1584|      0|	return NULL;
 1585|    150|}
card-openpgp.c:pgp_put_data_plain:
 2089|    401|{
 2090|    401|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|    401|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 2091|    401|	sc_apdu_t apdu;
 2092|    401|	u8 ins = 0xDA;
 2093|    401|	u8 p1 = tag >> 8;
 2094|    401|	u8 p2 = tag & 0xFF;
 2095|    401|	u8 apdu_case = (card->type == SC_CARD_TYPE_OPENPGP_GNUK)
  ------------------
  |  Branch (2095:17): [True: 1, False: 400]
  ------------------
 2096|    401|			? SC_APDU_CASE_3_SHORT : SC_APDU_CASE_3;
  ------------------
  |  |  293|      1|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
              			? SC_APDU_CASE_3_SHORT : SC_APDU_CASE_3;
  ------------------
  |  |  302|    801|#define SC_APDU_CASE_3			0x23
  ------------------
 2097|    401|	int r;
 2098|       |
 2099|    401|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    401|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    401|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    401|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    401|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 401]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2100|       |
 2101|       |	/* Extended Header list (DO 004D) needs a variant of PUT DATA command */
 2102|    401|	if (tag == 0x004D) {
  ------------------
  |  Branch (2102:6): [True: 0, False: 401]
  ------------------
 2103|      0|		ins = 0xDB;
 2104|      0|		p1 = 0x3F;
 2105|      0|		p2 = 0xFF;
 2106|      0|	}
 2107|       |
 2108|       |	/* build APDU */
 2109|    401|	if (buf != NULL && buf_len > 0) {
  ------------------
  |  Branch (2109:6): [True: 401, False: 0]
  |  Branch (2109:21): [True: 401, False: 0]
  ------------------
 2110|    401|		sc_format_apdu(card, &apdu, apdu_case, ins, p1, p2);
 2111|       |
 2112|       |		/* if card/reader does not support extended APDUs, but chaining, then set it */
 2113|    401|		if (((card->caps & SC_CARD_CAP_APDU_EXT) == 0) && (priv->ext_caps & EXT_CAP_CHAINING))
  ------------------
  |  |  547|    401|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (2113:7): [True: 378, False: 23]
  |  Branch (2113:53): [True: 11, False: 367]
  ------------------
 2114|     11|			apdu.flags |= SC_APDU_FLAGS_CHAINING;
  ------------------
  |  |  306|     11|#define SC_APDU_FLAGS_CHAINING		0x00000001UL
  ------------------
 2115|       |
 2116|    401|		apdu.data = (u8 *)buf;
 2117|    401|		apdu.datalen = buf_len;
 2118|    401|		apdu.lc = buf_len;
 2119|    401|	}
 2120|      0|	else {
 2121|       |		/* This case is to empty DO */
 2122|      0|		sc_format_apdu(card, &apdu, SC_APDU_CASE_1, ins, p1, p2);
  ------------------
  |  |  291|      0|#define SC_APDU_CASE_1			0x01
  ------------------
 2123|      0|	}
 2124|       |
 2125|       |	/* send APDU to card */
 2126|    401|	r = sc_transmit_apdu(card, &apdu);
 2127|    401|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    401|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    401|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    401|	int _ret = (r); \
  |  |  |  |  168|    401|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 398]
  |  |  |  |  ------------------
  |  |  |  |  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|    401|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 398]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2128|       |	/* check response */
 2129|    398|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 2130|    398|	LOG_TEST_RET(card->ctx, r, "Card returned error");
  ------------------
  |  |  174|    398|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    398|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    398|	int _ret = (r); \
  |  |  |  |  168|    398|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 214, False: 184]
  |  |  |  |  ------------------
  |  |  |  |  169|    214|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    214|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    214|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    214|		return _ret; \
  |  |  |  |  172|    214|	} \
  |  |  |  |  173|    398|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 184]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2131|       |
 2132|    184|	LOG_FUNC_RETURN(card->ctx, (int)buf_len);
  ------------------
  |  |  164|    184|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    184|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    184|	int _ret = r; \
  |  |  |  |  155|    184|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 184]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    184|	} else { \
  |  |  |  |  159|    184|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    184|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    184|	} \
  |  |  |  |  162|    184|	return _ret; \
  |  |  |  |  163|    184|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2133|    184|}
card-openpgp.c:pgp_card_ctl:
 4009|  1.47k|{
 4010|  1.47k|	int r;
 4011|       |
 4012|  1.47k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  1.47k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.47k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.47k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.47k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.47k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4013|       |
 4014|  1.47k|	switch(cmd) {
  ------------------
  |  Branch (4014:9): [True: 589, False: 883]
  ------------------
 4015|    328|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (4015:2): [True: 328, False: 1.14k]
  ------------------
 4016|    328|		memmove((sc_serial_number_t *) ptr, &card->serialnr, sizeof(card->serialnr));
 4017|    328|		LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    328|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    328|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    328|	int _ret = r; \
  |  |  |  |  155|    328|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 328, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    328|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 328]
  |  |  |  |  ------------------
  |  |  |  |  157|    328|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    328|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    328|	return _ret; \
  |  |  |  |  163|    328|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4018|      0|		break;
 4019|      0|	case SC_CARDCTL_OPENPGP_SELECT_DATA:
  ------------------
  |  Branch (4019:2): [True: 0, False: 1.47k]
  ------------------
 4020|      0|		r = pgp_select_data(card, *((u8 *) ptr));
 4021|      0|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4022|      0|		break;
 4023|      0|#ifdef ENABLE_OPENSSL
 4024|    261|	case SC_CARDCTL_OPENPGP_GENERATE_KEY:
  ------------------
  |  Branch (4024:2): [True: 261, False: 1.21k]
  ------------------
 4025|    261|		r = pgp_gen_key(card, (sc_cardctl_openpgp_key_gen_store_info_t *)ptr);
 4026|    261|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    261|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    261|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    261|	int _ret = r; \
  |  |  |  |  155|    261|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 261, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    261|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    257|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 257, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  157|    261|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    261|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    261|	return _ret; \
  |  |  |  |  163|    261|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4027|      0|		break;
 4028|      0|	case SC_CARDCTL_OPENPGP_STORE_KEY:
  ------------------
  |  Branch (4028:2): [True: 0, False: 1.47k]
  ------------------
 4029|      0|		r = pgp_store_key(card, (sc_cardctl_openpgp_key_gen_store_info_t *)ptr);
 4030|      0|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4031|      0|		break;
 4032|      0|#endif /* ENABLE_OPENSSL */
 4033|      0|	case SC_CARDCTL_ERASE_CARD:
  ------------------
  |  Branch (4033:2): [True: 0, False: 1.47k]
  ------------------
 4034|      0|		r = pgp_erase_card(card);
 4035|      0|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4036|      0|		break;
 4037|  1.47k|	}
 4038|       |
 4039|    883|	LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|    883|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    883|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    883|	int _ret = r; \
  |  |  |  |  155|    883|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 883, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    883|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    883|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 883, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    883|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    883|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    883|	return _ret; \
  |  |  |  |  163|    883|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4040|    883|}
card-openpgp.c:pgp_gen_key:
 3427|    261|{
 3428|    261|	sc_apdu_t apdu;
 3429|       |	/* temporary variables to hold APDU params */
 3430|    261|	u8 apdu_case;
 3431|    261|	u8 apdu_data[2] = { 0x00, 0x00 };
 3432|    261|	size_t apdu_le;
 3433|    261|	size_t resplen = 0;
 3434|    261|	int r = SC_SUCCESS;
  ------------------
  |  |   28|    261|#define SC_SUCCESS				0
  ------------------
 3435|    261|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|    261|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 3436|       |
 3437|    261|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    261|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    261|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    261|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    261|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 261]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3438|       |
 3439|       |	/* protect incompatible cards against non-RSA */
 3440|    261|	if (key_info->algorithm != SC_OPENPGP_KEYALGO_RSA &&
  ------------------
  |  |  870|    522|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  |  Branch (3440:6): [True: 15, False: 246]
  ------------------
 3441|     15|			priv->bcd_version < OPENPGP_CARD_3_0 &&
  ------------------
  |  Branch (3441:4): [True: 1, False: 14]
  ------------------
 3442|      1|			card->type != SC_CARD_TYPE_OPENPGP_GNUK)
  ------------------
  |  Branch (3442:4): [True: 1, False: 0]
  ------------------
 3443|    261|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3444|       |
 3445|       |	/* set Control Reference Template for key */
 3446|    260|	if (key_info->key_id == SC_OPENPGP_KEY_SIGN)
  ------------------
  |  |  866|    260|#define SC_OPENPGP_KEY_SIGN		1
  ------------------
  |  Branch (3446:6): [True: 0, False: 260]
  ------------------
 3447|      0|		ushort2bebytes(apdu_data, DO_SIGN);
  ------------------
  |  |  141|      0|#define DO_SIGN                  0xb600
  ------------------
 3448|    260|	else if (key_info->key_id == SC_OPENPGP_KEY_ENCR)
  ------------------
  |  |  867|    260|#define SC_OPENPGP_KEY_ENCR		2
  ------------------
  |  Branch (3448:11): [True: 0, False: 260]
  ------------------
 3449|      0|		ushort2bebytes(apdu_data, DO_ENCR);
  ------------------
  |  |  142|      0|#define DO_ENCR                  0xb800
  ------------------
 3450|    260|	else if (key_info->key_id == SC_OPENPGP_KEY_AUTH)
  ------------------
  |  |  868|    260|#define SC_OPENPGP_KEY_AUTH		3
  ------------------
  |  Branch (3450:11): [True: 260, False: 0]
  ------------------
 3451|    260|		ushort2bebytes(apdu_data, DO_AUTH);
  ------------------
  |  |  143|    260|#define DO_AUTH                  0xa400
  ------------------
 3452|      0|	else {
 3453|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3454|      0|				"Invalid key ID; must be 1, 2, or 3");
 3455|      0|	}
 3456|       |
 3457|       |	/* set attributes for new-generated key */
 3458|    260|	r = pgp_update_new_algo_attr(card, key_info);
 3459|    260|	LOG_TEST_RET(card->ctx, r, "Cannot set attributes for new-generated key");
  ------------------
  |  |  174|    260|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    260|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    260|	int _ret = (r); \
  |  |  |  |  168|    260|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 134, False: 126]
  |  |  |  |  ------------------
  |  |  |  |  169|    134|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    134|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    134|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    134|		return _ret; \
  |  |  |  |  172|    134|	} \
  |  |  |  |  173|    260|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 126]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3460|       |
 3461|       |	/* Test whether we will need extended APDU. 1900 is an
 3462|       |	 * arbitrary modulus length which for sure fits into a short APDU.
 3463|       |	 * This idea is borrowed from GnuPG code.  */
 3464|    126|	if (card->caps & SC_CARD_CAP_APDU_EXT
  ------------------
  |  |  547|    252|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (3464:6): [True: 5, False: 121]
  ------------------
 3465|      5|		&& key_info->u.rsa.modulus_len > 1900
  ------------------
  |  Branch (3465:6): [True: 0, False: 5]
  ------------------
 3466|      0|		&& card->type != SC_CARD_TYPE_OPENPGP_GNUK) {
  ------------------
  |  Branch (3466:6): [True: 0, False: 0]
  ------------------
 3467|       |		/* We won't store to apdu variable yet, because it will be reset in
 3468|       |		 * sc_format_apdu() */
 3469|      0|		apdu_le = card->max_recv_size;
 3470|      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
  |  |  ------------------
  ------------------
 3471|      0|	}
 3472|    126|	else {
 3473|    126|		apdu_case = SC_APDU_CASE_4_SHORT;
  ------------------
  |  |  294|    126|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
 3474|    126|		apdu_le = 256;
 3475|    126|		resplen = MAXLEN_RESP_PUBKEY;
  ------------------
  |  |  164|    126|#define MAXLEN_RESP_PUBKEY       527
  ------------------
 3476|    126|	}
 3477|    126|	if (card->type == SC_CARD_TYPE_OPENPGP_GNUK) {
  ------------------
  |  Branch (3477:6): [True: 0, False: 126]
  ------------------
 3478|      0|		resplen = MAXLEN_RESP_PUBKEY_GNUK;
  ------------------
  |  |  166|      0|#define MAXLEN_RESP_PUBKEY_GNUK  271
  ------------------
 3479|      0|	}
 3480|       |
 3481|       |	/* prepare APDU */
 3482|    126|	sc_format_apdu(card, &apdu, apdu_case, 0x47, 0x80, 0);
 3483|    126|	apdu.data = apdu_data;
 3484|    126|	apdu.datalen = sizeof(apdu_data);
 3485|    126|	apdu.lc = sizeof(apdu_data);
 3486|    126|	apdu.le = apdu_le;
 3487|       |
 3488|       |	/* buffer to receive response */
 3489|    126|	apdu.resplen = (resplen > 0) ? resplen : apdu_le;
  ------------------
  |  Branch (3489:17): [True: 126, False: 0]
  ------------------
 3490|    126|	apdu.resp = calloc(1, apdu.resplen);
 3491|    126|	if (apdu.resp == NULL) {
  ------------------
  |  Branch (3491:6): [True: 0, False: 126]
  ------------------
 3492|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3493|      0|	}
 3494|       |
 3495|       |	/* send */
 3496|    126|	sc_log(card->ctx, "Waiting for the card to generate key...");
  ------------------
  |  |   71|    126|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3497|    126|	r = sc_transmit_apdu(card, &apdu);
 3498|    126|	sc_log(card->ctx, "Card has done key generation.");
  ------------------
  |  |   71|    126|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3499|    126|	LOG_TEST_GOTO_ERR(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  184|    126|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    126|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    126|	int _ret = (r); \
  |  |  |  |  178|    126|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 1, False: 125]
  |  |  |  |  ------------------
  |  |  |  |  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|    126|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 125]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3500|       |
 3501|       |	/* check response */
 3502|    125|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 3503|       |	/* instruct more in case of error */
 3504|    125|	if (r == SC_ERROR_SECURITY_STATUS_NOT_SATISFIED) {
  ------------------
  |  |   61|    125|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
  |  Branch (3504:6): [True: 0, False: 125]
  ------------------
 3505|      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__
  |  |  ------------------
  ------------------
 3506|      0|		goto err;
 3507|      0|	}
 3508|    125|	LOG_TEST_GOTO_ERR(card->ctx, r, "Card returned error");
  ------------------
  |  |  184|    125|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    125|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    125|	int _ret = (r); \
  |  |  |  |  178|    125|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 7, False: 118]
  |  |  |  |  ------------------
  |  |  |  |  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|    125|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 118]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3509|       |
 3510|       |	/* parse response data and set output */
 3511|    118|	r = pgp_parse_and_set_pubkey_output(card, apdu.resp, apdu.resplen, key_info);
 3512|    118|	LOG_TEST_GOTO_ERR(card->ctx, r, "Failed to parse pubkey output");
  ------------------
  |  |  184|    118|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    118|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    118|	int _ret = (r); \
  |  |  |  |  178|    118|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 114, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  179|    114|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    114|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    114|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    114|		goto err; \
  |  |  |  |  182|    114|	} \
  |  |  |  |  183|    118|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3513|      4|	r = pgp_update_card_algorithms(card, key_info);
 3514|       |
 3515|    126|err:
 3516|    126|	free(apdu.resp);
 3517|    126|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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|    122|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 122, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3518|    126|}
card-openpgp.c:pgp_update_new_algo_attr:
 2850|    260|{
 2851|    260|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|    260|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 2852|    260|	pgp_blob_t *algo_blob = NULL;
 2853|    260|	const unsigned int tag = 0x00C0 | key_info->key_id;
 2854|    260|	int r = SC_SUCCESS;
  ------------------
  |  |   28|    260|#define SC_SUCCESS				0
  ------------------
 2855|    260|	unsigned int i;
 2856|       |
 2857|    260|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    260|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    260|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    260|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    260|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 260]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2858|       |
 2859|    260|	r = pgp_seek_blob(card, priv->mf, tag, &algo_blob);
 2860|    260|	LOG_TEST_RET(card->ctx, r, "Cannot get old algorithm attributes");
  ------------------
  |  |  174|    260|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    260|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    260|	int _ret = (r); \
  |  |  |  |  168|    260|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 38, False: 222]
  |  |  |  |  ------------------
  |  |  |  |  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|    260|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 222]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2861|       |
 2862|    222|	if (priv->ext_caps & EXT_CAP_ALG_ATTR_CHANGEABLE) {
  ------------------
  |  Branch (2862:6): [True: 214, False: 8]
  ------------------
 2863|       |		/* ECDSA and ECDH */
 2864|    214|		if (key_info->algorithm == SC_OPENPGP_KEYALGO_ECDH
  ------------------
  |  |  871|    428|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (2864:7): [True: 0, False: 214]
  ------------------
 2865|    214|				|| key_info->algorithm == SC_OPENPGP_KEYALGO_ECDSA
  ------------------
  |  |  872|    428|#define	SC_OPENPGP_KEYALGO_ECDSA	0x13
  ------------------
  |  Branch (2865:8): [True: 7, False: 207]
  ------------------
 2866|    207|				|| key_info->algorithm == SC_OPENPGP_KEYALGO_EDDSA){
  ------------------
  |  |  873|    207|#define	SC_OPENPGP_KEYALGO_EDDSA	0x16
  ------------------
  |  Branch (2866:8): [True: 0, False: 207]
  ------------------
 2867|       |			/* Note OpenPGP or current cards do not support 448 size keys yet */
 2868|      7|			unsigned char *aoid = NULL; /* ASN1 */
 2869|      7|			size_t aoid_len;
 2870|      7|			struct sc_object_id *scoid = NULL;
 2871|       |
 2872|      7|			scoid = &key_info->u.ec.oid;
 2873|       |			/*
 2874|       |			 * Current OpenPGP cards use pre RFC8410 OIDs for ECDH and EdDSA
 2875|       |			 * so convert to older versions of the OIDs.
 2876|       |			 */
 2877|     21|			for (i = 0; ec_curves_alt[i].size > 0; i++) {
  ------------------
  |  Branch (2877:16): [True: 14, False: 7]
  ------------------
 2878|     14|				if (sc_compare_oid(scoid, &ec_curves_alt[i].oid_alt)) {
  ------------------
  |  Branch (2878:9): [True: 0, False: 14]
  ------------------
 2879|      0|					scoid = &ec_curves_alt[i].oid;
 2880|      0|					break;
 2881|      0|				}
 2882|     14|			}
 2883|       |
 2884|      7|			r = sc_encode_oid(card->ctx, scoid, &aoid, &aoid_len);
 2885|      7|			LOG_TEST_RET(card->ctx, r, "invalid ec oid");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2886|      7|			if (aoid == NULL || aoid_len < 3 || aoid[1] > 127) {
  ------------------
  |  Branch (2886:8): [True: 0, False: 7]
  |  Branch (2886:24): [True: 0, False: 7]
  |  Branch (2886:40): [True: 0, False: 7]
  ------------------
 2887|      0|				free(aoid);
 2888|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2889|      0|			}
 2890|       |
 2891|      7|			key_info->data_len = aoid_len + 1 - 2; /* +1 for algorithm -2 drop 06 len */
 2892|      7|			key_info->data = malloc(key_info->data_len);
 2893|      7|			if (!key_info->data) {
  ------------------
  |  Branch (2893:8): [True: 0, False: 7]
  ------------------
 2894|      0|				free(aoid);
 2895|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2896|      0|			}
 2897|       |
 2898|      7|			key_info->data[0] = key_info->algorithm;
 2899|     63|			for (i = 0; i < aoid_len - 2; i++)
  ------------------
  |  Branch (2899:16): [True: 56, False: 7]
  ------------------
 2900|     56|				key_info->data[i + 1] = aoid[i + 2];
 2901|       |
 2902|      7|			free(aoid);
 2903|      7|		}
 2904|       |
 2905|       |		/* RSA */
 2906|    207|		else if (key_info->algorithm == SC_OPENPGP_KEYALGO_RSA){
  ------------------
  |  |  870|    207|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  |  Branch (2906:12): [True: 207, False: 0]
  ------------------
 2907|       |
 2908|       |			/* We can not rely on previous key attributes anymore, as it might be ECC */
 2909|    207|			if (key_info->u.rsa.exponent_len == 0 || key_info->u.rsa.modulus_len == 0)
  ------------------
  |  Branch (2909:8): [True: 0, False: 207]
  |  Branch (2909:45): [True: 0, False: 207]
  ------------------
 2910|    207|				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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2911|       |
 2912|    207|			key_info->data_len = 6;
 2913|    207|			key_info->data = malloc(key_info->data_len);
 2914|    207|			if (!key_info->data)
  ------------------
  |  Branch (2914:8): [True: 0, False: 207]
  ------------------
 2915|    207|				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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2916|       |
 2917|    207|			key_info->data[0] = key_info->algorithm;
 2918|    207|			ushort2bebytes(key_info->data + 1, key_info->u.rsa.modulus_len);
 2919|       |			/* OpenPGP Card only accepts 32bit as exponent length field,
 2920|       |			 * although you can import keys with smaller exponent;
 2921|       |			 * thus we don't change rsa.exponent_len, but ignore it here */
 2922|    207|			ushort2bebytes(key_info->data + 3, SC_OPENPGP_MAX_EXP_BITS);
  ------------------
  |  |  883|    207|#define SC_OPENPGP_MAX_EXP_BITS		0x20 /* maximum exponent length supported in bits */
  ------------------
 2923|       |			/* Import-Format of private key (e,p,q) */
 2924|    207|			key_info->data[5] = SC_OPENPGP_KEYFORMAT_RSA_STD;
  ------------------
  |  |  875|    207|#define SC_OPENPGP_KEYFORMAT_RSA_STD	0    /* See 4.3.3.6 Algorithm Attributes */
  ------------------
 2925|    207|		}
 2926|      0|		else {
 2927|      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__
  |  |  ------------------
  ------------------
 2928|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2929|      0|		}
 2930|       |
 2931|    214|		r = pgp_put_data(card, tag, key_info->data, key_info->data_len);
 2932|       |		/* Note: pgp_put_data calls pgp_set_blob */
 2933|    214|		LOG_TEST_RET(card->ctx, r, "Cannot set new algorithm attributes");
  ------------------
  |  |  174|    214|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    214|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    214|	int _ret = (r); \
  |  |  |  |  168|    214|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 90, False: 124]
  |  |  |  |  ------------------
  |  |  |  |  169|     90|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     90|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     90|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     90|		return _ret; \
  |  |  |  |  172|     90|	} \
  |  |  |  |  173|    214|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 124]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2934|    214|	} else {
 2935|      8|		sc_cardctl_openpgp_key_gen_store_info_t old_key_info;
 2936|       |
 2937|      8|		if (pgp_parse_algo_attr_blob(card, algo_blob, &old_key_info) != SC_SUCCESS
  ------------------
  |  |   28|     16|#define SC_SUCCESS				0
  ------------------
  |  Branch (2937:7): [True: 3, False: 5]
  ------------------
 2938|      5|				|| old_key_info.algorithm != key_info->algorithm)
  ------------------
  |  Branch (2938:8): [True: 3, False: 2]
  ------------------
 2939|      8|			LOG_TEST_RET(card->ctx, SC_ERROR_NO_CARD_SUPPORT,
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2940|      8|					"Requested algorithm not supported");
 2941|       |		/* FIXME check whether the static parameters match the requested ones. */
 2942|      8|	}
 2943|       |
 2944|    126|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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: 2, False: 124]
  |  |  |  |  ------------------
  |  |  |  |  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|    124|	} else { \
  |  |  |  |  159|    124|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    124|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    124|	} \
  |  |  |  |  162|    126|	return _ret; \
  |  |  |  |  163|    126|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2945|    126|}
card-openpgp.c:pgp_parse_and_set_pubkey_output:
 3256|    118|{
 3257|    118|	time_t ctime = 0;
 3258|    118|	u8 *in = data;
 3259|    118|	int r;
 3260|    118|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    118|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    118|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    118|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    118|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 118]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3261|       |
 3262|       |	/* store creation time */
 3263|    118|	r = pgp_store_creationtime(card, key_info->key_id, &ctime);
 3264|    118|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|    118|#define SC_SUCCESS				0
  ------------------
  |  Branch (3264:6): [True: 118, False: 0]
  ------------------
 3265|       |		/* TODO for now with GNUK at least, log but do not return error */
 3266|    118|		sc_log(card->ctx, "Cannot store creation time");
  ------------------
  |  |   71|    118|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3267|    118|	}
 3268|       |
 3269|       |	/* parse response. Ref: pgp_enumerate_blob() */
 3270|    837|	while (data_len > (size_t) (in - data)) {
  ------------------
  |  Branch (3270:9): [True: 787, False: 50]
  ------------------
 3271|    787|		unsigned int cla, tag, tmptag;
 3272|    787|		size_t		len;
 3273|    787|		u8	*part = in;
 3274|       |
 3275|       |		/* parse TLV structure */
 3276|    787|		r = sc_asn1_read_tag((const u8**)&part, data_len - (in - data), &cla, &tag, &len);
 3277|    787|		if (part == NULL)
  ------------------
  |  Branch (3277:7): [True: 41, False: 746]
  ------------------
 3278|     41|			r = SC_ERROR_ASN1_OBJECT_NOT_FOUND;
  ------------------
  |  |   83|     41|#define SC_ERROR_ASN1_OBJECT_NOT_FOUND		-1402
  ------------------
 3279|    787|		LOG_TEST_RET(card->ctx, r, "Unexpected end of contents");
  ------------------
  |  |  174|    787|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    787|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    787|	int _ret = (r); \
  |  |  |  |  168|    787|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 64, False: 723]
  |  |  |  |  ------------------
  |  |  |  |  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|    787|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 723]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3280|       |		/* undo ASN1's split of tag & class */
 3281|    848|		for (tmptag = tag; tmptag > 0x0FF; tmptag >>= 8) {
  ------------------
  |  Branch (3281:22): [True: 125, False: 723]
  ------------------
 3282|    125|			cla <<= 8;
 3283|    125|		}
 3284|    723|		tag |= cla;
 3285|       |
 3286|       |		/* RSA modulus */
 3287|    723|		if (tag == 0x0081) {
  ------------------
  |  Branch (3287:7): [True: 42, False: 681]
  ------------------
 3288|     42|			if (key_info->algorithm != SC_OPENPGP_KEYALGO_RSA) {
  ------------------
  |  |  870|     42|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  |  Branch (3288:8): [True: 1, False: 41]
  ------------------
 3289|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3290|      1|			}
 3291|     41|			if ((BYTES4BITS(key_info->u.rsa.modulus_len) < len)  /* modulus_len is in bits */
  ------------------
  |  |  146|     41|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  |  Branch (3291:8): [True: 8, False: 33]
  ------------------
 3292|     33|				|| key_info->u.rsa.modulus == NULL) {
  ------------------
  |  Branch (3292:8): [True: 0, False: 33]
  ------------------
 3293|       |
 3294|      8|				free(key_info->u.rsa.modulus);
 3295|      8|				key_info->u.rsa.modulus = malloc(len);
 3296|      8|				if (key_info->u.rsa.modulus == NULL)
  ------------------
  |  Branch (3296:9): [True: 0, False: 8]
  ------------------
 3297|      8|					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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3298|      8|			}
 3299|       |
 3300|       |			/* set values */
 3301|     41|			memcpy(key_info->u.rsa.modulus, part, len);
 3302|     41|			key_info->u.rsa.modulus_len = len * 8; /* store length in bits */
 3303|     41|		}
 3304|       |		/* RSA public exponent */
 3305|    681|		else if (tag == 0x0082) {
  ------------------
  |  Branch (3305:12): [True: 142, False: 539]
  ------------------
 3306|    142|			if (key_info->algorithm != SC_OPENPGP_KEYALGO_RSA) {
  ------------------
  |  |  870|    142|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  |  Branch (3306:8): [True: 1, False: 141]
  ------------------
 3307|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3308|      1|			}
 3309|    141|			if ((BYTES4BITS(key_info->u.rsa.exponent_len) < len)  /* exponent_len is in bits */
  ------------------
  |  |  146|    141|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  |  Branch (3309:8): [True: 59, False: 82]
  ------------------
 3310|     82|				|| key_info->u.rsa.exponent == NULL) {
  ------------------
  |  Branch (3310:8): [True: 0, False: 82]
  ------------------
 3311|       |
 3312|     59|				free(key_info->u.rsa.exponent);
 3313|     59|				key_info->u.rsa.exponent = malloc(len);
 3314|     59|				if (key_info->u.rsa.exponent == NULL)
  ------------------
  |  Branch (3314:9): [True: 0, False: 59]
  ------------------
 3315|     59|					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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3316|     59|			}
 3317|       |
 3318|       |			/* set values */
 3319|    141|			memcpy(key_info->u.rsa.exponent, part, len);
 3320|    141|			key_info->u.rsa.exponent_len = len * 8; /* store length in bits */
 3321|    141|		}
 3322|       |		/* ECC or EDDSA public key */
 3323|    539|		else if (tag == 0x0086) {
  ------------------
  |  Branch (3323:12): [True: 2, False: 537]
  ------------------
 3324|       |			/* Note: SC_OPENPGP_KEYALGO_ECDH could be either EC or XEDDSA */
 3325|      2|			if (key_info->algorithm != SC_OPENPGP_KEYALGO_ECDSA &&
  ------------------
  |  |  872|      4|#define	SC_OPENPGP_KEYALGO_ECDSA	0x13
  ------------------
  |  Branch (3325:8): [True: 1, False: 1]
  ------------------
 3326|      1|					key_info->algorithm != SC_OPENPGP_KEYALGO_ECDH &&
  ------------------
  |  |  871|      3|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (3326:6): [True: 1, False: 0]
  ------------------
 3327|      1|					key_info->algorithm != SC_OPENPGP_KEYALGO_EDDSA) {
  ------------------
  |  |  873|      1|#define	SC_OPENPGP_KEYALGO_EDDSA	0x16
  ------------------
  |  Branch (3327:6): [True: 1, False: 0]
  ------------------
 3328|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3329|      1|			}
 3330|       |			/* set the output data */
 3331|       |			/* key_info->u.ec.ecpoint_len is already set based on
 3332|       |			 * key_info->key_type
 3333|       |			 * EC is in 04||x||y format i.e.
 3334|       |			 *    (field_length + 7)/8 * 2 + 1 in bytes
 3335|       |			 *    len is ecpoint length + format byte
 3336|       |			 *    see section 7.2.14 of 3.3.1 specs
 3337|       |			 * EDDSA and XEDDSA have no format byte and one number
 3338|       |			 *    (field_length + 7)/8 in bytes
 3339|       |			 */
 3340|       |			/* GNUK returns 04||x||y */
 3341|       |
 3342|      1|			if (len != key_info->u.ec.ecpointQ_len)
  ------------------
  |  Branch (3342:8): [True: 1, False: 0]
  ------------------
 3343|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3344|       |
 3345|      0|			switch (key_info->key_type) {
 3346|      0|			case SC_ALGORITHM_EC:
  ------------------
  |  |   70|      0|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (3346:4): [True: 0, False: 0]
  ------------------
 3347|      0|			case SC_ALGORITHM_EDDSA:
  ------------------
  |  |   72|      0|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (3347:4): [True: 0, False: 0]
  ------------------
 3348|      0|			case SC_ALGORITHM_XEDDSA:
  ------------------
  |  |   73|      0|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (3348:4): [True: 0, False: 0]
  ------------------
 3349|      0|				key_info->u.ec.ecpointQ = malloc(len);
 3350|      0|				if (key_info->u.ec.ecpointQ == NULL)
  ------------------
  |  Branch (3350:9): [True: 0, False: 0]
  ------------------
 3351|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3352|      0|				memcpy(key_info->u.ec.ecpointQ, part, len);
 3353|      0|				key_info->u.ec.ecpointQ_len = len;
 3354|      0|				break;
 3355|      0|			default:
  ------------------
  |  Branch (3355:4): [True: 0, False: 0]
  ------------------
 3356|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3357|      0|			}
 3358|      0|		}
 3359|       |
 3360|       |		/* go to next part to parse */
 3361|       |		/* This will be different from pgp_enumerate_blob() a bit */
 3362|    719|		in = part + ((tag != 0x7F49) ? len : 0);
  ------------------
  |  Branch (3362:16): [True: 709, False: 10]
  ------------------
 3363|    719|	}
 3364|       |
 3365|       |	/* calculate and store fingerprint */
 3366|     50|	sc_log(card->ctx, "Calculate and store fingerprint");
  ------------------
  |  |   71|     50|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3367|     50|	r = pgp_calculate_and_store_fingerprint(card, ctime, key_info);
 3368|     50|	LOG_TEST_RET(card->ctx, r, "Cannot store fingerprint");
  ------------------
  |  |  174|     50|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     50|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     50|	int _ret = (r); \
  |  |  |  |  168|     50|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 46, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  169|     46|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     46|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     46|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     46|		return _ret; \
  |  |  |  |  172|     46|	} \
  |  |  |  |  173|     50|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3369|       |	/* TODO only try and update pubkey if present */
 3370|       |
 3371|       |	/* update pubkey blobs (B601, B801, A401) */
 3372|      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__
  |  |  ------------------
  ------------------
 3373|      4|	r = pgp_update_pubkey_blob(card, key_info);
 3374|       |
 3375|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3376|      4|}
card-openpgp.c:pgp_store_creationtime:
 2956|    118|{
 2957|    118|	int r;
 2958|    118|	time_t createtime = 0;
 2959|    118|	const size_t timestrlen = 64;
 2960|    118|	char timestring[65];
 2961|    118|	u8 buf[4];
 2962|    118|	struct tm tm;
 2963|       |
 2964|    118|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    118|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    118|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    118|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    118|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 118]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2965|       |
 2966|    118|	if (key_id < 1 || key_id > 3)
  ------------------
  |  Branch (2966:6): [True: 0, False: 118]
  |  Branch (2966:20): [True: 0, False: 118]
  ------------------
 2967|    118|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2968|    118|				"Invalid key ID; must be 1, 2, or 3");
 2969|       |
 2970|    118|	if (outtime != NULL && *outtime != 0)
  ------------------
  |  Branch (2970:6): [True: 118, False: 0]
  |  Branch (2970:25): [True: 0, False: 118]
  ------------------
 2971|      0|		createtime = *outtime;
 2972|    118|	else if (outtime != NULL)
  ------------------
  |  Branch (2972:11): [True: 118, False: 0]
  ------------------
 2973|       |		/* set output */
 2974|    118|		*outtime = createtime = time(NULL);
 2975|       |
 2976|       |#ifdef _WIN32
 2977|       |	if (0 != gmtime_s(&tm, &createtime))
 2978|       |		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
 2979|       |#else
 2980|    118|	if (NULL == gmtime_r(&createtime, &tm))
  ------------------
  |  Branch (2980:6): [True: 0, False: 118]
  ------------------
 2981|    118|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2982|    118|#endif
 2983|    118|	strftime(timestring, timestrlen, "%c %Z", &tm);
 2984|    118|	sc_log(card->ctx, "Creation time %s.", timestring);
  ------------------
  |  |   71|    118|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2985|       |	/* Code borrowed from GnuPG */
 2986|    118|	ulong2bebytes(buf, (unsigned long)createtime);
 2987|    118|	r = pgp_put_data(card, 0x00CD + key_id, buf, 4);
 2988|    118|	LOG_TEST_RET(card->ctx, r, "Cannot write to DO");
  ------------------
  |  |  174|    118|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    118|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    118|	int _ret = (r); \
  |  |  |  |  168|    118|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 95, False: 23]
  |  |  |  |  ------------------
  |  |  |  |  169|     95|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     95|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     95|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     95|		return _ret; \
  |  |  |  |  172|     95|	} \
  |  |  |  |  173|    118|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 23]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2989|     23|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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: 0, False: 23]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     23|	} 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|     23|	return _ret; \
  |  |  |  |  163|     23|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2990|     23|}
card-openpgp.c:pgp_calculate_and_store_fingerprint:
 3000|     50|{
 3001|     50|	u8 fingerprint[SHA_DIGEST_LENGTH];
 3002|     50|	u8 *fp_buffer = NULL;  /* fingerprint buffer, not hashed */
 3003|     50|	size_t fp_buffer_len;
 3004|     50|	u8 *p; /* use this pointer to set fp_buffer content */
 3005|     50|	size_t pk_packet_len;
 3006|     50|	unsigned int tag = 0x00C6 + key_info->key_id;
 3007|     50|	pgp_blob_t *fpseq_blob = NULL;
 3008|     50|	u8 *newdata = NULL;
 3009|     50|	int r;
 3010|       |
 3011|     50|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     50|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     50|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     50|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     50|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 50]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3012|       |
 3013|       |	/* constructing public-key packet length */
 3014|       |	/* RSA */
 3015|     50|	if (key_info->algorithm == SC_OPENPGP_KEYALGO_RSA) {
  ------------------
  |  |  870|     50|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  |  Branch (3015:6): [True: 48, False: 2]
  ------------------
 3016|       |
 3017|     48|		if (key_info->u.rsa.modulus == NULL
  ------------------
  |  Branch (3017:7): [True: 0, False: 48]
  ------------------
 3018|     48|			|| key_info->u.rsa.exponent == NULL
  ------------------
  |  Branch (3018:7): [True: 0, False: 48]
  ------------------
 3019|     48|			|| (key_info->u.rsa.modulus_len) == 0
  ------------------
  |  Branch (3019:7): [True: 2, False: 46]
  ------------------
 3020|     46|			|| (key_info->u.rsa.exponent_len) == 0) {
  ------------------
  |  Branch (3020:7): [True: 1, False: 45]
  ------------------
 3021|       |
 3022|      3|			sc_log(card->ctx, "Null data (modulus or exponent)");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3023|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3024|      3|		}
 3025|       |
 3026|       |		/* https://tools.ietf.org/html/rfc4880  page 41, 72 */
 3027|     45|		pk_packet_len =   1   /* version number */
 3028|     45|				+ 4   /* creation time */
 3029|     45|				+ 1   /* algorithm */
 3030|     45|				+ 2   /* algorithm-specific fields: RSA modulus+exponent */
 3031|     45|				+ (BYTES4BITS(key_info->u.rsa.modulus_len))
  ------------------
  |  |  146|     45|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
 3032|     45|				+ 2
 3033|     45|				+ (BYTES4BITS(key_info->u.rsa.exponent_len));
  ------------------
  |  |  146|     45|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
 3034|       |
 3035|     45|	}
 3036|       |	/* ECC */
 3037|      2|	else if (key_info->algorithm == SC_OPENPGP_KEYALGO_ECDH || /* also includes XEDDSA */
  ------------------
  |  |  871|      4|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (3037:11): [True: 0, False: 2]
  ------------------
 3038|      2|			key_info->algorithm == SC_OPENPGP_KEYALGO_ECDSA ||
  ------------------
  |  |  872|      4|#define	SC_OPENPGP_KEYALGO_ECDSA	0x13
  ------------------
  |  Branch (3038:4): [True: 2, False: 0]
  ------------------
 3039|      2|			key_info->algorithm == SC_OPENPGP_KEYALGO_EDDSA) {
  ------------------
  |  |  873|      0|#define	SC_OPENPGP_KEYALGO_EDDSA	0x16
  ------------------
  |  Branch (3039:4): [True: 0, False: 0]
  ------------------
 3040|      2|		if (key_info->u.ec.ecpointQ == NULL || (key_info->u.ec.ecpointQ_len) == 0) {
  ------------------
  |  Branch (3040:7): [True: 2, False: 0]
  |  Branch (3040:42): [True: 0, False: 0]
  ------------------
 3041|      2|			sc_log(card->ctx, "Error: ecpoint required!");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3042|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3043|      2|		}
 3044|       |
 3045|       |		/* https://tools.ietf.org/html/rfc4880  page 41, 72
 3046|       |		 * and https://tools.ietf.org/html/rfc6637 section 9 (page 8 and 9) */
 3047|      0|		pk_packet_len = 1			       /* version number */
 3048|      0|				+ 4			       /* creation time */
 3049|      0|				+ 1			       /* algorithm */
 3050|      0|				+ 1			       /* oid len */
 3051|      0|				+ key_info->u.ec.oidv_len      /* oid */
 3052|      0|				+ key_info->u.ec.ecpointQ_len; /* ecpoint */
 3053|       |
 3054|       |		/* KDF parameters for ECDH */
 3055|      0|		if (key_info->algorithm == SC_OPENPGP_KEYALGO_ECDH) {
  ------------------
  |  |  871|      0|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (3055:7): [True: 0, False: 0]
  ------------------
 3056|       |			/* https://tools.ietf.org/html/rfc6637#section-8 */
 3057|      0|			pk_packet_len +=   1	/* number of bytes */
 3058|      0|					 + 1	/* version number */
 3059|      0|					 + 1	/* KDF algo */
 3060|      0|					 + 1;	/* KEK algo */
 3061|      0|		}
 3062|      0|	} else
 3063|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3064|     45|	sc_log(card->ctx, "pk_packet_len is %zu", pk_packet_len);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3065|       |
 3066|     45|	fp_buffer_len = 3 + pk_packet_len;
 3067|     45|	p = fp_buffer = calloc(1, fp_buffer_len);
 3068|     45|	if (p == NULL)
  ------------------
  |  Branch (3068:6): [True: 0, False: 45]
  ------------------
 3069|     45|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3070|       |
 3071|       |	/* constructing public-key packet */
 3072|     45|	p[0] = 0x99;   /* http://tools.ietf.org/html/rfc4880  page 71 */
 3073|     45|	ushort2bebytes(++p, (unsigned short)pk_packet_len);
 3074|       |	/* start pk_packet */
 3075|     45|	p += 2;
 3076|     45|	*p = 4;        /* Version 4 key */
 3077|     45|	ulong2bebytes(++p, (unsigned long)ctime);    /* Creation time */
 3078|     45|	p += 4;
 3079|       |
 3080|       |	/* RSA */
 3081|     45|	if (key_info->algorithm == SC_OPENPGP_KEYALGO_RSA) {
  ------------------
  |  |  870|     45|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  |  Branch (3081:6): [True: 45, False: 0]
  ------------------
 3082|     45|		unsigned short bytes_length = 0;
 3083|       |
 3084|     45|		*p = 1; /* Algorithm ID, RSA */
 3085|     45|		p += 1;
 3086|       |
 3087|       |		/* Modulus */
 3088|     45|		bytes_length = BYTES4BITS(key_info->u.rsa.modulus_len);
  ------------------
  |  |  146|     45|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
 3089|     45|		ushort2bebytes(p, (unsigned short)key_info->u.rsa.modulus_len);
 3090|     45|		p += 2;
 3091|     45|		memcpy(p, key_info->u.rsa.modulus, bytes_length);
 3092|     45|		p += bytes_length;
 3093|       |
 3094|       |		/* Exponent */
 3095|     45|		bytes_length = BYTES4BITS(key_info->u.rsa.exponent_len);
  ------------------
  |  |  146|     45|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
 3096|     45|		ushort2bebytes(p, (unsigned short)key_info->u.rsa.exponent_len);
 3097|     45|		p += 2;
 3098|     45|		memcpy(p, key_info->u.rsa.exponent, bytes_length);
 3099|     45|	}
 3100|       |	/* ECC */
 3101|      0|	else if (key_info->algorithm == SC_OPENPGP_KEYALGO_ECDH || /* includes XEDDSA */
  ------------------
  |  |  871|      0|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (3101:11): [True: 0, False: 0]
  ------------------
 3102|      0|			key_info->algorithm == SC_OPENPGP_KEYALGO_ECDSA ||
  ------------------
  |  |  872|      0|#define	SC_OPENPGP_KEYALGO_ECDSA	0x13
  ------------------
  |  Branch (3102:4): [True: 0, False: 0]
  ------------------
 3103|      0|			key_info->algorithm == SC_OPENPGP_KEYALGO_EDDSA) {
  ------------------
  |  |  873|      0|#define	SC_OPENPGP_KEYALGO_EDDSA	0x16
  ------------------
  |  Branch (3103:4): [True: 0, False: 0]
  ------------------
 3104|       |		/* Algorithm ID, see https://tools.ietf.org/html/rfc6637#section-5 */
 3105|      0|		*p = key_info->algorithm + 6;
 3106|      0|		p += 1;
 3107|      0|		*p = key_info->u.ec.oidv_len;
 3108|      0|		p += 1;
 3109|      0|		memcpy(p, key_info->u.ec.oidv.value, key_info->u.ec.oidv_len);
 3110|      0|		p += key_info->u.ec.oidv_len;
 3111|      0|		memcpy(p, key_info->u.ec.ecpointQ, key_info->u.ec.ecpointQ_len);
 3112|       |
 3113|       |		/* KDF parameters for ECDH */
 3114|      0|		if (key_info->algorithm == SC_OPENPGP_KEYALGO_ECDH) {
  ------------------
  |  |  871|      0|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (3114:7): [True: 0, False: 0]
  ------------------
 3115|       |			/* https://tools.ietf.org/html/rfc6637#section-8
 3116|       |			 * This is copied from GnuPG's ecdh_params() function in app-openpgp.c */
 3117|      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 */
  ------------------
 3118|      0|			*p = 0x03; /* number of bytes following */
 3119|      0|			p += 1;
 3120|      0|			*p = 0x01; /* version of this format */
 3121|      0|			p += 1;
 3122|      0|			if (key_info->u.ec.key_length <= 256) { /* ec bit size <= 256 */
  ------------------
  |  Branch (3122:8): [True: 0, False: 0]
  ------------------
 3123|      0|				*p = 0x08;	/* KDF algo */
 3124|      0|				*(p+1) = 0x07;	/* KEK algo */
 3125|      0|			} else if (key_info->u.ec.key_length <= 384) { /* ec bit size <= 384 */
  ------------------
  |  Branch (3125:15): [True: 0, False: 0]
  ------------------
 3126|      0|				*p = 0x09;	/* KDF algo */
 3127|      0|				*(p+1) = 0x08;	/* KEK algo */
 3128|      0|			} else {		/* ec bit size = 512 or 521*/
 3129|      0|				*p = 0x0a;	/* KDF algo */
 3130|      0|				*(p+1) = 0x09;	/* KEK algo */
 3131|      0|			}
 3132|      0|		}
 3133|      0|	} else
 3134|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3135|       |
 3136|     45|	p = NULL;
 3137|       |
 3138|       |	/* hash with SHA-1 */
 3139|     45|	SHA1(fp_buffer, fp_buffer_len, fingerprint);
 3140|     45|	free(fp_buffer);
 3141|       |
 3142|       |	/* store to DO */
 3143|     45|	sc_log(card->ctx, "Writing to DO %04X.", tag);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3144|     45|	r = pgp_put_data(card, tag, fingerprint, SHA_DIGEST_LENGTH);
 3145|     45|	LOG_TEST_RET(card->ctx, r, "Cannot write to DO");
  ------------------
  |  |  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: 27, False: 18]
  |  |  |  |  ------------------
  |  |  |  |  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|     45|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 18]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3146|       |
 3147|       |	/* update the blob containing fingerprints (00C5) */
 3148|     18|	sc_log(card->ctx, "Updating fingerprint blob 00C5.");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3149|     18|	fpseq_blob = pgp_find_blob(card, 0x00C5);
 3150|     18|	if (fpseq_blob == NULL) {
  ------------------
  |  Branch (3150:6): [True: 13, False: 5]
  ------------------
 3151|     13|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|     13|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 3152|     13|		LOG_TEST_GOTO_ERR(card->ctx, r, "Cannot find blob 00C5");
  ------------------
  |  |  184|     13|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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: 13, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|     13|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3153|     13|	}
 3154|      5|	if (20U * key_info->key_id > fpseq_blob->len) {
  ------------------
  |  Branch (3154:6): [True: 1, False: 4]
  ------------------
 3155|      1|		r = SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      1|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
 3156|      1|		LOG_TEST_GOTO_ERR(card->ctx, r, "The 00C5 blob is not large enough");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3157|      1|	}
 3158|       |
 3159|       |	/* save the fingerprints sequence */
 3160|      4|	newdata = malloc(fpseq_blob->len);
 3161|      4|	if (newdata == NULL) {
  ------------------
  |  Branch (3161:6): [True: 0, False: 4]
  ------------------
 3162|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 3163|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3164|      0|	}
 3165|       |
 3166|      4|	memcpy(newdata, fpseq_blob->data, fpseq_blob->len);
 3167|       |	/* move p to the portion holding the fingerprint of the current key */
 3168|      4|	p = newdata + 20 * (key_info->key_id - 1);
 3169|       |	/* copy new fingerprint value */
 3170|      4|	memcpy(p, fingerprint, 20);
 3171|       |	/* set blob's data */
 3172|      4|	pgp_set_blob(fpseq_blob, newdata, fpseq_blob->len);
 3173|      4|	free(newdata);
 3174|       |
 3175|     18|err:
 3176|     18|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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: 14, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  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|      4|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      4|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      4|	} \
  |  |  |  |  162|     18|	return _ret; \
  |  |  |  |  163|     18|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3177|     18|}
card-openpgp.c:pgp_update_pubkey_blob:
 3186|      4|{
 3187|      4|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|      4|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 3188|      4|	pgp_blob_t *pk_blob;
 3189|      4|	unsigned int blob_id = 0;
 3190|      4|	sc_pkcs15_pubkey_t p15pubkey;
 3191|      4|	u8 *data = NULL;
 3192|      4|	size_t len;
 3193|      4|	int r;
 3194|       |
 3195|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3196|       |
 3197|      4|	if (key_info->key_id == SC_OPENPGP_KEY_SIGN)
  ------------------
  |  |  866|      4|#define SC_OPENPGP_KEY_SIGN		1
  ------------------
  |  Branch (3197:6): [True: 0, False: 4]
  ------------------
 3198|      0|		blob_id = DO_SIGN_SYM;
  ------------------
  |  |  145|      0|#define DO_SIGN_SYM              0xb601
  ------------------
 3199|      4|	else if (key_info->key_id == SC_OPENPGP_KEY_ENCR)
  ------------------
  |  |  867|      4|#define SC_OPENPGP_KEY_ENCR		2
  ------------------
  |  Branch (3199:11): [True: 0, False: 4]
  ------------------
 3200|      0|		blob_id = DO_ENCR_SYM;
  ------------------
  |  |  146|      0|#define DO_ENCR_SYM              0xb801
  ------------------
 3201|      4|	else if (key_info->key_id == SC_OPENPGP_KEY_AUTH)
  ------------------
  |  |  868|      4|#define SC_OPENPGP_KEY_AUTH		3
  ------------------
  |  Branch (3201:11): [True: 4, False: 0]
  ------------------
 3202|      4|		blob_id = DO_AUTH_SYM;
  ------------------
  |  |  147|      4|#define DO_AUTH_SYM              0xa401
  ------------------
 3203|      0|	else {
 3204|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3205|      0|				"Invalid key ID; must be 1, 2, or 3");
 3206|      0|	}
 3207|       |
 3208|      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__
  |  |  ------------------
  ------------------
 3209|      4|	r = pgp_get_blob(card, priv->mf, blob_id, &pk_blob);
 3210|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3211|       |
 3212|       |	/* encode pubkey */
 3213|       |	/* RSA */
 3214|      4|	if (key_info->algorithm == SC_OPENPGP_KEYALGO_RSA){
  ------------------
  |  |  870|      4|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  |  Branch (3214:6): [True: 4, False: 0]
  ------------------
 3215|      4|		memset(&p15pubkey, 0, sizeof(p15pubkey));
 3216|      4|		p15pubkey.algorithm = SC_ALGORITHM_RSA;
  ------------------
  |  |   69|      4|#define SC_ALGORITHM_RSA		0
  ------------------
 3217|      4|		p15pubkey.u.rsa.modulus.data  = key_info->u.rsa.modulus;
 3218|      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 */
  ------------------
 3219|      4|		p15pubkey.u.rsa.exponent.data = key_info->u.rsa.exponent;
 3220|      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 */
  ------------------
 3221|      4|	}
 3222|       |	/* ECC */
 3223|      0|	else if (key_info->algorithm == SC_OPENPGP_KEYALGO_ECDH || /* includes XEDDSA */
  ------------------
  |  |  871|      0|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (3223:11): [True: 0, False: 0]
  ------------------
 3224|      0|			key_info->algorithm == SC_OPENPGP_KEYALGO_ECDSA ||
  ------------------
  |  |  872|      0|#define	SC_OPENPGP_KEYALGO_ECDSA	0x13
  ------------------
  |  Branch (3224:4): [True: 0, False: 0]
  ------------------
 3225|      0|			key_info->algorithm == SC_OPENPGP_KEYALGO_EDDSA) {
  ------------------
  |  |  873|      0|#define	SC_OPENPGP_KEYALGO_EDDSA	0x16
  ------------------
  |  Branch (3225:4): [True: 0, False: 0]
  ------------------
 3226|      0|		memset(&p15pubkey, 0, sizeof(p15pubkey));
 3227|      0|		p15pubkey.algorithm = key_info->key_type;
 3228|      0|		p15pubkey.u.ec.ecpointQ.value = key_info->u.ec.ecpointQ;
 3229|      0|		p15pubkey.u.ec.ecpointQ.len = key_info->u.ec.ecpointQ_len;
 3230|      0|	} else
 3231|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3232|       |
 3233|      4|	r = sc_pkcs15_encode_pubkey_as_spki(card->ctx, &p15pubkey, &data, &len);
 3234|       |	/*
 3235|       |	 * key_info is missing an algo_id. sc_pkcs15_encode_pubkey_as_spki
 3236|       |	 * allocates one. Free it here.
 3237|       |	 */
 3238|      4|	free(p15pubkey.alg_id);
 3239|      4|	p15pubkey.alg_id = NULL;
 3240|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3241|       |
 3242|      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__
  |  |  ------------------
  ------------------
 3243|      4|	r = pgp_set_blob(pk_blob, data, len);
 3244|      4|	free(data);
 3245|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3246|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3247|      4|}
card-openpgp.c:pgp_update_card_algorithms:
 3384|      4|{
 3385|      4|	sc_algorithm_info_t *algo;
 3386|      4|	u8 id = key_info->key_id;
 3387|      4|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|      4|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 3388|       |
 3389|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3390|       |
 3391|       |	/* protect incompatible cards against non-RSA */
 3392|      4|	if (key_info->algorithm != SC_OPENPGP_KEYALGO_RSA &&
  ------------------
  |  |  870|      8|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  |  Branch (3392:6): [True: 0, False: 4]
  ------------------
 3393|      0|			priv->bcd_version < OPENPGP_CARD_3_0 &&
  ------------------
  |  Branch (3393:4): [True: 0, False: 0]
  ------------------
 3394|      0|			card->type != SC_CARD_TYPE_OPENPGP_GNUK)
  ------------------
  |  Branch (3394:4): [True: 0, False: 0]
  ------------------
 3395|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3396|       |
 3397|      4|	if (id > card->algorithm_count) {
  ------------------
  |  Branch (3397:6): [True: 0, False: 4]
  ------------------
 3398|      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__
  |  |  ------------------
  ------------------
 3399|      0|		       "This key ID %u is out of the card's algorithm list.",
 3400|      0|		       (unsigned int)id);
 3401|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3402|      0|	}
 3403|       |
 3404|       |	/* get the algorithm corresponding to the key ID */
 3405|      4|	algo = card->algorithms + (id - 1);
 3406|       |	/* update new key attribute */
 3407|      4|	if (key_info->algorithm == SC_OPENPGP_KEYALGO_RSA) {
  ------------------
  |  |  870|      4|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  |  Branch (3407:6): [True: 4, False: 0]
  ------------------
 3408|      4|		algo->algorithm = SC_ALGORITHM_RSA;
  ------------------
  |  |   69|      4|#define SC_ALGORITHM_RSA		0
  ------------------
 3409|      4|		algo->key_length = (unsigned int)key_info->u.rsa.modulus_len;
 3410|      4|	} else if (key_info->algorithm == SC_OPENPGP_KEYALGO_ECDH || /* includes XEDDSA */
  ------------------
  |  |  871|      0|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (3410:13): [True: 0, False: 0]
  ------------------
 3411|      0|			key_info->algorithm == SC_OPENPGP_KEYALGO_ECDSA ||
  ------------------
  |  |  872|      0|#define	SC_OPENPGP_KEYALGO_ECDSA	0x13
  ------------------
  |  Branch (3411:4): [True: 0, False: 0]
  ------------------
 3412|      0|			key_info->algorithm == SC_OPENPGP_KEYALGO_EDDSA) {
  ------------------
  |  |  873|      0|#define	SC_OPENPGP_KEYALGO_EDDSA	0x16
  ------------------
  |  Branch (3412:4): [True: 0, False: 0]
  ------------------
 3413|      0|		algo->algorithm = SC_ALGORITHM_EC;
  ------------------
  |  |   70|      0|#define SC_ALGORITHM_EC		2
  ------------------
 3414|      0|		algo->key_length = (unsigned int)((key_info->u.ec.ecpointQ_len));
 3415|      0|	} else
 3416|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3417|       |
 3418|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3419|      4|}
card-openpgp.c:pgp_update_binary:
 4143|     37|{
 4144|     37|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|     37|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 4145|     37|	pgp_blob_t *blob = priv->current;
 4146|     37|	int r = SC_SUCCESS;
  ------------------
  |  |   28|     37|#define SC_SUCCESS				0
  ------------------
 4147|       |
 4148|     37|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     37|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     37|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     37|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     37|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 37]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4149|       |
 4150|       |	/* We will use PUT DATA to write to DO.
 4151|       |	 * As PUT DATA does not support idx, we don't either */
 4152|     37|	if (idx > 0)
  ------------------
  |  Branch (4152:6): [True: 13, False: 24]
  ------------------
 4153|     37|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS);
  ------------------
  |  |  164|     13|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     13|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     13|	int _ret = r; \
  |  |  |  |  155|     13|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 13, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     13|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     13|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 13, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     13|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     13|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     13|	return _ret; \
  |  |  |  |  163|     13|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4154|       |
 4155|       |	/* When a dummy file, e.g "11001101", is selected, the current blob
 4156|       |	 * is set to NULL. We don't really put data to dummy file. */
 4157|     24|	if (blob != NULL) {
  ------------------
  |  Branch (4157:6): [True: 24, False: 0]
  ------------------
 4158|     24|		r = pgp_put_data(card, blob->id, buf, count);
 4159|     24|	}
 4160|       |
 4161|     24|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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: 5, False: 19]
  |  |  |  |  ------------------
  |  |  |  |  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|     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|     24|	return _ret; \
  |  |  |  |  163|     24|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4162|     24|}
card-openpgp.c:pgp_card_reader_lock_obtained:
 4169|  13.4k|{
 4170|  13.4k|	struct pgp_priv_data *priv = DRVDATA(card); /* may be null during initialization */
  ------------------
  |  |  189|  13.4k|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 4171|  13.4k|	int r = SC_SUCCESS;
  ------------------
  |  |   28|  13.4k|#define SC_SUCCESS				0
  ------------------
 4172|       |
 4173|  13.4k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  13.4k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  13.4k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  13.4k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 13.4k]
  |  |  ------------------
  ------------------
 4174|       |
 4175|  13.4k|	if (card->flags & SC_CARD_FLAG_KEEP_ALIVE
  ------------------
  |  |  537|  26.8k|#define SC_CARD_FLAG_KEEP_ALIVE	0x00000004
  ------------------
  |  Branch (4175:6): [True: 0, False: 13.4k]
  ------------------
 4176|      0|			&& was_reset <= 0
  ------------------
  |  Branch (4176:7): [True: 0, False: 0]
  ------------------
 4177|      0|			&& priv != NULL && priv->mf && priv->mf->file) {
  ------------------
  |  Branch (4177:7): [True: 0, False: 0]
  |  Branch (4177:23): [True: 0, False: 0]
  |  Branch (4177:35): [True: 0, False: 0]
  ------------------
 4178|       |		/* check whether applet is still selected */
 4179|      0|		unsigned char aid[16];
 4180|       |
 4181|      0|		r = sc_get_data(card, 0x004F, aid, sizeof aid);
 4182|      0|		if ((size_t) r != priv->mf->file->namelen
  ------------------
  |  Branch (4182:7): [True: 0, False: 0]
  ------------------
 4183|      0|				|| 0 != memcmp(aid, priv->mf->file->name, r)) {
  ------------------
  |  Branch (4183:8): [True: 0, False: 0]
  ------------------
 4184|       |			/* reselect is required */
 4185|      0|			was_reset = 1;
 4186|      0|		}
 4187|      0|		r = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 4188|      0|	}
 4189|       |
 4190|  13.4k|	if (was_reset > 0) {
  ------------------
  |  Branch (4190:6): [True: 0, False: 13.4k]
  ------------------
 4191|      0|		sc_file_t	*file = NULL;
 4192|      0|		sc_path_t	path;
 4193|       |		/* select application "OpenPGP" */
 4194|      0|		sc_format_path("D276:0001:2401", &path);
 4195|      0|		path.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|      0|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
 4196|      0|		r = iso_ops->select_file(card, &path, &file);
 4197|      0|		sc_file_free(file);
 4198|      0|	}
 4199|       |
 4200|  13.4k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  13.4k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  13.4k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  13.4k|	int _ret = r; \
  |  |  |  |  155|  13.4k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 13.4k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  13.4k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 13.4k]
  |  |  |  |  ------------------
  |  |  |  |  157|  13.4k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  13.4k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|  13.4k|	return _ret; \
  |  |  |  |  163|  13.4k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4201|  13.4k|}

sc_get_piv_driver:
 6570|  16.3k|{
 6571|  16.3k|	return sc_get_driver();
 6572|  16.3k|}
card-piv.c:sc_get_driver:
 6543|  16.3k|{
 6544|  16.3k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 6545|       |
 6546|  16.3k|	piv_ops = *iso_drv->ops;
 6547|  16.3k|	piv_ops.match_card = piv_match_card;
 6548|  16.3k|	piv_ops.init = piv_init;
 6549|  16.3k|	piv_ops.finish = piv_finish;
 6550|       |
 6551|  16.3k|	piv_ops.select_file = piv_select_file; /* must use get/put, could emulate? */
 6552|  16.3k|	piv_ops.get_challenge = piv_get_challenge;
 6553|  16.3k|	piv_ops.logout = piv_logout;
 6554|  16.3k|	piv_ops.read_binary = piv_read_binary;
 6555|  16.3k|	piv_ops.write_binary = piv_write_binary;
 6556|  16.3k|	piv_ops.set_security_env = piv_set_security_env;
 6557|  16.3k|	piv_ops.restore_security_env = piv_restore_security_env;
 6558|  16.3k|	piv_ops.compute_signature = piv_compute_signature;
 6559|  16.3k|	piv_ops.decipher = piv_decipher;
 6560|  16.3k|	piv_ops.check_sw = piv_check_sw;
 6561|  16.3k|	piv_ops.card_ctl = piv_card_ctl;
 6562|  16.3k|	piv_ops.pin_cmd = piv_pin_cmd;
 6563|  16.3k|	piv_ops.card_reader_lock_obtained = piv_card_reader_lock_obtained;
 6564|       |
 6565|  16.3k|	return &piv_drv;
 6566|  16.3k|}
card-piv.c:piv_match_card:
 5508|  4.38k|{
 5509|  4.38k|	int r = 0;
 5510|       |
 5511|  4.38k|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d\n", card->type);
  ------------------
  |  |   70|  4.38k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5512|       |	/* piv_match_card may be called with card->type, set by opensc.conf */
 5513|       |	/* user provided card type must be one we know */
 5514|  4.38k|	switch (card->type) {
 5515|  4.38k|	case -1:
  ------------------
  |  Branch (5515:2): [True: 4.38k, False: 0]
  ------------------
 5516|  4.38k|	case SC_CARD_TYPE_PIV_II_BASE:
  ------------------
  |  Branch (5516:2): [True: 0, False: 4.38k]
  ------------------
 5517|  4.38k|	case SC_CARD_TYPE_PIV_II_GENERIC:
  ------------------
  |  Branch (5517:2): [True: 0, False: 4.38k]
  ------------------
 5518|  4.38k|	case SC_CARD_TYPE_PIV_II_HIST:
  ------------------
  |  Branch (5518:2): [True: 0, False: 4.38k]
  ------------------
 5519|  4.38k|	case SC_CARD_TYPE_PIV_II_NEO:
  ------------------
  |  Branch (5519:2): [True: 0, False: 4.38k]
  ------------------
 5520|  4.38k|	case SC_CARD_TYPE_PIV_II_YUBIKEY4:
  ------------------
  |  Branch (5520:2): [True: 0, False: 4.38k]
  ------------------
 5521|  4.38k|	case SC_CARD_TYPE_PIV_II_GI_DE_DUAL_CAC:
  ------------------
  |  Branch (5521:2): [True: 0, False: 4.38k]
  ------------------
 5522|  4.38k|	case SC_CARD_TYPE_PIV_II_GI_DE:
  ------------------
  |  Branch (5522:2): [True: 0, False: 4.38k]
  ------------------
 5523|  4.38k|	case SC_CARD_TYPE_PIV_II_GEMALTO_DUAL_CAC:
  ------------------
  |  Branch (5523:2): [True: 0, False: 4.38k]
  ------------------
 5524|  4.38k|	case SC_CARD_TYPE_PIV_II_GEMALTO:
  ------------------
  |  Branch (5524:2): [True: 0, False: 4.38k]
  ------------------
 5525|  4.38k|	case SC_CARD_TYPE_PIV_II_OBERTHUR_DUAL_CAC:
  ------------------
  |  Branch (5525:2): [True: 0, False: 4.38k]
  ------------------
 5526|  4.38k|	case SC_CARD_TYPE_PIV_II_OBERTHUR:
  ------------------
  |  Branch (5526:2): [True: 0, False: 4.38k]
  ------------------
 5527|  4.38k|	case SC_CARD_TYPE_PIV_II_PIVKEY:
  ------------------
  |  Branch (5527:2): [True: 0, False: 4.38k]
  ------------------
 5528|  4.38k|	case SC_CARD_TYPE_PIV_II_SWISSBIT:
  ------------------
  |  Branch (5528:2): [True: 0, False: 4.38k]
  ------------------
 5529|  4.38k|	case SC_CARD_TYPE_PIV_II_800_73_4:
  ------------------
  |  Branch (5529:2): [True: 0, False: 4.38k]
  ------------------
 5530|  4.38k|	case SC_CARD_TYPE_PIV_II_NITROKEY:
  ------------------
  |  Branch (5530:2): [True: 0, False: 4.38k]
  ------------------
 5531|  4.38k|	case SC_CARD_TYPE_PIV_II_TOKEN2:
  ------------------
  |  Branch (5531:2): [True: 0, False: 4.38k]
  ------------------
 5532|  4.38k|	case SC_CARD_TYPE_PIV_II_PIVAPPLET:
  ------------------
  |  Branch (5532:2): [True: 0, False: 4.38k]
  ------------------
 5533|  4.38k|		break;
 5534|      0|	default:
  ------------------
  |  Branch (5534:2): [True: 0, False: 4.38k]
  ------------------
 5535|      0|		return 0; /* can not handle the card */
 5536|  4.38k|	}
 5537|       |
 5538|  4.38k|	r = sc_lock(card);
 5539|  4.38k|	if (r < 0)
  ------------------
  |  Branch (5539:6): [True: 0, False: 4.38k]
  ------------------
 5540|      0|		return 0;
 5541|       |	/* its one we know, or we can test for it in piv_init */
 5542|  4.38k|	r = piv_match_card_continued(card);
 5543|  4.38k|	sc_unlock(card);
 5544|       |
 5545|  4.38k|	if (r < 0 || !card->drv_data) {
  ------------------
  |  Branch (5545:6): [True: 4.13k, False: 249]
  |  Branch (5545:15): [True: 0, False: 249]
  ------------------
 5546|       |		/* clean up what we left in card */
 5547|  4.13k|		piv_finish(card);
 5548|  4.13k|		return 0; /* match failed */
 5549|  4.13k|	}
 5550|       |
 5551|    249|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d r:%d\n", card->type, r);
  ------------------
  |  |   70|    249|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5552|    249|	return 1; /* matched */
 5553|  4.38k|}
card-piv.c:piv_match_card_continued:
 5557|  4.38k|{
 5558|  4.38k|	int i, r = 0, r2 = 0;
 5559|  4.38k|	int type = -1;
 5560|  4.38k|	piv_private_data_t *priv = NULL;
 5561|  4.38k|	int saved_type = card->type;
 5562|  4.38k|	sc_apdu_t apdu;
 5563|  4.38k|	u8 yubico_version_buf[3] = {0};
 5564|       |
 5565|       |	/* piv_match_card may be called with card->type, set by opensc.conf */
 5566|       |	/* User provided card type must be one we know */
 5567|       |
 5568|  4.38k|	switch (card->type) {
 5569|  4.38k|	case -1:
  ------------------
  |  Branch (5569:2): [True: 4.38k, False: 0]
  ------------------
 5570|  4.38k|	case SC_CARD_TYPE_PIV_II_BASE:
  ------------------
  |  Branch (5570:2): [True: 0, False: 4.38k]
  ------------------
 5571|  4.38k|	case SC_CARD_TYPE_PIV_II_GENERIC:
  ------------------
  |  Branch (5571:2): [True: 0, False: 4.38k]
  ------------------
 5572|  4.38k|	case SC_CARD_TYPE_PIV_II_HIST:
  ------------------
  |  Branch (5572:2): [True: 0, False: 4.38k]
  ------------------
 5573|  4.38k|	case SC_CARD_TYPE_PIV_II_NEO:
  ------------------
  |  Branch (5573:2): [True: 0, False: 4.38k]
  ------------------
 5574|  4.38k|	case SC_CARD_TYPE_PIV_II_YUBIKEY4:
  ------------------
  |  Branch (5574:2): [True: 0, False: 4.38k]
  ------------------
 5575|  4.38k|	case SC_CARD_TYPE_PIV_II_GI_DE_DUAL_CAC:
  ------------------
  |  Branch (5575:2): [True: 0, False: 4.38k]
  ------------------
 5576|  4.38k|	case SC_CARD_TYPE_PIV_II_GI_DE:
  ------------------
  |  Branch (5576:2): [True: 0, False: 4.38k]
  ------------------
 5577|  4.38k|	case SC_CARD_TYPE_PIV_II_GEMALTO_DUAL_CAC:
  ------------------
  |  Branch (5577:2): [True: 0, False: 4.38k]
  ------------------
 5578|  4.38k|	case SC_CARD_TYPE_PIV_II_GEMALTO:
  ------------------
  |  Branch (5578:2): [True: 0, False: 4.38k]
  ------------------
 5579|  4.38k|	case SC_CARD_TYPE_PIV_II_OBERTHUR_DUAL_CAC:
  ------------------
  |  Branch (5579:2): [True: 0, False: 4.38k]
  ------------------
 5580|  4.38k|	case SC_CARD_TYPE_PIV_II_OBERTHUR:
  ------------------
  |  Branch (5580:2): [True: 0, False: 4.38k]
  ------------------
 5581|  4.38k|	case SC_CARD_TYPE_PIV_II_PIVKEY:
  ------------------
  |  Branch (5581:2): [True: 0, False: 4.38k]
  ------------------
 5582|  4.38k|	case SC_CARD_TYPE_PIV_II_SWISSBIT:
  ------------------
  |  Branch (5582:2): [True: 0, False: 4.38k]
  ------------------
 5583|  4.38k|	case SC_CARD_TYPE_PIV_II_800_73_4:
  ------------------
  |  Branch (5583:2): [True: 0, False: 4.38k]
  ------------------
 5584|  4.38k|	case SC_CARD_TYPE_PIV_II_NITROKEY:
  ------------------
  |  Branch (5584:2): [True: 0, False: 4.38k]
  ------------------
 5585|  4.38k|	case SC_CARD_TYPE_PIV_II_TOKEN2:
  ------------------
  |  Branch (5585:2): [True: 0, False: 4.38k]
  ------------------
 5586|  4.38k|	case SC_CARD_TYPE_PIV_II_PIVAPPLET:
  ------------------
  |  Branch (5586:2): [True: 0, False: 4.38k]
  ------------------
 5587|  4.38k|		type = card->type;
 5588|  4.38k|		break;
 5589|      0|	default:
  ------------------
  |  Branch (5589:2): [True: 0, False: 4.38k]
  ------------------
 5590|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5591|  4.38k|	}
 5592|  4.38k|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d type:%d r:%d\n", card->type, type, r);
  ------------------
  |  |   70|  4.38k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5593|  4.38k|	if (type == -1) {
  ------------------
  |  Branch (5593:6): [True: 4.38k, False: 0]
  ------------------
 5594|       |		/*
 5595|       |		 * Try to identify card by ATR or historical data in ATR
 5596|       |		 * currently all PIV card will respond to piv_find_aid
 5597|       |		 * the same. But in future may need to know card type first,
 5598|       |		 * so do it here.
 5599|       |		 */
 5600|       |
 5601|  4.38k|		if (card->reader->atr_info.hist_bytes != NULL) {
  ------------------
  |  Branch (5601:7): [True: 1.03k, False: 3.34k]
  ------------------
 5602|  1.03k|			if (card->reader->atr_info.hist_bytes_len == 8 &&
  ------------------
  |  Branch (5602:8): [True: 160, False: 879]
  ------------------
 5603|    160|					!(memcmp(card->reader->atr_info.hist_bytes, "Yubikey4", 8))) {
  ------------------
  |  Branch (5603:6): [True: 30, False: 130]
  ------------------
 5604|     30|				type = SC_CARD_TYPE_PIV_II_YUBIKEY4;
 5605|  1.00k|			} else if (card->reader->atr_info.hist_bytes_len >= 7 &&
  ------------------
  |  Branch (5605:15): [True: 501, False: 508]
  ------------------
 5606|    501|					!(memcmp(card->reader->atr_info.hist_bytes, "Yubikey", 7))) {
  ------------------
  |  Branch (5606:6): [True: 72, False: 429]
  ------------------
 5607|     72|				type = SC_CARD_TYPE_PIV_II_NEO;
 5608|    937|			} else if (card->reader->atr_info.hist_bytes_len >= 6 &&
  ------------------
  |  Branch (5608:15): [True: 462, False: 475]
  ------------------
 5609|    462|					!(memcmp(card->reader->atr_info.hist_bytes, "PIVKEY", 6))) {
  ------------------
  |  Branch (5609:6): [True: 14, False: 448]
  ------------------
 5610|     14|				type = SC_CARD_TYPE_PIV_II_PIVKEY;
 5611|    923|			} else if (card->reader->atr_info.hist_bytes_len >= 6 &&
  ------------------
  |  Branch (5611:15): [True: 448, False: 475]
  ------------------
 5612|    448|					!(memcmp(card->reader->atr_info.hist_bytes, (u8 *)"TK\x00PIV", 6))) {
  ------------------
  |  Branch (5612:6): [True: 27, False: 421]
  ------------------
 5613|     27|				type = SC_CARD_TYPE_PIV_II_TOKEN2;
 5614|     27|			}
 5615|       |			/* look for TLV historic data */
 5616|    896|			else if (card->reader->atr_info.hist_bytes_len > 0 &&
  ------------------
  |  Branch (5616:13): [True: 863, False: 33]
  ------------------
 5617|    863|					card->reader->atr_info.hist_bytes[0] == 0x80u) { /* compact TLV */
  ------------------
  |  Branch (5617:6): [True: 148, False: 715]
  ------------------
 5618|    148|				size_t datalen;
 5619|    148|				const u8 *data;
 5620|       |
 5621|       |				/* look for card issuer's data:  tag 5X where X is datalen */
 5622|    148|				if ((data = sc_compacttlv_find_tag(card->reader->atr_info.hist_bytes + 1,
  ------------------
  |  Branch (5622:9): [True: 29, False: 119]
  ------------------
 5623|    148|						     card->reader->atr_info.hist_bytes_len - 1, 0x50, &datalen))) {
 5624|     29|					if (datalen >= 8 && !(memcmp(data, "Nitrokey", 8))) { /* first 8 are Nitrokey */
  ------------------
  |  Branch (5624:10): [True: 14, False: 15]
  |  Branch (5624:26): [True: 1, False: 13]
  ------------------
 5625|      1|						type = SC_CARD_TYPE_PIV_II_NITROKEY;
 5626|     28|					} else if (datalen == 7 && !(memcmp(data, "YubiKey", 7))) {
  ------------------
  |  Branch (5626:17): [True: 8, False: 20]
  |  Branch (5626:33): [True: 1, False: 7]
  ------------------
 5627|      1|						type = SC_CARD_TYPE_PIV_II_YUBIKEY4; /* reader says 4  really 5 */
 5628|      1|					}
 5629|       |					/* Yubikey 5 NFC ATR using ACR122 contactless reader does not match
 5630|       |					 * https://developers.yubico.com/PIV/Introduction/Yubico_extensions.html
 5631|       |					 * On Windows 10, using Omnikey 5021, the ATR is correct
 5632|       |					 * will look at only 6 bytes that do match
 5633|       |					 */
 5634|     27|					else if (datalen == 7 && !(memcmp(data, "YubiKe", 6))) {
  ------------------
  |  Branch (5634:15): [True: 7, False: 20]
  |  Branch (5634:31): [True: 1, False: 6]
  ------------------
 5635|      1|						type = SC_CARD_TYPE_PIV_II_YUBIKEY4; /* reader says 4 really 5 */
 5636|      1|					}
 5637|    119|				} else if ((data = sc_compacttlv_find_tag(card->reader->atr_info.hist_bytes + 1,
  ------------------
  |  Branch (5637:16): [True: 59, False: 60]
  ------------------
 5638|    119|							    card->reader->atr_info.hist_bytes_len - 1, 0xF0, &datalen))) {
 5639|     59|					int k;
 5640|       |
 5641|    172|					for (k = 0; piv_aids[k].len_long != 0; k++) {
  ------------------
  |  Branch (5641:18): [True: 116, False: 56]
  ------------------
 5642|    116|						if (datalen == piv_aids[k].len_long &&
  ------------------
  |  Branch (5642:11): [True: 106, False: 10]
  ------------------
 5643|    106|								!memcmp(data, piv_aids[k].value, datalen)) {
  ------------------
  |  Branch (5643:9): [True: 3, False: 103]
  ------------------
 5644|      3|							type = SC_CARD_TYPE_PIV_II_HIST;
 5645|      3|							break;
 5646|      3|						}
 5647|    116|					}
 5648|     59|				}
 5649|    148|			}
 5650|  1.03k|		}
 5651|       |
 5652|  4.38k|		sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d type:%d r:%d\n", card->type, type, r);
  ------------------
  |  |   70|  4.38k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5653|       |
 5654|  4.38k|		if (type == -1) {
  ------------------
  |  Branch (5654:7): [True: 4.23k, False: 149]
  ------------------
 5655|       |			/* use known ATRs  which changes the type */
 5656|  4.23k|			i = _sc_match_atr(card, piv_atrs, &type);
 5657|  4.23k|			if (i < 0)
  ------------------
  |  Branch (5657:8): [True: 4.23k, False: 1]
  ------------------
 5658|  4.23k|				type = SC_CARD_TYPE_PIV_II_BASE; /* May be some newer unknown card including CAC or PIV-like card */
 5659|  4.23k|		}
 5660|  4.38k|	}
 5661|       |
 5662|  4.38k|	card->type = type;
 5663|       |
 5664|       |	/* we either found via ATR historic bytes or ATR directly */
 5665|  4.38k|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d type:%d r:%d\n", card->type, type, r);
  ------------------
  |  |   70|  4.38k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5666|       |
 5667|       |	/* allocate and init basic fields */
 5668|  4.38k|	priv = calloc(1, sizeof(piv_private_data_t));
 5669|       |
 5670|  4.38k|	if (!priv)
  ------------------
  |  Branch (5670:6): [True: 0, False: 4.38k]
  ------------------
 5671|  4.38k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5672|       |
 5673|  4.38k|	card->drv_data = priv; /* will free if no match, or pass on to piv_init */
 5674|       |	/*
 5675|       |	 * Largest object defined in NIST sp800-73-3 and sp800-73-4 is 12710 bytes
 5676|       |	 * If for some reason future cards have larger objects, this value needs to
 5677|       |	 * be increased here.
 5678|       |	 */
 5679|  4.38k|	priv->max_object_size = MAX_FILE_SIZE - 256; /* fix SM apdu resplen issue */
  ------------------
  |  |  220|  4.38k|#define MAX_FILE_SIZE 65535
  ------------------
 5680|  4.38k|	priv->selected_obj = -1;
 5681|  4.38k|	priv->pin_preference = 0x80; /* 800-73-3 part 1, table 3 */
 5682|  4.38k|	priv->logged_in = SC_PIN_STATE_UNKNOWN;
  ------------------
  |  |  430|  4.38k|#define SC_PIN_STATE_UNKNOWN	0
  ------------------
 5683|  4.38k|	priv->pstate = PIV_STATE_MATCH;
 5684|       |
 5685|       |#ifdef ENABLE_PIV_SM
 5686|       |	memset(&card->sm_ctx, 0, sizeof card->sm_ctx);
 5687|       |	card->sm_ctx.ops.open = piv_sm_open;
 5688|       |	card->sm_ctx.ops.get_sm_apdu = piv_get_sm_apdu;
 5689|       |	card->sm_ctx.ops.free_sm_apdu = piv_free_sm_apdu;
 5690|       |	card->sm_ctx.ops.close = piv_sm_close;
 5691|       |#endif /* ENABLE_PIV_SM */
 5692|       |
 5693|       |	/* See if contactless  or run as virtual card */
 5694|       |	/* PivApplet in .github/test_piv.sh for example */
 5695|  4.38k|	if (card->reader->atr.len >= 4 &&
  ------------------
  |  Branch (5695:6): [True: 1.23k, False: 3.14k]
  ------------------
 5696|  1.23k|			card->reader->atr.value[0] == 0x3b &&
  ------------------
  |  Branch (5696:4): [True: 1.02k, False: 214]
  ------------------
 5697|  1.02k|			(card->reader->atr.value[1] & 0xF0) == 0x80 &&
  ------------------
  |  Branch (5697:4): [True: 142, False: 880]
  ------------------
 5698|    142|			card->reader->atr.value[2] == 0x80 &&
  ------------------
  |  Branch (5698:4): [True: 112, False: 30]
  ------------------
 5699|    112|			card->reader->atr.value[3] == 0x01) {
  ------------------
  |  Branch (5699:4): [True: 15, False: 97]
  ------------------
 5700|     15|		priv->init_flags |= PIV_INIT_CONTACTLESS;
  ------------------
  |  |  385|     15|#define PIV_INIT_CONTACTLESS			0x00000020u
  ------------------
 5701|     15|	}
 5702|       |
 5703|   267k|	for (i = 0; i < PIV_OBJ_LAST_ENUM - 1; i++)
  ------------------
  |  Branch (5703:14): [True: 262k, False: 4.38k]
  ------------------
 5704|   262k|		if (piv_objects[i].flags & PIV_OBJECT_NOT_PRESENT)
  ------------------
  |  |  646|   262k|#define PIV_OBJECT_NOT_PRESENT		0x04
  ------------------
  |  Branch (5704:7): [True: 87.6k, False: 175k]
  ------------------
 5705|  87.6k|			priv->obj_cache[i].flags |= PIV_OBJ_CACHE_NOT_PRESENT;
  ------------------
  |  |  153|  92.0k|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
 5706|       |	/*
 5707|       |	 * Detect if active AID is PIV. NIST 800-73 says only one PIV application per card
 5708|       |	 * and PIV must be the default application.
 5709|       |	 * Try to avoid doing a select_aid and losing the login state on some cards.
 5710|       |	 * We may get interference on some cards by other drivers trying SELECT_AID before
 5711|       |	 * we get to see if PIV application is still active. Putting PIV driver first might help.
 5712|       |	 *
 5713|       |	 * Discovery Object introduced in 800-73-3 so will return OK if found and PIV applet active.
 5714|       |	 * Will fail with SC_ERROR_FILE_NOT_FOUND if 800-73-3 and no Discovery object.
 5715|       |	 * But some other card could also return SC_ERROR_FILE_NOT_FOUND.
 5716|       |	 * Will fail for other reasons if wrong applet is selected or bad PIV implementation.
 5717|       |	 */
 5718|       |
 5719|       |	/*
 5720|       |	 * if ATR matched or user forced card type
 5721|       |	 * test if PIV is active applet without using AID If fails try AID
 5722|       |	 */
 5723|       |
 5724|  4.38k|	if (card->type > SC_CARD_TYPE_PIV_II_BASE &&
  ------------------
  |  Branch (5724:6): [True: 150, False: 4.23k]
  ------------------
 5725|    150|			!(priv->init_flags & PIV_INIT_CONTACTLESS)) {
  ------------------
  |  |  385|    150|#define PIV_INIT_CONTACTLESS			0x00000020u
  ------------------
  |  Branch (5725:4): [True: 148, False: 2]
  ------------------
 5726|    148|		r = piv_find_discovery(card);
 5727|    148|		if (r < 0) {
  ------------------
  |  Branch (5727:7): [True: 142, False: 6]
  ------------------
 5728|    142|			piv_obj_cache_free_entry(card, PIV_OBJ_DISCOVERY, 0); /* don't cache  on failure */
 5729|    142|			r = piv_find_aid(card);
 5730|    142|			LOG_TEST_GOTO_ERR(card->ctx, r, "Not a PIV card");
  ------------------
  |  |  184|    142|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    142|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    142|	int _ret = (r); \
  |  |  |  |  178|    142|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 84, False: 58]
  |  |  |  |  ------------------
  |  |  |  |  179|     84|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     84|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     84|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     84|		goto err; \
  |  |  |  |  182|     84|	} \
  |  |  |  |  183|    142|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5731|    142|		}
 5732|  4.23k|	} else {
 5733|       |		/* piv_find_aid saves al_label from response */
 5734|  4.23k|		r = piv_find_aid(card);
 5735|  4.23k|		LOG_TEST_GOTO_ERR(card->ctx, r, "Not a PIV card");
  ------------------
  |  |  184|  4.23k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  4.23k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  4.23k|	int _ret = (r); \
  |  |  |  |  178|  4.23k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 4.04k, False: 185]
  |  |  |  |  ------------------
  |  |  |  |  179|  4.04k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.04k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|  4.04k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|  4.04k|		goto err; \
  |  |  |  |  182|  4.04k|	} \
  |  |  |  |  183|  4.23k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 185]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5736|  4.23k|	}
 5737|       |
 5738|       |	/* Know to be PIV card but not the type */
 5739|       |
 5740|       |	/* If card type still unknown, see if Application Label is known and set card->type */
 5741|    249|	if (priv->al_label && priv->al_labellen) {
  ------------------
  |  Branch (5741:6): [True: 20, False: 229]
  |  Branch (5741:24): [True: 12, False: 8]
  ------------------
 5742|     12|		switch (card->type) {
  ------------------
  |  Branch (5742:11): [True: 10, False: 2]
  ------------------
 5743|     10|		case SC_CARD_TYPE_PIV_II_BASE:
  ------------------
  |  Branch (5743:3): [True: 10, False: 2]
  ------------------
 5744|     10|		case SC_CARD_TYPE_PIV_II_GENERIC:
  ------------------
  |  Branch (5744:3): [True: 0, False: 12]
  ------------------
 5745|     19|			for (i = 0; al_map[i].al_label; i++) {
  ------------------
  |  Branch (5745:16): [True: 10, False: 9]
  ------------------
 5746|     10|				if ((priv->al_labellen >= al_map[i].al_labellen) &&
  ------------------
  |  Branch (5746:9): [True: 8, False: 2]
  ------------------
 5747|      8|						(!memcmp(priv->al_label, al_map[i].al_label, al_map[i].al_labellen))) {
  ------------------
  |  Branch (5747:7): [True: 1, False: 7]
  ------------------
 5748|      1|					sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "AL match i:%d type:%d", i, al_map[i].al_type);
  ------------------
  |  |   70|      1|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5749|      1|					card->type = al_map[i].al_type;
 5750|      1|					break;
 5751|      1|				}
 5752|     10|			}
 5753|     10|			break;
 5754|     12|		}
 5755|     12|	}
 5756|       |
 5757|    249|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d  CI:%08x r:%d AI:%08x\n",
  ------------------
  |  |   70|    249|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5758|    249|			card->type, priv->card_issues, r, priv->alg_ids);
 5759|       |
 5760|       |	/*
 5761|       |	 * Assumes all Yubikey/Nitrokey/Token2/PivApplet cards are all "Yubico like"
 5762|       |	 * via ATR, ATR Historic bytes or Application Label
 5763|       |	 * Will also check if BASE cards are Yubikey like card and return a version number
 5764|       |	 * SC_CARD_TYPE_PIV_II_GENERIC can be set by user to not test for Yubico version
 5765|       |	 */
 5766|    249|	switch (card->type) {
  ------------------
  |  Branch (5766:10): [True: 247, False: 2]
  ------------------
 5767|     31|	case SC_CARD_TYPE_PIV_II_NEO:
  ------------------
  |  Branch (5767:2): [True: 31, False: 218]
  ------------------
 5768|     59|	case SC_CARD_TYPE_PIV_II_YUBIKEY4:
  ------------------
  |  Branch (5768:2): [True: 28, False: 221]
  ------------------
 5769|     59|	case SC_CARD_TYPE_PIV_II_NITROKEY:
  ------------------
  |  Branch (5769:2): [True: 0, False: 249]
  ------------------
 5770|     62|	case SC_CARD_TYPE_PIV_II_TOKEN2:
  ------------------
  |  Branch (5770:2): [True: 3, False: 246]
  ------------------
 5771|     63|	case SC_CARD_TYPE_PIV_II_PIVAPPLET:
  ------------------
  |  Branch (5771:2): [True: 1, False: 248]
  ------------------
 5772|     63|	case SC_CARD_TYPE_PIV_II_GENERIC:
  ------------------
  |  Branch (5772:2): [True: 0, False: 249]
  ------------------
 5773|    247|	case SC_CARD_TYPE_PIV_II_BASE: /* unknown PIV card */
  ------------------
  |  Branch (5773:2): [True: 184, False: 65]
  ------------------
 5774|    247|		sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xFD, 0x00, 0x00);
  ------------------
  |  |  292|    247|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 5775|    247|		apdu.lc = 0;
 5776|    247|		apdu.data = NULL;
 5777|    247|		apdu.datalen = 0;
 5778|    247|		apdu.resp = yubico_version_buf;
 5779|    247|		apdu.resplen = sizeof(yubico_version_buf);
 5780|    247|		apdu.le = apdu.resplen;
 5781|    247|		r2 = sc_transmit_apdu(card, &apdu); /* if not supported yubico_version == 0 */
 5782|    247|		if (r2 == SC_SUCCESS && apdu.resplen == 3) {
  ------------------
  |  |   28|    494|#define SC_SUCCESS				0
  ------------------
  |  Branch (5782:7): [True: 243, False: 4]
  |  Branch (5782:27): [True: 87, False: 156]
  ------------------
 5783|     87|			priv->yubico_version = (yubico_version_buf[0] << 16) | (yubico_version_buf[1] << 8) | yubico_version_buf[2];
 5784|     87|			sc_log(card->ctx, "Yubikey version test card->type=%d, r=0x%08x version=0x%08x", card->type, r, priv->yubico_version);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 5785|     87|		}
 5786|    247|		break;
 5787|    249|	}
 5788|       |
 5789|    249|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d r2:%d CI:%08x r:%d AI:%08x\n",
  ------------------
  |  |   70|    249|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5790|    249|			card->type, r2, priv->card_issues, r, priv->alg_ids);
 5791|       |
 5792|       |	/* We now know PIV AID is active, test CCC object. 800-73-* say CCC is required */
 5793|       |	/* CCC not readable over contactless, unless using VCI. but dont need CCC for SC_CARD_TYPE_PIV_II_800_73_4 */
 5794|    249|	switch (card->type) {
  ------------------
  |  Branch (5794:10): [True: 185, False: 64]
  ------------------
 5795|       |	/*
 5796|       |	 * For cards that may also be CAC, try and read the CCC
 5797|       |	 * CCC is required and all Dual PIV/CAC will have a CCC
 5798|       |	 * Currently Dual PIV/CAC are based on NIST 800-73-1 which does not have Discovery or History
 5799|       |	 */
 5800|    184|	case SC_CARD_TYPE_PIV_II_BASE: /* i.e. really dont know what this is */
  ------------------
  |  Branch (5800:2): [True: 184, False: 65]
  ------------------
 5801|    184|	case SC_CARD_TYPE_PIV_II_GENERIC:
  ------------------
  |  Branch (5801:2): [True: 0, False: 249]
  ------------------
 5802|    185|	case SC_CARD_TYPE_PIV_II_HIST:
  ------------------
  |  Branch (5802:2): [True: 1, False: 248]
  ------------------
 5803|    185|	case SC_CARD_TYPE_PIV_II_GI_DE:
  ------------------
  |  Branch (5803:2): [True: 0, False: 249]
  ------------------
 5804|    185|	case SC_CARD_TYPE_PIV_II_GEMALTO:
  ------------------
  |  Branch (5804:2): [True: 0, False: 249]
  ------------------
 5805|    185|	case SC_CARD_TYPE_PIV_II_OBERTHUR:
  ------------------
  |  Branch (5805:2): [True: 0, False: 249]
  ------------------
 5806|    185|		r2 = piv_process_ccc(card);
 5807|    185|		sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d r2:%d CI:%08x r:%d AI:%08x\n",
  ------------------
  |  |   70|    185|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5808|    185|				card->type, r2, priv->card_issues, r, priv->alg_ids);
 5809|       |		/* Ignore any error. */
 5810|       |		/* If CCC says it has CAC with PKI on card set to one of the SC_CARD_TYPE_PIV_II_*_DUAL_CAC */
 5811|    185|		if (priv->ccc_flags & PIV_CCC_F3_CAC_PKI) {
  ------------------
  |  |  174|    185|#define PIV_CCC_F3_CAC_PKI	0x00000010
  ------------------
  |  Branch (5811:7): [True: 1, False: 184]
  ------------------
 5812|      1|			switch (card->type) {
  ------------------
  |  Branch (5812:12): [True: 1, False: 0]
  ------------------
 5813|      1|			case SC_CARD_TYPE_PIV_II_BASE:
  ------------------
  |  Branch (5813:4): [True: 1, False: 0]
  ------------------
 5814|      1|			case SC_CARD_TYPE_PIV_II_GENERIC:
  ------------------
  |  Branch (5814:4): [True: 0, False: 1]
  ------------------
 5815|      1|			case SC_CARD_TYPE_PIV_II_HIST:
  ------------------
  |  Branch (5815:4): [True: 0, False: 1]
  ------------------
 5816|      1|			case SC_CARD_TYPE_PIV_II_GI_DE:
  ------------------
  |  Branch (5816:4): [True: 0, False: 1]
  ------------------
 5817|      1|				card->type = SC_CARD_TYPE_PIV_II_GI_DE_DUAL_CAC;
 5818|      1|				priv->card_issues |= CI_DISCOVERY_USELESS;
  ------------------
  |  |  590|      1|#define CI_DISCOVERY_USELESS		    0x00000020U /* Discovery can not be used to query active AID invalid or no data returned */
  ------------------
 5819|      1|				priv->obj_cache[PIV_OBJ_DISCOVERY].flags |= PIV_OBJ_CACHE_NOT_PRESENT;
  ------------------
  |  |  153|      1|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
 5820|      1|				break;
 5821|      0|			case SC_CARD_TYPE_PIV_II_GEMALTO:
  ------------------
  |  Branch (5821:4): [True: 0, False: 1]
  ------------------
 5822|      0|				card->type = SC_CARD_TYPE_PIV_II_GEMALTO_DUAL_CAC;
 5823|      0|				priv->card_issues |= CI_DISCOVERY_USELESS;
  ------------------
  |  |  590|      0|#define CI_DISCOVERY_USELESS		    0x00000020U /* Discovery can not be used to query active AID invalid or no data returned */
  ------------------
 5824|      0|				priv->obj_cache[PIV_OBJ_DISCOVERY].flags |= PIV_OBJ_CACHE_NOT_PRESENT;
  ------------------
  |  |  153|      0|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
 5825|      0|				break;
 5826|      0|			case SC_CARD_TYPE_PIV_II_OBERTHUR:
  ------------------
  |  Branch (5826:4): [True: 0, False: 1]
  ------------------
 5827|      0|				card->type = SC_CARD_TYPE_PIV_II_OBERTHUR_DUAL_CAC;
 5828|      0|				priv->card_issues |= CI_DISCOVERY_USELESS;
  ------------------
  |  |  590|      0|#define CI_DISCOVERY_USELESS		    0x00000020U /* Discovery can not be used to query active AID invalid or no data returned */
  ------------------
 5829|      0|				priv->obj_cache[PIV_OBJ_DISCOVERY].flags |= PIV_OBJ_CACHE_NOT_PRESENT;
  ------------------
  |  |  153|      0|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
 5830|      0|				break;
 5831|      1|			}
 5832|      1|		}
 5833|    185|		break;
 5834|       |
 5835|    185|	case SC_CARD_TYPE_PIV_II_GI_DE_DUAL_CAC:
  ------------------
  |  Branch (5835:2): [True: 0, False: 249]
  ------------------
 5836|      0|	case SC_CARD_TYPE_PIV_II_GEMALTO_DUAL_CAC:
  ------------------
  |  Branch (5836:2): [True: 0, False: 249]
  ------------------
 5837|      0|	case SC_CARD_TYPE_PIV_II_OBERTHUR_DUAL_CAC:
  ------------------
  |  Branch (5837:2): [True: 0, False: 249]
  ------------------
 5838|      0|		priv->card_issues |= CI_DISCOVERY_USELESS;
  ------------------
  |  |  590|      0|#define CI_DISCOVERY_USELESS		    0x00000020U /* Discovery can not be used to query active AID invalid or no data returned */
  ------------------
 5839|      0|		priv->obj_cache[PIV_OBJ_DISCOVERY].flags |= PIV_OBJ_CACHE_NOT_PRESENT;
  ------------------
  |  |  153|      0|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
 5840|      0|		break;
 5841|    249|	}
 5842|    249|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d r2:%d CI:%08x r:%d AI:%08x\n",
  ------------------
  |  |   70|    249|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5843|    249|			card->type, r2, priv->card_issues, r, priv->alg_ids);
 5844|       |
 5845|       |	/* If contactless or run as virtual card try to get alg refs from AC entries in response to SELECT AID */
 5846|    249|	if (!(priv->init_flags & PIV_INIT_AID_PARSED) && priv->init_flags & PIV_INIT_CONTACTLESS) {
  ------------------
  |  |  380|    249|#define PIV_INIT_AID_PARSED			0x00000001u
  ------------------
              	if (!(priv->init_flags & PIV_INIT_AID_PARSED) && priv->init_flags & PIV_INIT_CONTACTLESS) {
  ------------------
  |  |  385|      6|#define PIV_INIT_CONTACTLESS			0x00000020u
  ------------------
  |  Branch (5846:6): [True: 6, False: 243]
  |  Branch (5846:51): [True: 0, False: 6]
  ------------------
 5847|      0|		r2 = piv_find_aid(card);
 5848|      0|	}
 5849|       |
 5850|       |	/* Read AID if needed for these cards types */
 5851|    249|	if (!(priv->init_flags & PIV_INIT_AID_PARSED)) {
  ------------------
  |  |  380|    249|#define PIV_INIT_AID_PARSED			0x00000001u
  ------------------
  |  Branch (5851:6): [True: 6, False: 243]
  ------------------
 5852|      6|		switch (card->type) {
  ------------------
  |  Branch (5852:11): [True: 3, False: 3]
  ------------------
 5853|      0|		case SC_CARD_TYPE_PIV_II_BASE:
  ------------------
  |  Branch (5853:3): [True: 0, False: 6]
  ------------------
 5854|      0|		case SC_CARD_TYPE_PIV_II_GENERIC:
  ------------------
  |  Branch (5854:3): [True: 0, False: 6]
  ------------------
 5855|      0|		case SC_CARD_TYPE_PIV_II_800_73_4:
  ------------------
  |  Branch (5855:3): [True: 0, False: 6]
  ------------------
 5856|      0|		case SC_CARD_TYPE_PIV_II_NITROKEY:
  ------------------
  |  Branch (5856:3): [True: 0, False: 6]
  ------------------
 5857|      3|		case SC_CARD_TYPE_PIV_II_TOKEN2:
  ------------------
  |  Branch (5857:3): [True: 3, False: 3]
  ------------------
 5858|      3|		case SC_CARD_TYPE_PIV_II_PIVAPPLET:
  ------------------
  |  Branch (5858:3): [True: 0, False: 6]
  ------------------
 5859|      3|			r2 = piv_find_aid(card);
 5860|      6|		}
 5861|      6|	}
 5862|       |
 5863|    249|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d r2:%d CI:%08x r:%d AI:%08x\n",
  ------------------
  |  |   70|    249|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5864|    249|			card->type, r2, priv->card_issues, r, priv->alg_ids);
 5865|       |
 5866|       |	/* if card did not specify any of the NIST basic alg_ids add them */
 5867|    249|	if ((priv->alg_ids & AI_NIST) == 0) {
  ------------------
  |  |  609|    249|#define AI_NIST (AI_RSA_1024 | AI_RSA_2048 | AI_RSA_3072 | AI_EC_256 | AI_EC_384)
  |  |  ------------------
  |  |  |  |  600|    249|#define AI_RSA_1024			    0x00000001U
  |  |  ------------------
  |  |               #define AI_NIST (AI_RSA_1024 | AI_RSA_2048 | AI_RSA_3072 | AI_EC_256 | AI_EC_384)
  |  |  ------------------
  |  |  |  |  601|    249|#define AI_RSA_2048			    0x00000002U
  |  |  ------------------
  |  |               #define AI_NIST (AI_RSA_1024 | AI_RSA_2048 | AI_RSA_3072 | AI_EC_256 | AI_EC_384)
  |  |  ------------------
  |  |  |  |  602|    249|#define AI_RSA_3072			    0x00000004U
  |  |  ------------------
  |  |               #define AI_NIST (AI_RSA_1024 | AI_RSA_2048 | AI_RSA_3072 | AI_EC_256 | AI_EC_384)
  |  |  ------------------
  |  |  |  |  604|    249|#define AI_EC_256			    0x00000100U
  |  |  ------------------
  |  |               #define AI_NIST (AI_RSA_1024 | AI_RSA_2048 | AI_RSA_3072 | AI_EC_256 | AI_EC_384)
  |  |  ------------------
  |  |  |  |  605|    249|#define AI_EC_384			    0x00000200U
  |  |  ------------------
  ------------------
  |  Branch (5867:6): [True: 247, False: 2]
  ------------------
 5868|    247|		priv->alg_ids |= AI_NIST;
  ------------------
  |  |  609|    247|#define AI_NIST (AI_RSA_1024 | AI_RSA_2048 | AI_RSA_3072 | AI_EC_256 | AI_EC_384)
  |  |  ------------------
  |  |  |  |  600|    247|#define AI_RSA_1024			    0x00000001U
  |  |  ------------------
  |  |               #define AI_NIST (AI_RSA_1024 | AI_RSA_2048 | AI_RSA_3072 | AI_EC_256 | AI_EC_384)
  |  |  ------------------
  |  |  |  |  601|    247|#define AI_RSA_2048			    0x00000002U
  |  |  ------------------
  |  |               #define AI_NIST (AI_RSA_1024 | AI_RSA_2048 | AI_RSA_3072 | AI_EC_256 | AI_EC_384)
  |  |  ------------------
  |  |  |  |  602|    247|#define AI_RSA_3072			    0x00000004U
  |  |  ------------------
  |  |               #define AI_NIST (AI_RSA_1024 | AI_RSA_2048 | AI_RSA_3072 | AI_EC_256 | AI_EC_384)
  |  |  ------------------
  |  |  |  |  604|    247|#define AI_EC_256			    0x00000100U
  |  |  ------------------
  |  |               #define AI_NIST (AI_RSA_1024 | AI_RSA_2048 | AI_RSA_3072 | AI_EC_256 | AI_EC_384)
  |  |  ------------------
  |  |  |  |  605|    247|#define AI_EC_384			    0x00000200U
  |  |  ------------------
  ------------------
 5869|    247|	}
 5870|       |
 5871|       |	/* If unknown card has 800-73-4 features, it must be based on 800-73-4 or above */
 5872|    249|	switch (card->type) {
  ------------------
  |  Branch (5872:10): [True: 183, False: 66]
  ------------------
 5873|    183|	case SC_CARD_TYPE_PIV_II_BASE:
  ------------------
  |  Branch (5873:2): [True: 183, False: 66]
  ------------------
 5874|    183|	case SC_CARD_TYPE_PIV_II_GENERIC:
  ------------------
  |  Branch (5874:2): [True: 0, False: 249]
  ------------------
 5875|    183|		if (priv->init_flags & PIV_INIT_AID_AC_SM) {
  ------------------
  |  |  381|    183|#define PIV_INIT_AID_AC_SM			0x00000002u
  ------------------
  |  Branch (5875:7): [True: 0, False: 183]
  ------------------
 5876|      0|			card->type = SC_CARD_TYPE_PIV_II_800_73_4;
 5877|      0|		}
 5878|       |
 5879|       |#ifdef ENABLE_PIV_SM
 5880|       |		/* Discovery object has pin policy. 800-74-4 bits, its at least SC_CARD_TYPE_PIV_II_800_73_4 */
 5881|       |		if ((priv->pin_policy & (PIV_PP_OCC | PIV_PP_VCI_IMPL | PIV_PP_VCI_WITHOUT_PC)) != 0) {
 5882|       |			card->type = SC_CARD_TYPE_PIV_II_800_73_4;
 5883|       |		}
 5884|       |#endif
 5885|    183|		break;
 5886|    249|	}
 5887|       |
 5888|    249|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d r2:%d CI:%08x r:%d AI:%08x\n",
  ------------------
  |  |   70|    249|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5889|    249|			card->type, r2, priv->card_issues, r, priv->alg_ids);
 5890|       |
 5891|       |	/*
 5892|       |	 * Set card_issues flags based card->type and version numbers if available.
 5893|       |	 *
 5894|       |	 * YubiKey NEO, Yubikey 4 and other devices with PIV applets, have compliance
 5895|       |	 * issues with the NIST 800-73-3 specs. The OpenSC developers do not have
 5896|       |	 * access to all the different devices or versions of the devices.
 5897|       |	 * Vendor and user input is welcome on any compliance issues.
 5898|       |	 *
 5899|       |	 * For the Yubico devices The assumption is also made that if a bug is
 5900|       |	 * fixed in a Yubico version that means it is fixed on both NEO and Yubikey 4.
 5901|       |	 *
 5902|       |	 * The flags CI_CANT_USE_GETDATA_FOR_STATE and CI_DISCOVERY_USELESS
 5903|       |	 * may be set earlier or later then in the following code.
 5904|       |	 */
 5905|       |
 5906|    249|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d r2:%d CI:%08x r:%d AI:%08x\n",
  ------------------
  |  |   70|    249|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5907|    249|			card->type, r2, priv->card_issues, r, priv->alg_ids);
 5908|    249|	switch (card->type) {
 5909|     31|	case SC_CARD_TYPE_PIV_II_NEO:
  ------------------
  |  Branch (5909:2): [True: 31, False: 218]
  ------------------
 5910|     31|		priv->card_issues |= CI_NO_EC384 |
  ------------------
  |  |  596|     31|#define CI_NO_EC384			    0x00000400U /* does not have EC 384 */
  ------------------
 5911|     31|				     CI_VERIFY_630X |
  ------------------
  |  |  584|     31|#define CI_VERIFY_630X			    0x00000001U /* VERIFY tries left returns 630X rather then 63CX */
  ------------------
 5912|     31|				     CI_OTHER_AID_LOSE_STATE |
  ------------------
  |  |  593|     31|#define CI_OTHER_AID_LOSE_STATE		    0x00000100U /* Other drivers match routines may reset our security state and lose AID!!! */
  ------------------
 5913|     31|				     CI_LEAKS_FILE_NOT_FOUND |
  ------------------
  |  |  589|     31|#define CI_LEAKS_FILE_NOT_FOUND		    0x00000010U /* GET DATA of empty object returns 6A 82 even if PIN not verified */
  ------------------
 5914|     31|				     CI_NFC_EXPOSE_TOO_MUCH;
  ------------------
  |  |  594|     31|#define CI_NFC_EXPOSE_TOO_MUCH		    0x00000200U /* PIN, crypto and objects exposed over NFS in violation of 800-73-3 */
  ------------------
 5915|     31|		if (priv->yubico_version < 0x00040302)
  ------------------
  |  Branch (5915:7): [True: 18, False: 13]
  ------------------
 5916|     18|			priv->card_issues |= CI_VERIFY_LC0_FAIL;
  ------------------
  |  |  585|     18|#define CI_VERIFY_LC0_FAIL		    0x00000002U /* VERIFY Lc=0 never returns 90 00 if PIN not needed */
  ------------------
 5917|     31|		break;
 5918|       |
 5919|     28|	case SC_CARD_TYPE_PIV_II_YUBIKEY4:
  ------------------
  |  Branch (5919:2): [True: 28, False: 221]
  ------------------
 5920|     29|	case SC_CARD_TYPE_PIV_II_PIVAPPLET:
  ------------------
  |  Branch (5920:2): [True: 1, False: 248]
  ------------------
 5921|     32|	case SC_CARD_TYPE_PIV_II_TOKEN2:
  ------------------
  |  Branch (5921:2): [True: 3, False: 246]
  ------------------
 5922|     32|		priv->card_issues |= CI_OTHER_AID_LOSE_STATE |
  ------------------
  |  |  593|     32|#define CI_OTHER_AID_LOSE_STATE		    0x00000100U /* Other drivers match routines may reset our security state and lose AID!!! */
  ------------------
 5923|     32|				     CI_LEAKS_FILE_NOT_FOUND;
  ------------------
  |  |  589|     32|#define CI_LEAKS_FILE_NOT_FOUND		    0x00000010U /* GET DATA of empty object returns 6A 82 even if PIN not verified */
  ------------------
 5924|     32|		if (priv->yubico_version < 0x00040302)
  ------------------
  |  Branch (5924:7): [True: 14, False: 18]
  ------------------
 5925|     14|			priv->card_issues |= CI_VERIFY_LC0_FAIL;
  ------------------
  |  |  585|     14|#define CI_VERIFY_LC0_FAIL		    0x00000002U /* VERIFY Lc=0 never returns 90 00 if PIN not needed */
  ------------------
 5926|     32|		if (priv->yubico_version >= 0x00050700) /* Also used by Token2 */
  ------------------
  |  Branch (5926:7): [True: 12, False: 20]
  ------------------
 5927|     12|			priv->alg_ids |= AI_RSA_4096 | AI_25519 | AI_X25519;
  ------------------
  |  |  603|     12|#define AI_RSA_4096			    0x00000008U
  ------------------
              			priv->alg_ids |= AI_RSA_4096 | AI_25519 | AI_X25519;
  ------------------
  |  |  606|     12|#define AI_25519			    0x00100000U
  ------------------
              			priv->alg_ids |= AI_RSA_4096 | AI_25519 | AI_X25519;
  ------------------
  |  |  607|     12|#define AI_X25519			    0x00200000U
  ------------------
 5928|     32|		break;
 5929|       |
 5930|      0|	case SC_CARD_TYPE_PIV_II_NITROKEY:
  ------------------
  |  Branch (5930:2): [True: 0, False: 249]
  ------------------
 5931|      0|		priv->card_issues |= CI_OTHER_AID_LOSE_STATE;
  ------------------
  |  |  593|      0|#define CI_OTHER_AID_LOSE_STATE		    0x00000100U /* Other drivers match routines may reset our security state and lose AID!!! */
  ------------------
 5932|      0|		if (priv->yubico_version >= 0x00010802) /* use for NitroKey too */
  ------------------
  |  Branch (5932:7): [True: 0, False: 0]
  ------------------
 5933|      0|			priv->alg_ids |= AI_RSA_4096;
  ------------------
  |  |  603|      0|#define AI_RSA_4096			    0x00000008U
  ------------------
 5934|      0|		break;
 5935|       |
 5936|      0|	case SC_CARD_TYPE_PIV_II_GI_DE:
  ------------------
  |  Branch (5936:2): [True: 0, False: 249]
  ------------------
 5937|      0|	case SC_CARD_TYPE_PIV_II_OBERTHUR:
  ------------------
  |  Branch (5937:2): [True: 0, False: 249]
  ------------------
 5938|      0|	case SC_CARD_TYPE_PIV_II_GEMALTO:
  ------------------
  |  Branch (5938:2): [True: 0, False: 249]
  ------------------
 5939|      0|	case SC_CARD_TYPE_PIV_II_SWISSBIT:
  ------------------
  |  Branch (5939:2): [True: 0, False: 249]
  ------------------
 5940|      0|		priv->card_issues |= 0; /* could add others here */
 5941|      0|		break;
 5942|       |
 5943|    183|	case SC_CARD_TYPE_PIV_II_BASE:
  ------------------
  |  Branch (5943:2): [True: 183, False: 66]
  ------------------
 5944|    184|	case SC_CARD_TYPE_PIV_II_HIST:
  ------------------
  |  Branch (5944:2): [True: 1, False: 248]
  ------------------
 5945|    184|	case SC_CARD_TYPE_PIV_II_800_73_4:
  ------------------
  |  Branch (5945:2): [True: 0, False: 249]
  ------------------
 5946|    184|		priv->card_issues |= 0; /* could add others here */
 5947|    184|		break;
 5948|       |
 5949|      1|	case SC_CARD_TYPE_PIV_II_GI_DE_DUAL_CAC:
  ------------------
  |  Branch (5949:2): [True: 1, False: 248]
  ------------------
 5950|      1|	case SC_CARD_TYPE_PIV_II_GEMALTO_DUAL_CAC:
  ------------------
  |  Branch (5950:2): [True: 0, False: 249]
  ------------------
 5951|      1|	case SC_CARD_TYPE_PIV_II_OBERTHUR_DUAL_CAC:
  ------------------
  |  Branch (5951:2): [True: 0, False: 249]
  ------------------
 5952|      1|		priv->card_issues |= CI_VERIFY_LC0_FAIL |
  ------------------
  |  |  585|      1|#define CI_VERIFY_LC0_FAIL		    0x00000002U /* VERIFY Lc=0 never returns 90 00 if PIN not needed */
  ------------------
 5953|      1|				     CI_PIV_AID_LOSE_STATE |
  ------------------
  |  |  591|      1|#define CI_PIV_AID_LOSE_STATE		    0x00000040U /* PIV AID can lose the login state run with out it*/
  ------------------
 5954|      1|				     CI_NO_RANDOM |
  ------------------
  |  |  587|      1|#define CI_NO_RANDOM			    0x00000004U /* can not use Challenge to get random data or no 9B key */
  ------------------
 5955|      1|				     CI_OTHER_AID_LOSE_STATE;
  ------------------
  |  |  593|      1|#define CI_OTHER_AID_LOSE_STATE		    0x00000100U /* Other drivers match routines may reset our security state and lose AID!!! */
  ------------------
 5956|      1|		break;
 5957|       |
 5958|      0|	case SC_CARD_TYPE_PIV_II_GENERIC:
  ------------------
  |  Branch (5958:2): [True: 0, False: 249]
  ------------------
 5959|      0|		priv->card_issues |= CI_VERIFY_LC0_FAIL |
  ------------------
  |  |  585|      0|#define CI_VERIFY_LC0_FAIL		    0x00000002U /* VERIFY Lc=0 never returns 90 00 if PIN not needed */
  ------------------
 5960|      0|				     CI_OTHER_AID_LOSE_STATE;
  ------------------
  |  |  593|      0|#define CI_OTHER_AID_LOSE_STATE		    0x00000100U /* Other drivers match routines may reset our security state and lose AID!!! */
  ------------------
 5961|      0|		break;
 5962|       |
 5963|      1|	case SC_CARD_TYPE_PIV_II_PIVKEY:
  ------------------
  |  Branch (5963:2): [True: 1, False: 248]
  ------------------
 5964|      1|		priv->card_issues |= CI_VERIFY_LC0_FAIL |
  ------------------
  |  |  585|      1|#define CI_VERIFY_LC0_FAIL		    0x00000002U /* VERIFY Lc=0 never returns 90 00 if PIN not needed */
  ------------------
 5965|      1|				     CI_PIV_AID_LOSE_STATE | /* be conservative */
  ------------------
  |  |  591|      1|#define CI_PIV_AID_LOSE_STATE		    0x00000040U /* PIV AID can lose the login state run with out it*/
  ------------------
 5966|      1|				     CI_NO_RANDOM;	     /* does not have 9B key */
  ------------------
  |  |  587|      1|#define CI_NO_RANDOM			    0x00000004U /* can not use Challenge to get random data or no 9B key */
  ------------------
 5967|       |							     /* Discovery object returns 6A 82 so is not on card by default */
 5968|      1|		break;
 5969|       |
 5970|      0|	default:
  ------------------
  |  Branch (5970:2): [True: 0, False: 249]
  ------------------
 5971|      0|		priv->card_issues |= CI_VERIFY_LC0_FAIL |
  ------------------
  |  |  585|      0|#define CI_VERIFY_LC0_FAIL		    0x00000002U /* VERIFY Lc=0 never returns 90 00 if PIN not needed */
  ------------------
 5972|      0|				     CI_OTHER_AID_LOSE_STATE;
  ------------------
  |  |  593|      0|#define CI_OTHER_AID_LOSE_STATE		    0x00000100U /* Other drivers match routines may reset our security state and lose AID!!! */
  ------------------
 5973|       |		/* opensc.conf may have it wrong, continue anyway */
 5974|      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__
  |  |  ------------------
  ------------------
 5975|      0|		card->type = SC_CARD_TYPE_PIV_II_GENERIC;
 5976|    249|	}
 5977|    249|	sc_log(card->ctx, "PIV_MATCH card->type:%d r2:%d CI:%08x r:%d AI:%08x\n",
  ------------------
  |  |   71|    249|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5978|    249|			card->type, r2, priv->card_issues, r, priv->alg_ids);
 5979|       |
 5980|    249|	if (!(priv->card_issues & CI_DISCOVERY_USELESS) && !(priv->init_flags & PIV_INIT_DISCOVERY_PARSED)) {
  ------------------
  |  |  590|    249|#define CI_DISCOVERY_USELESS		    0x00000020U /* Discovery can not be used to query active AID invalid or no data returned */
  ------------------
              	if (!(priv->card_issues & CI_DISCOVERY_USELESS) && !(priv->init_flags & PIV_INIT_DISCOVERY_PARSED)) {
  ------------------
  |  |  382|    248|#define PIV_INIT_DISCOVERY_PARSED		0x00000004u
  ------------------
  |  Branch (5980:6): [True: 248, False: 1]
  |  Branch (5980:53): [True: 242, False: 6]
  ------------------
 5981|       |		/*
 5982|       |		 * We now know PIV AID is active, test DISCOVERY object again
 5983|       |		 * Some PIV don't support DISCOVERY and return
 5984|       |		 * SC_ERROR_INCORRECT_PARAMETERS. Any error
 5985|       |		 * including SC_ERROR_FILE_NOT_FOUND means we cannot use discovery
 5986|       |		 * to test for active AID.
 5987|       |		 */
 5988|    242|		r2 = piv_find_discovery(card);
 5989|       |
 5990|    242|		if (r2 < 0) {
  ------------------
  |  Branch (5990:7): [True: 241, False: 1]
  ------------------
 5991|    241|			priv->card_issues |= CI_DISCOVERY_USELESS;
  ------------------
  |  |  590|    241|#define CI_DISCOVERY_USELESS		    0x00000020U /* Discovery can not be used to query active AID invalid or no data returned */
  ------------------
 5992|    241|			piv_obj_cache_free_entry(card, PIV_OBJ_DISCOVERY, PIV_OBJ_CACHE_NOT_PRESENT);
  ------------------
  |  |  153|    241|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
 5993|    241|		}
 5994|    242|	}
 5995|       |
 5996|    249|	sc_log(card->ctx, "PIV_MATCH card->type:%d r2:%d CI:%08x r:%d AI:%08x\n",
  ------------------
  |  |   71|    249|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5997|    249|			card->type, r2, priv->card_issues, r, priv->alg_ids);
 5998|       |	/* Matched, caller will use or free priv and sc_lock as needed */
 5999|    249|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    249|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    249|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    249|	int _ret = r; \
  |  |  |  |  155|    249|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 249, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    249|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 249]
  |  |  |  |  ------------------
  |  |  |  |  157|    249|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    249|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    249|	return _ret; \
  |  |  |  |  163|    249|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6000|       |
 6001|  4.13k|err:
 6002|  4.13k|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH failed card->type:%d r2:%d CI:%08x r:%d AI:%08x\n",
  ------------------
  |  |   70|  4.13k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 6003|  4.13k|			card->type, r2, priv->card_issues, r, priv->alg_ids);
 6004|       |	/* don't match. Does not have a PIV applet. */
 6005|  4.13k|	piv_finish(card);
 6006|  4.13k|	card->type = saved_type;
 6007|  4.13k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  4.13k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  4.13k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  4.13k|	int _ret = r; \
  |  |  |  |  155|  4.13k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4.13k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  4.13k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  4.13k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 4.13k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  4.13k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  4.13k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|  4.13k|	return _ret; \
  |  |  |  |  163|  4.13k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6008|  4.13k|}
card-piv.c:piv_find_discovery:
 5158|    390|{
 5159|    390|	int r = 0;
 5160|    390|	size_t rbuflen;
 5161|    390|	u8 *rbuf = NULL;
 5162|    390|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  440|    390|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 5163|       |
 5164|    390|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    390|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    390|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    390|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 390]
  |  |  ------------------
  ------------------
 5165|       |
 5166|       |	/*
 5167|       |	 * During piv_card_reader_lock_obtained,
 5168|       |	 * we use the discovery object to test if card present, and
 5169|       |	 * if PIV AID is active.
 5170|       |	 */
 5171|    390|	if (priv->obj_cache[PIV_OBJ_DISCOVERY].flags & PIV_OBJ_CACHE_NOT_PRESENT) {
  ------------------
  |  |  153|    390|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
  |  Branch (5171:6): [True: 0, False: 390]
  ------------------
 5172|      0|		r = SC_ERROR_DATA_OBJECT_NOT_FOUND;
  ------------------
  |  |   66|      0|#define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
  ------------------
 5173|      0|		goto end;
 5174|      0|	}
 5175|       |
 5176|       |	/* If not valid: read, test,  cache */
 5177|    390|	if (!(priv->obj_cache[PIV_OBJ_DISCOVERY].flags & PIV_OBJ_CACHE_VALID)) {
  ------------------
  |  |  151|    390|#define PIV_OBJ_CACHE_VALID		1
  ------------------
  |  Branch (5177:6): [True: 390, False: 0]
  ------------------
 5178|    390|		r = piv_process_discovery(card);
 5179|    390|	} else {
 5180|       |		/* if already in cache,force read */
 5181|      0|		rbuflen = 1;
 5182|      0|		r = piv_get_data(card, PIV_OBJ_DISCOVERY, &rbuf, &rbuflen);
 5183|       |		/* if same response as last, no need to parse */
 5184|      0|		if (r == 0 && priv->obj_cache[PIV_OBJ_DISCOVERY].obj_len == 0)
  ------------------
  |  Branch (5184:7): [True: 0, False: 0]
  |  Branch (5184:17): [True: 0, False: 0]
  ------------------
 5185|      0|			goto end;
 5186|       |
 5187|      0|		if (r >= 0 && priv->obj_cache[PIV_OBJ_DISCOVERY].obj_len == rbuflen &&
  ------------------
  |  Branch (5187:7): [True: 0, False: 0]
  |  Branch (5187:17): [True: 0, False: 0]
  ------------------
 5188|      0|				priv->obj_cache[PIV_OBJ_DISCOVERY].obj_data &&
  ------------------
  |  Branch (5188:5): [True: 0, False: 0]
  ------------------
 5189|      0|				!memcmp(rbuf, priv->obj_cache[PIV_OBJ_DISCOVERY].obj_data, rbuflen)) {
  ------------------
  |  Branch (5189:5): [True: 0, False: 0]
  ------------------
 5190|      0|			goto end;
 5191|      0|		}
 5192|       |		/* This should not happen  bad card */
 5193|      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__
  |  |  ------------------
  ------------------
 5194|      0|		r = SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|      0|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
 5195|      0|		goto end;
 5196|      0|	}
 5197|       |
 5198|    390|end:
 5199|    390|	free(rbuf);
 5200|    390|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    390|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    390|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    390|	int _ret = r; \
  |  |  |  |  155|    390|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 390, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    390|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    383|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 383, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  157|    390|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    390|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    390|	return _ret; \
  |  |  |  |  163|    390|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5201|    390|}
card-piv.c:piv_process_discovery:
 5051|    390|{
 5052|    390|	int r;
 5053|    390|	u8 *rbuf = NULL;
 5054|    390|	size_t rbuflen = 0;
 5055|       |
 5056|    390|	r = piv_get_cached_data(card, PIV_OBJ_DISCOVERY, &rbuf, &rbuflen);
 5057|       |	/* Note rbuf and rbuflen are now pointers into cache */
 5058|    390|	if (r < 0)
  ------------------
  |  Branch (5058:6): [True: 358, False: 32]
  ------------------
 5059|    358|		goto err;
 5060|       |
 5061|       |	/* the object is now cached, see what we have */
 5062|     32|	r = piv_parse_discovery(card, rbuf, rbuflen, 0);
 5063|       |
 5064|    390|err:
 5065|    390|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    390|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    390|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    390|	int _ret = r; \
  |  |  |  |  155|    390|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 390, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    390|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    383|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 383, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  157|    390|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    390|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    390|	return _ret; \
  |  |  |  |  163|    390|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5066|    390|}
card-piv.c:piv_get_cached_data:
 3201|    824|{
 3202|       |
 3203|    824|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  440|    824|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 3204|    824|	int r;
 3205|    824|	u8 *rbuf = NULL;
 3206|    824|	size_t rbuflen;
 3207|       |
 3208|    824|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    824|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    824|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    824|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 824]
  |  |  ------------------
  ------------------
 3209|       |
 3210|    824|	if (enumtag < 0 || enumtag >= PIV_OBJ_LAST_ENUM)
  ------------------
  |  Branch (3210:6): [True: 0, False: 824]
  |  Branch (3210:21): [True: 0, False: 824]
  ------------------
 3211|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 3212|       |
 3213|    824|	sc_log(card->ctx, "#%d, %s", enumtag, piv_objects[enumtag].name);
  ------------------
  |  |   71|    824|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3214|       |
 3215|       |	/* see if we have it cached */
 3216|    824|	if (priv->obj_cache[enumtag].flags & PIV_OBJ_CACHE_VALID) {
  ------------------
  |  |  151|    824|#define PIV_OBJ_CACHE_VALID		1
  ------------------
  |  Branch (3216:6): [True: 0, False: 824]
  ------------------
 3217|       |
 3218|      0|		sc_log(card->ctx, "found #%d %p:%zu %p:%zu",
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3219|      0|				enumtag,
 3220|      0|				priv->obj_cache[enumtag].obj_data,
 3221|      0|				priv->obj_cache[enumtag].obj_len,
 3222|      0|				priv->obj_cache[enumtag].internal_obj_data,
 3223|      0|				priv->obj_cache[enumtag].internal_obj_len);
 3224|       |
 3225|      0|		if (priv->obj_cache[enumtag].obj_len == 0) {
  ------------------
  |  Branch (3225:7): [True: 0, False: 0]
  ------------------
 3226|      0|			r = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
 3227|      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__
  |  |  ------------------
  ------------------
 3228|      0|			goto err;
 3229|      0|		}
 3230|      0|		*buf = priv->obj_cache[enumtag].obj_data;
 3231|      0|		*buf_len = priv->obj_cache[enumtag].obj_len;
 3232|      0|		r = (int)*buf_len;
 3233|      0|		goto ok;
 3234|      0|	}
 3235|       |
 3236|       |	/*
 3237|       |	 * If we know it can not be on the card  i.e. History object
 3238|       |	 * has been read, and we know what other certs may or
 3239|       |	 * may not be on the card. We can avoid extra overhead
 3240|       |	 * Also used if object on card was not parsable
 3241|       |	 */
 3242|       |
 3243|    824|	if (priv->obj_cache[enumtag].flags & PIV_OBJ_CACHE_NOT_PRESENT) {
  ------------------
  |  |  153|    824|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
  |  Branch (3243:6): [True: 0, False: 824]
  ------------------
 3244|      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__
  |  |  ------------------
  ------------------
 3245|      0|		r = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
 3246|      0|		goto err;
 3247|      0|	}
 3248|       |
 3249|       |	/* Not cached, try to get it, piv_get_data will allocate a buf */
 3250|    824|	sc_log(card->ctx, "get #%d", enumtag);
  ------------------
  |  |   71|    824|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3251|    824|	rbuflen = 1;
 3252|    824|	r = piv_get_data(card, enumtag, &rbuf, &rbuflen);
 3253|    824|	if (r > 0) {
  ------------------
  |  Branch (3253:6): [True: 156, False: 668]
  ------------------
 3254|    156|		priv->obj_cache[enumtag].flags |= PIV_OBJ_CACHE_VALID;
  ------------------
  |  |  151|    156|#define PIV_OBJ_CACHE_VALID		1
  ------------------
 3255|    156|		priv->obj_cache[enumtag].obj_len = r;
 3256|    156|		priv->obj_cache[enumtag].obj_data = rbuf;
 3257|    156|		*buf = rbuf;
 3258|    156|		*buf_len = r;
 3259|       |
 3260|    156|		sc_log(card->ctx, "added #%d  %p:%zu %p:%zu",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3261|    156|				enumtag,
 3262|    156|				priv->obj_cache[enumtag].obj_data,
 3263|    156|				priv->obj_cache[enumtag].obj_len,
 3264|    156|				priv->obj_cache[enumtag].internal_obj_data,
 3265|    156|				priv->obj_cache[enumtag].internal_obj_len);
 3266|       |
 3267|    668|	} else {
 3268|    668|		free(rbuf);
 3269|    668|		if (r == 0 || r == SC_ERROR_FILE_NOT_FOUND) {
  ------------------
  |  |   51|    668|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (3269:7): [True: 0, False: 668]
  |  Branch (3269:17): [True: 62, False: 606]
  ------------------
 3270|     62|			r = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|     62|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
 3271|     62|			priv->obj_cache[enumtag].flags |= PIV_OBJ_CACHE_VALID;
  ------------------
  |  |  151|     62|#define PIV_OBJ_CACHE_VALID		1
  ------------------
 3272|     62|			priv->obj_cache[enumtag].obj_len = 0;
 3273|    606|		} else {
 3274|    606|			goto err;
 3275|    606|		}
 3276|    668|	}
 3277|    218|ok:
 3278|       |
 3279|    824|err:
 3280|    824|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    824|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    824|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    824|	int _ret = r; \
  |  |  |  |  155|    824|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 668, False: 156]
  |  |  |  |  ------------------
  |  |  |  |  156|    668|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    668|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 668, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    668|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    668|	} else { \
  |  |  |  |  159|    156|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    156|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    156|	} \
  |  |  |  |  162|    824|	return _ret; \
  |  |  |  |  163|    824|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3281|    824|}
card-piv.c:piv_parse_discovery:
 4995|     32|{
 4996|     32|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  440|     32|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 4997|     32|	int r = 0;
 4998|     32|	const u8 *body;
 4999|     32|	size_t bodylen;
 5000|     32|	const u8 *aid;
 5001|     32|	size_t aidlen;
 5002|     32|	const u8 *pinp;
 5003|     32|	size_t pinplen;
 5004|     32|	unsigned int cla_out, tag_out;
 5005|       |
 5006|     32|	if (rbuflen != 0) {
  ------------------
  |  Branch (5006:6): [True: 32, False: 0]
  ------------------
 5007|     32|		body = rbuf;
 5008|     32|		if ((r = sc_asn1_read_tag(&body, rbuflen, &cla_out, &tag_out, &bodylen)) != SC_SUCCESS ||
  ------------------
  |  |   28|     64|#define SC_SUCCESS				0
  ------------------
  |  Branch (5008:7): [True: 0, False: 32]
  ------------------
 5009|     32|				body == NULL ||
  ------------------
  |  Branch (5009:5): [True: 0, False: 32]
  ------------------
 5010|     32|				bodylen == 0 ||
  ------------------
  |  Branch (5010:5): [True: 1, False: 31]
  ------------------
 5011|     31|				((cla_out | tag_out) != 0x7E)) {
  ------------------
  |  Branch (5011:5): [True: 0, False: 31]
  ------------------
 5012|      1|			sc_log(card->ctx, "DER problem %d", r);
  ------------------
  |  |   71|      1|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5013|      1|			r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      1|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5014|      1|			goto err;
 5015|      1|		}
 5016|       |
 5017|     31|		sc_log(card->ctx, "Discovery 0x%2.2x 0x%2.2x %p:%zu",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 5018|     31|				cla_out, tag_out, body, bodylen);
 5019|     31|		aidlen = 0;
 5020|     31|		aid = sc_asn1_find_tag(card->ctx, body, bodylen, 0x4F, &aidlen);
 5021|     31|		if (aid == NULL || aidlen < piv_aids[0].len_short ||
  ------------------
  |  Branch (5021:7): [True: 4, False: 27]
  |  Branch (5021:22): [True: 2, False: 25]
  ------------------
 5022|     25|				memcmp(aid, piv_aids[0].value, piv_aids[0].len_short) != 0) {
  ------------------
  |  Branch (5022:5): [True: 18, False: 7]
  ------------------
 5023|     24|			sc_log(card->ctx, "Discovery object not PIV");
  ------------------
  |  |   71|     24|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5024|     24|			r = SC_ERROR_INVALID_CARD; /* This is an error */
  ------------------
  |  |   60|     24|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 5025|     24|			goto err;
 5026|     24|		}
 5027|      7|		if (aid_only == 0) {
  ------------------
  |  Branch (5027:7): [True: 7, False: 0]
  ------------------
 5028|      7|			pinp = sc_asn1_find_tag(card->ctx, body, bodylen, 0x5F2F, &pinplen);
 5029|      7|			if (pinp && pinplen == 2) {
  ------------------
  |  Branch (5029:8): [True: 5, False: 2]
  |  Branch (5029:16): [True: 4, False: 1]
  ------------------
 5030|      4|				priv->init_flags |= PIV_INIT_DISCOVERY_PP;
  ------------------
  |  |  383|      4|#define PIV_INIT_DISCOVERY_PP			0x00000008u
  ------------------
 5031|      4|				priv->pin_policy = (*pinp << 8) + *(pinp + 1);
 5032|      4|				sc_log(card->ctx, "Discovery pinp flags=0x%2.2x 0x%2.2x", *pinp, *(pinp + 1));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 5033|      4|				if ((priv->pin_policy & (PIV_PP_PIN | PIV_PP_GLOBAL)) == (PIV_PP_PIN | PIV_PP_GLOBAL) &&
  ------------------
  |  |  371|      4|#define PIV_PP_PIN		0x00004000u
  ------------------
              				if ((priv->pin_policy & (PIV_PP_PIN | PIV_PP_GLOBAL)) == (PIV_PP_PIN | PIV_PP_GLOBAL) &&
  ------------------
  |  |  372|      4|#define PIV_PP_GLOBAL		0x00002000u
  ------------------
              				if ((priv->pin_policy & (PIV_PP_PIN | PIV_PP_GLOBAL)) == (PIV_PP_PIN | PIV_PP_GLOBAL) &&
  ------------------
  |  |  371|      4|#define PIV_PP_PIN		0x00004000u
  ------------------
              				if ((priv->pin_policy & (PIV_PP_PIN | PIV_PP_GLOBAL)) == (PIV_PP_PIN | PIV_PP_GLOBAL) &&
  ------------------
  |  |  372|      4|#define PIV_PP_GLOBAL		0x00002000u
  ------------------
  |  Branch (5033:9): [True: 2, False: 2]
  ------------------
 5034|      2|						priv->pin_policy & PIV_PP_GLOBAL_PRIMARY) {
  ------------------
  |  |  377|      2|#define PIV_PP_GLOBAL_PRIMARY	0x00000020u
  ------------------
  |  Branch (5034:7): [True: 1, False: 1]
  ------------------
 5035|      1|					sc_log(card->ctx, "Pin Preference - Global");
  ------------------
  |  |   71|      1|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5036|      1|					priv->pin_preference = 0x00;
 5037|      1|				}
 5038|      4|			}
 5039|      7|		}
 5040|      7|		r = SC_SUCCESS;
  ------------------
  |  |   28|      7|#define SC_SUCCESS				0
  ------------------
 5041|      7|		priv->init_flags |= PIV_INIT_DISCOVERY_PARSED;
  ------------------
  |  |  382|      7|#define PIV_INIT_DISCOVERY_PARSED		0x00000004u
  ------------------
 5042|      7|	}
 5043|       |
 5044|     32|err:
 5045|     32|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     32|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     32|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     32|	int _ret = r; \
  |  |  |  |  155|     32|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 32, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     32|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     25|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 25, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5046|     32|}
card-piv.c:piv_get_data:
 3091|    824|{
 3092|    824|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  440|    824|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 3093|    824|	u8 *p;
 3094|    824|	u8 *tbuf;
 3095|    824|	int r = 0;
 3096|    824|	u8 tagbuf[8];
 3097|    824|	size_t tag_len;
 3098|    824|	int alloc_buf = 0;
 3099|       |
 3100|    824|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    824|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    824|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    824|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 824]
  |  |  ------------------
  ------------------
 3101|       |
 3102|    824|	sc_log(card->ctx, "#%d, %s", enumtag, piv_objects[enumtag].name);
  ------------------
  |  |   71|    824|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3103|       |
 3104|    824|	r = sc_lock(card); /* do check len and get data in same transaction */
 3105|    824|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|    824|#define SC_SUCCESS				0
  ------------------
  |  Branch (3105:6): [True: 0, False: 824]
  ------------------
 3106|      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__
  |  |  ------------------
  ------------------
 3107|      0|		return r;
 3108|      0|	}
 3109|       |
 3110|    824|	tag_len = piv_objects[enumtag].tag_len;
 3111|       |
 3112|    824|	p = tagbuf;
 3113|    824|	r = sc_asn1_put_tag(0x5c, piv_objects[enumtag].tag_value, tag_len, tagbuf, sizeof(tagbuf), &p);
 3114|    824|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|    824|#define SC_SUCCESS				0
  ------------------
  |  Branch (3114:6): [True: 0, False: 824]
  ------------------
 3115|      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__
  |  |  ------------------
  ------------------
 3116|      0|		goto err;
 3117|      0|	}
 3118|       |
 3119|    824|	if (*buf_len == 1 && *buf == NULL) {
  ------------------
  |  Branch (3119:6): [True: 824, False: 0]
  |  Branch (3119:23): [True: 824, False: 0]
  ------------------
 3120|    824|		*buf_len = priv->max_object_size; /* will allocate below */
 3121|    824|		alloc_buf = 1;
 3122|    824|	}
 3123|       |
 3124|    824|	sc_log(card->ctx, "buffer for #%d *buf=0x%p len=%zu", enumtag, *buf, *buf_len);
  ------------------
  |  |   71|    824|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3125|    824|	if (*buf == NULL && *buf_len > 0) {
  ------------------
  |  Branch (3125:6): [True: 824, False: 0]
  |  Branch (3125:22): [True: 824, False: 0]
  ------------------
 3126|    824|		if (*buf_len > MAX_FILE_SIZE) {
  ------------------
  |  |  220|    824|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (3126:7): [True: 0, False: 824]
  ------------------
 3127|      0|			r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 3128|      0|			goto err;
 3129|      0|		}
 3130|    824|		*buf = malloc(*buf_len);
 3131|    824|		if (*buf == NULL) {
  ------------------
  |  Branch (3131:7): [True: 0, False: 824]
  ------------------
 3132|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 3133|      0|			goto err;
 3134|      0|		}
 3135|    824|	}
 3136|       |
 3137|       |#ifdef ENABLE_PIV_SM
 3138|       |	/*
 3139|       |	 * Over contact reader, OK to read non sensitive object in clear even when SM is active
 3140|       |	 * but only if using default policy and we are not in reader_lock_obtained
 3141|       |	 * Discovery object will use SM from reader_lock_obtained to catch if SM is still valid
 3142|       |	 * i.e. no interference from other applications
 3143|       |	 */
 3144|       |	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",
 3145|       |			enumtag, card->sm_ctx.sm_mode, piv_objects[enumtag].flags, priv->sm_flags, priv->init_flags);
 3146|       |	if (priv->sm_flags & PIV_SM_FLAGS_SM_IS_ACTIVE &&
 3147|       |			enumtag != PIV_OBJ_DISCOVERY &&
 3148|       |			card->sm_ctx.sm_mode == SM_MODE_TRANSMIT &&
 3149|       |			!(piv_objects[enumtag].flags & PIV_OBJECT_NEEDS_PIN) &&
 3150|       |			!(priv->sm_flags & (PIV_SM_FLAGS_NEVER | PIV_SM_FLAGS_ALWAYS)) &&
 3151|       |			!(priv->init_flags & (PIV_INIT_CONTACTLESS | PIV_INIT_IN_READER_LOCK_OBTAINED))) {
 3152|       |		sc_log(card->ctx, "Set PIV_SM_GET_DATA_IN_CLEAR");
 3153|       |		priv->sm_flags |= PIV_SM_GET_DATA_IN_CLEAR;
 3154|       |	}
 3155|       |
 3156|       |#endif /* ENABLE_PIV_SM */
 3157|    824|	r = piv_general_io(card, 0xCB, 0x3F, 0xFF, tagbuf, p - tagbuf, *buf, *buf_len);
 3158|    824|	if (r > 0) {
  ------------------
  |  Branch (3158:6): [True: 206, False: 618]
  ------------------
 3159|    206|		int r_tag;
 3160|    206|		unsigned int cla_out, tag_out;
 3161|    206|		size_t bodylen = 0;
 3162|    206|		const u8 *body = *buf;
 3163|    206|		r_tag = sc_asn1_read_tag(&body, r, &cla_out, &tag_out, &bodylen);
 3164|    206|		if (r_tag != SC_SUCCESS || body == NULL ||
  ------------------
  |  |   28|    412|#define SC_SUCCESS				0
  ------------------
  |  Branch (3164:7): [True: 10, False: 196]
  |  Branch (3164:30): [True: 8, False: 188]
  ------------------
 3165|    188|				((cla_out << 24 | tag_out) != piv_objects[enumtag].resp_tag)) {
  ------------------
  |  Branch (3165:5): [True: 32, False: 156]
  ------------------
 3166|     50|			sc_log(card->ctx, "invalid tag or length r_tag:%d body:%p", r_tag, body);
  ------------------
  |  |   71|     50|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3167|     50|			r = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|     50|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
 3168|     50|			goto err;
 3169|     50|		}
 3170|    156|		*buf_len = (body - *buf) + bodylen;
 3171|    618|	} else if (r == 0) {
  ------------------
  |  Branch (3171:13): [True: 11, False: 607]
  ------------------
 3172|     11|		r = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|     11|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
 3173|     11|		goto err;
 3174|    607|	} else {
 3175|    607|		goto err;
 3176|    607|	}
 3177|       |
 3178|    156|	if (alloc_buf && *buf) {
  ------------------
  |  Branch (3178:6): [True: 156, False: 0]
  |  Branch (3178:19): [True: 156, False: 0]
  ------------------
 3179|    156|		tbuf = malloc(r);
 3180|    156|		if (tbuf == NULL) {
  ------------------
  |  Branch (3180:7): [True: 0, False: 156]
  ------------------
 3181|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 3182|      0|			goto err;
 3183|      0|		}
 3184|    156|		memcpy(tbuf, *buf, r);
 3185|    156|		free(*buf);
 3186|    156|		alloc_buf = 0;
 3187|    156|		*buf = tbuf;
 3188|    156|	}
 3189|       |
 3190|    824|err:
 3191|    824|	if (alloc_buf) {
  ------------------
  |  Branch (3191:6): [True: 668, False: 156]
  ------------------
 3192|    668|		free(*buf);
 3193|    668|		*buf = NULL;
 3194|    668|	}
 3195|    824|	sc_unlock(card);
 3196|    824|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    824|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    824|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    824|	int _ret = r; \
  |  |  |  |  155|    824|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 668, False: 156]
  |  |  |  |  ------------------
  |  |  |  |  156|    668|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    668|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 668, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    668|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    668|	} else { \
  |  |  |  |  159|    156|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    156|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    156|	} \
  |  |  |  |  162|    824|	return _ret; \
  |  |  |  |  163|    824|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3197|    824|}
card-piv.c:piv_general_io:
 1794|    824|{
 1795|    824|	int r;
 1796|    824|	sc_apdu_t apdu;
 1797|       |
 1798|    824|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    824|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    824|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    824|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 824]
  |  |  ------------------
  ------------------
 1799|       |
 1800|    824|	r = sc_lock(card);
 1801|    824|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|    824|#define SC_SUCCESS				0
  ------------------
  |  Branch (1801:6): [True: 0, False: 824]
  ------------------
 1802|    824|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1803|       |
 1804|    824|	sc_format_apdu(card, &apdu,
 1805|    824|			recvbuf ? SC_APDU_CASE_4_SHORT : SC_APDU_CASE_3_SHORT,
  ------------------
  |  |  294|    824|#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 (1805:4): [True: 824, False: 0]
  ------------------
 1806|    824|			ins, p1, p2);
 1807|    824|	apdu.flags |= SC_APDU_FLAGS_CHAINING;
  ------------------
  |  |  306|    824|#define SC_APDU_FLAGS_CHAINING		0x00000001UL
  ------------------
 1808|       |#ifdef ENABLE_PIV_SM
 1809|       |	if (card->sm_ctx.sm_mode != SM_MODE_NONE && sendbuflen > 255) {
 1810|       |		/* tell apdu.c to not do the chaining, let the SM get_apdu do it */
 1811|       |		apdu.flags |= SC_APDU_FLAGS_SM_CHAINING;
 1812|       |	}
 1813|       |#endif
 1814|    824|	apdu.lc = sendbuflen;
 1815|    824|	apdu.datalen = sendbuflen;
 1816|    824|	apdu.data = sendbuf;
 1817|       |
 1818|    824|	if (recvbuf && recvbuflen) {
  ------------------
  |  Branch (1818:6): [True: 824, False: 0]
  |  Branch (1818:17): [True: 824, False: 0]
  ------------------
 1819|    824|		apdu.le = (recvbuflen > 256) ? 256 : recvbuflen;
  ------------------
  |  Branch (1819:13): [True: 824, False: 0]
  ------------------
 1820|    824|		apdu.resplen = recvbuflen;
 1821|    824|	} else {
 1822|      0|		apdu.le = 0;
 1823|      0|		apdu.resplen = 0;
 1824|      0|	}
 1825|    824|	apdu.resp = recvbuf;
 1826|       |
 1827|       |	/* with new adpu.c and chaining, this actually reads the whole object */
 1828|    824|	r = sc_transmit_apdu(card, &apdu);
 1829|       |
 1830|       |	/* adpu will not have sw1,sw2 set because sc_sm_single_transmit called sc_sm_stop, */
 1831|    824|	if (r < 0) {
  ------------------
  |  Branch (1831:6): [True: 11, False: 813]
  ------------------
 1832|     11|		sc_log(card->ctx, "Transmit failed");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1833|     11|		goto err;
 1834|     11|	}
 1835|       |
 1836|    813|	if (apdu.sw1 == 0x69 && apdu.sw2 == 0x88)
  ------------------
  |  Branch (1836:6): [True: 14, False: 799]
  |  Branch (1836:26): [True: 4, False: 10]
  ------------------
 1837|      4|		r = SC_ERROR_SM_INVALID_SESSION_KEY;
  ------------------
  |  |  119|      4|#define SC_ERROR_SM_INVALID_SESSION_KEY		-1604
  ------------------
 1838|    809|	else
 1839|    809|		r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1840|       |
 1841|    813|	if (r < 0) {
  ------------------
  |  Branch (1841:6): [True: 596, False: 217]
  ------------------
 1842|    596|		sc_log(card->ctx, "Card returned error ");
  ------------------
  |  |   71|    596|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1843|    596|		goto err;
 1844|    596|	}
 1845|       |
 1846|    217|	r = (int)apdu.resplen;
 1847|       |
 1848|    824|err:
 1849|    824|	sc_unlock(card);
 1850|    824|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    824|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    824|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    824|	int _ret = r; \
  |  |  |  |  155|    824|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 618, False: 206]
  |  |  |  |  ------------------
  |  |  |  |  156|    618|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    607|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 607, False: 11]
  |  |  |  |  ------------------
  |  |  |  |  157|    618|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    618|	} else { \
  |  |  |  |  159|    206|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    206|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    206|	} \
  |  |  |  |  162|    824|	return _ret; \
  |  |  |  |  163|    824|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1851|    824|}
card-piv.c:piv_obj_cache_free_entry:
 5455|   263k|{
 5456|   263k|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  440|   263k|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 5457|       |
 5458|   263k|	if (priv->obj_cache[enumtag].obj_data)
  ------------------
  |  Branch (5458:6): [True: 156, False: 263k]
  ------------------
 5459|    156|		free(priv->obj_cache[enumtag].obj_data);
 5460|   263k|	priv->obj_cache[enumtag].obj_data = NULL;
 5461|   263k|	priv->obj_cache[enumtag].obj_len = 0;
 5462|       |
 5463|   263k|	if (priv->obj_cache[enumtag].internal_obj_data)
  ------------------
  |  Branch (5463:6): [True: 0, False: 263k]
  ------------------
 5464|      0|		free(priv->obj_cache[enumtag].internal_obj_data);
 5465|   263k|	priv->obj_cache[enumtag].internal_obj_data = NULL;
 5466|   263k|	priv->obj_cache[enumtag].internal_obj_len = 0;
 5467|   263k|	priv->obj_cache[enumtag].flags = flags;
 5468|       |
 5469|   263k|	return SC_SUCCESS;
  ------------------
  |  |   28|   263k|#define SC_SUCCESS				0
  ------------------
 5470|   263k|}
card-piv.c:piv_find_aid:
 2903|  4.37k|{
 2904|  4.37k|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  440|  4.37k|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 2905|  4.37k|	u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
 2906|  4.37k|	int r, i, j;
 2907|  4.37k|	const u8 *tag;
 2908|  4.37k|	size_t taglen;
 2909|  4.37k|	const u8 *nextac;
 2910|  4.37k|	const u8 *next80;
 2911|  4.37k|	const u8 *pix;
 2912|  4.37k|	size_t pixlen;
 2913|  4.37k|	const u8 *al_label;
 2914|  4.37k|	size_t al_labellen;
 2915|  4.37k|	const u8 *actag; /* Cipher Suite */
 2916|  4.37k|	size_t actaglen;
 2917|  4.37k|	const u8 *csai; /* Cipher Suite Algorithm Identifier */
 2918|  4.37k|	size_t csailen;
 2919|  4.37k|	size_t resplen = sizeof(rbuf);
 2920|       |#ifdef ENABLE_PIV_SM
 2921|       |	int found_csai = 0;
 2922|       |#endif
 2923|       |
 2924|  4.37k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  4.37k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  4.37k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  4.37k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 4.37k]
  |  |  ------------------
  ------------------
 2925|       |
 2926|       |	/* first  see if the default application will return a template
 2927|       |	 * that we know about.
 2928|       |	 */
 2929|       |
 2930|  4.37k|	r = iso7816_select_aid(card, piv_aids[0].value, piv_aids[0].len_short, rbuf, &resplen);
 2931|  4.37k|	if (r > 0 && priv->aid_der.value && resplen == priv->aid_der.len && !memcmp(priv->aid_der.value, rbuf, resplen)) {
  ------------------
  |  Branch (2931:6): [True: 0, False: 4.37k]
  |  Branch (2931:15): [True: 0, False: 0]
  |  Branch (2931:38): [True: 0, False: 0]
  |  Branch (2931:70): [True: 0, False: 0]
  ------------------
 2932|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2933|       |		/* no need to parse again, same as last time */
 2934|      0|	}
 2935|  4.37k|	if (r >= 0 && resplen > 2) {
  ------------------
  |  Branch (2935:6): [True: 430, False: 3.94k]
  |  Branch (2935:16): [True: 388, False: 42]
  ------------------
 2936|    388|		tag = sc_asn1_find_tag(card->ctx, rbuf, resplen, 0x61, &taglen);
 2937|    388|		if (tag != NULL) {
  ------------------
  |  Branch (2937:7): [True: 291, False: 97]
  ------------------
 2938|    291|			priv->init_flags |= PIV_INIT_AID_PARSED;
  ------------------
  |  |  380|    291|#define PIV_INIT_AID_PARSED			0x00000001u
  ------------------
 2939|       |			/* look for 800-73-4 0xAC for Cipher Suite Algorithm Identifier Table 14 */
 2940|       |			/* 800-73-4 only expects 1 0xAC tag len 6 with a 80 01 xx 06 01 00
 2941|       |			 * where xx is the SM csID either 27 or 2E.
 2942|       |			 * Some vendors may include entries for supported Algorithms even when
 2943|       |			 * not required. We will use these if possible
 2944|       |			 * Will look for multiple 0x80 with in 0xAC value too.
 2945|       |			 */
 2946|    291|			nextac = tag;
 2947|    317|			while ((actag = sc_asn1_find_tag(card->ctx, nextac, taglen - (nextac - tag),
  ------------------
  |  Branch (2947:11): [True: 26, False: 291]
  ------------------
 2948|    317|						0xAC, &actaglen)) != NULL) {
 2949|     26|				nextac = actag + actaglen;
 2950|       |
 2951|     26|				next80 = actag;
 2952|     47|				while ((csai = sc_asn1_find_tag(card->ctx, next80, actaglen - (next80 - actag),
  ------------------
  |  Branch (2952:12): [True: 21, False: 26]
  ------------------
 2953|     47|							0x80, &csailen)) != NULL) {
 2954|     21|					next80 = csai + csailen;
 2955|     21|					if (csailen == 1) {
  ------------------
  |  Branch (2955:10): [True: 11, False: 10]
  ------------------
 2956|     11|						sc_log(card->ctx, "0xAC 0x80 entry:0x%2.2x found", *csai);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2957|     11|						j = piv_ai_map_find_by_id(card, *csai);
 2958|     11|						if (j >= 0) {
  ------------------
  |  Branch (2958:11): [True: 8, False: 3]
  ------------------
 2959|      8|							priv->alg_ids |= ai_map[j].ai_flag;
 2960|      8|							continue;
 2961|      8|						}
 2962|       |#ifdef ENABLE_PIV_SM
 2963|       |						/* check if id is NIST SM */
 2964|       |						for (i = 0; i < PIV_CSS_SIZE; i++) {
 2965|       |							if (*csai != css[i].id)
 2966|       |								continue;
 2967|       |							if (found_csai) {
 2968|       |								sc_log(card->ctx, "found multiple csIDs, using first");
 2969|       |							} else {
 2970|       |								priv->cs = &css[i];
 2971|       |								priv->csID = *csai;
 2972|       |								found_csai++;
 2973|       |								priv->init_flags |= PIV_INIT_AID_AC_SM;
 2974|       |							}
 2975|       |						}
 2976|       |#endif /* ENABLE_PIV_SM */
 2977|     11|					}
 2978|     21|				}
 2979|     26|			}
 2980|       |
 2981|       |			/* Last chance to distinguish card type based on Application Label '50' */
 2982|    291|			al_label = sc_asn1_find_tag(card->ctx, tag, taglen, 0x50, &al_labellen);
 2983|    291|			if (al_label != NULL) {
  ------------------
  |  Branch (2983:8): [True: 20, False: 271]
  ------------------
 2984|     20|				sc_log_hex(card->ctx, "Application Label", al_label, al_labellen);
  ------------------
  |  |  129|     20|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|     20|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2985|     20|				if ((priv->al_label = malloc(al_labellen)) == NULL) {
  ------------------
  |  Branch (2985:9): [True: 0, False: 20]
  ------------------
 2986|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2987|      0|				}
 2988|     20|				memcpy(priv->al_label, al_label, al_labellen);
 2989|     20|				priv->al_labellen = (int)al_labellen;
 2990|     20|			}
 2991|       |
 2992|    291|			pix = sc_asn1_find_tag(card->ctx, tag, taglen, 0x4F, &pixlen);
 2993|    291|			if (pix != NULL) {
  ------------------
  |  Branch (2993:8): [True: 266, False: 25]
  ------------------
 2994|    266|				sc_log(card->ctx, "found PIX");
  ------------------
  |  |   71|    266|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2995|       |
 2996|       |				/* early cards returned full AID, rather then just the pix */
 2997|    315|				for (i = 0; piv_aids[i].len_long != 0; i++) {
  ------------------
  |  Branch (2997:17): [True: 292, False: 23]
  ------------------
 2998|    292|					if ((pixlen >= piv_aids[i].len_long - 5 &&
  ------------------
  |  Branch (2998:11): [True: 286, False: 6]
  ------------------
 2999|    286|							    memcmp(pix, piv_aids[i].value + 5, piv_aids[i].len_long - 5) == 0) ||
  ------------------
  |  Branch (2999:12): [True: 236, False: 50]
  ------------------
 3000|     56|							((pixlen >= piv_aids[i].len_short && memcmp(pix, piv_aids[i].value,
  ------------------
  |  Branch (3000:10): [True: 43, False: 13]
  |  Branch (3000:45): [True: 7, False: 36]
  ------------------
 3001|    243|													     piv_aids[i].len_short) == 0))) {
 3002|    243|						free(priv->aid_der.value); /* free previous value if any */
 3003|    243|						if ((priv->aid_der.value = malloc(resplen)) == NULL) {
  ------------------
  |  Branch (3003:11): [True: 0, False: 243]
  ------------------
 3004|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3005|      0|						}
 3006|    243|						memcpy(priv->aid_der.value, rbuf, resplen);
 3007|    243|						priv->aid_der.len = resplen;
 3008|    243|						LOG_FUNC_RETURN(card->ctx, i);
  ------------------
  |  |  164|    243|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (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: 240, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 240]
  |  |  |  |  ------------------
  |  |  |  |  157|    240|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    240|	} 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|    243|	return _ret; \
  |  |  |  |  163|    243|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3009|    243|					}
 3010|    292|				}
 3011|    266|			}
 3012|    291|		}
 3013|    388|	}
 3014|       |
 3015|  4.13k|	LOG_FUNC_RETURN(card->ctx, SC_ERROR_NO_CARD_SUPPORT);
  ------------------
  |  |  164|  4.13k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  4.13k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  4.13k|	int _ret = r; \
  |  |  |  |  155|  4.13k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4.13k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  4.13k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  4.13k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 4.13k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  4.13k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  4.13k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|  4.13k|	return _ret; \
  |  |  |  |  163|  4.13k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3016|  4.13k|}
card-piv.c:piv_ai_map_find_by_id:
 2886|     11|{
 2887|       |	/* piv_private_data_t * priv = PIV_DATA(card); */
 2888|     11|	int i;
 2889|       |
 2890|     60|	for (i = 0; ai_map[i].ai_id != 0; i++) {
  ------------------
  |  Branch (2890:14): [True: 57, False: 3]
  ------------------
 2891|     57|		if (ai_map[i].ai_id == id)
  ------------------
  |  Branch (2891:7): [True: 8, False: 49]
  ------------------
 2892|      8|			return i;
 2893|     57|	}
 2894|      3|	return -1;
 2895|     11|}
card-piv.c:piv_process_ccc:
 5139|    185|{
 5140|    185|	int r = 0;
 5141|    185|	u8 *rbuf = NULL;
 5142|    185|	size_t rbuflen = 0;
 5143|       |
 5144|    185|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 5145|    185|	r = piv_get_cached_data(card, PIV_OBJ_CCC, &rbuf, &rbuflen);
 5146|       |
 5147|    185|	if (r < 0)
  ------------------
  |  Branch (5147:6): [True: 138, False: 47]
  ------------------
 5148|    138|		goto err;
 5149|       |
 5150|       |	/* the object is now cached, see what we have */
 5151|     47|	r = piv_parse_ccc(card, rbuf, rbuflen);
 5152|    185|err:
 5153|    185|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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|    172|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 172, False: 13]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5154|    185|}
card-piv.c:piv_parse_ccc:
 5075|     47|{
 5076|     47|	int r = 0;
 5077|     47|	const u8 *body;
 5078|     47|	size_t bodylen;
 5079|     47|	unsigned int cla_out, tag_out;
 5080|       |
 5081|     47|	u8 tag;
 5082|     47|	const u8 *end;
 5083|     47|	size_t len;
 5084|       |
 5085|     47|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  440|     47|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 5086|       |
 5087|     47|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     47|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     47|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     47|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 47]
  |  |  ------------------
  ------------------
 5088|       |
 5089|     47|	if (rbuf == NULL || rbuflen == 0) {
  ------------------
  |  Branch (5089:6): [True: 0, False: 47]
  |  Branch (5089:22): [True: 0, False: 47]
  ------------------
 5090|      0|		r = SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|      0|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
 5091|      0|		goto err;
 5092|      0|	}
 5093|       |
 5094|       |	/* Outer layer is a DER tlv */
 5095|     47|	body = rbuf;
 5096|     47|	if ((r = sc_asn1_read_tag(&body, rbuflen, &cla_out, &tag_out, &bodylen)) != SC_SUCCESS ||
  ------------------
  |  |   28|     94|#define SC_SUCCESS				0
  ------------------
  |  Branch (5096:6): [True: 0, False: 47]
  ------------------
 5097|     47|			body == NULL ||
  ------------------
  |  Branch (5097:4): [True: 0, False: 47]
  ------------------
 5098|     47|			bodylen == 0 ||
  ------------------
  |  Branch (5098:4): [True: 1, False: 46]
  ------------------
 5099|     46|			((cla_out << 24 | tag_out) != piv_objects[PIV_OBJ_CCC].resp_tag)) {
  ------------------
  |  Branch (5099:4): [True: 0, False: 46]
  ------------------
 5100|      1|		sc_log(card->ctx, "DER problem %d", r);
  ------------------
  |  |   71|      1|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5101|      1|		r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      1|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5102|      1|		goto err;
 5103|      1|	}
 5104|       |
 5105|     46|	priv->ccc_flags |= PIV_CCC_FOUND;
  ------------------
  |  |  170|     46|#define PIV_CCC_FOUND		0x00000001
  ------------------
 5106|       |
 5107|       |	/* CCC  entries are simple tlv */
 5108|     46|	end = body + bodylen;
 5109|    267|	for (; (body < end); body += len) {
  ------------------
  |  Branch (5109:9): [True: 254, False: 13]
  ------------------
 5110|    254|		r = sc_simpletlv_read_tag(&body, end - body, &tag, &len);
 5111|    254|		if (r < 0)
  ------------------
  |  Branch (5111:7): [True: 33, False: 221]
  ------------------
 5112|     33|			goto err;
 5113|    221|		switch (tag) {
  ------------------
  |  Branch (5113:11): [True: 108, False: 113]
  ------------------
 5114|     86|		case PIV_CCC_TAG_F0:
  ------------------
  |  |  176|     86|#define PIV_CCC_TAG_F0		0xF0
  ------------------
  |  Branch (5114:3): [True: 86, False: 135]
  ------------------
 5115|     86|			if (len == 0x15) {
  ------------------
  |  Branch (5115:8): [True: 50, False: 36]
  ------------------
 5116|     50|				if (memcmp(body, "\xA0\x00\x00\x03\08", 5) == 0)
  ------------------
  |  Branch (5116:9): [True: 9, False: 41]
  ------------------
 5117|      9|					priv->ccc_flags |= PIV_CCC_F0_PIV;
  ------------------
  |  |  171|      9|#define PIV_CCC_F0_PIV		0x00000002
  ------------------
 5118|     41|				else if (memcmp(body, "\xA0\x00\x00\x00\x79", 5) == 0)
  ------------------
  |  Branch (5118:14): [True: 10, False: 31]
  ------------------
 5119|     10|					priv->ccc_flags |= PIV_CCC_F0_CAC;
  ------------------
  |  |  172|     10|#define PIV_CCC_F0_CAC		0x00000004
  ------------------
 5120|     50|				if (*(body + 6) == 0x02)
  ------------------
  |  Branch (5120:9): [True: 8, False: 42]
  ------------------
 5121|      8|					priv->ccc_flags |= PIV_CCC_F0_JAVA;
  ------------------
  |  |  173|      8|#define PIV_CCC_F0_JAVA		0x00000008
  ------------------
 5122|     50|			}
 5123|     86|			break;
 5124|     22|		case PIV_CCC_TAG_F3:
  ------------------
  |  |  177|     22|#define PIV_CCC_TAG_F3		0xF3
  ------------------
  |  Branch (5124:3): [True: 22, False: 199]
  ------------------
 5125|     22|			if (len == 0x10) {
  ------------------
  |  Branch (5125:8): [True: 11, False: 11]
  ------------------
 5126|     11|				if (memcmp(body, "\xA0\x00\x00\x00\x79\x04", 6) == 0)
  ------------------
  |  Branch (5126:9): [True: 1, False: 10]
  ------------------
 5127|      1|					priv->ccc_flags |= PIV_CCC_F3_CAC_PKI;
  ------------------
  |  |  174|      1|#define PIV_CCC_F3_CAC_PKI	0x00000010
  ------------------
 5128|     11|			}
 5129|     22|			break;
 5130|    221|		}
 5131|    221|	}
 5132|       |
 5133|     47|err:
 5134|     47|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     47|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     47|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     47|	int _ret = r; \
  |  |  |  |  155|     47|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 47, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     47|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     34|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 34, False: 13]
  |  |  |  |  ------------------
  |  |  |  |  157|     47|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     47|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     47|	return _ret; \
  |  |  |  |  163|     47|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5135|     47|}
card-piv.c:piv_init:
 6012|    249|{
 6013|    249|	int r = 0;
 6014|    249|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  440|    249|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 6015|    249|	unsigned long flags;
 6016|    249|	unsigned long flags_eddsa;
 6017|    249|	unsigned long flags_xeddsa;
 6018|    249|	unsigned long ext_flags;
 6019|       |
 6020|    249|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    249|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    249|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    249|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 249]
  |  |  ------------------
  ------------------
 6021|       |
 6022|    249|	r = sc_lock(card); /* hold until match or init is complete */
 6023|    249|	LOG_TEST_RET(card->ctx, r, "sc_lock 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: 0, False: 249]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|    249|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 249]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6024|       |
 6025|       |	/* piv_match_card_continued called from card match should have left card->drv_data */
 6026|    249|	if (priv == NULL) {
  ------------------
  |  Branch (6026:6): [True: 0, False: 249]
  ------------------
 6027|      0|		r = piv_match_card_continued(card);
 6028|      0|		priv = PIV_DATA(card);
  ------------------
  |  |  440|      0|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 6029|      0|		if (r < 0 || !priv) {
  ------------------
  |  Branch (6029:7): [True: 0, False: 0]
  |  Branch (6029:16): [True: 0, False: 0]
  ------------------
 6030|      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__
  |  |  ------------------
  ------------------
 6031|      0|			sc_unlock(card);
 6032|      0|			piv_finish(card);
 6033|       |			/* tell sc_connect_card to try other driver */
 6034|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6035|      0|		}
 6036|      0|	}
 6037|       |
 6038|       |	/* read "card_driver PIV-II" opensc.conf options, and env parameters */
 6039|    249|	piv_load_options(card);
 6040|       |
 6041|    249|	priv->pstate = PIV_STATE_INIT;
 6042|       |
 6043|    249|	sc_log(card->ctx, "Max send = %zu recv = %zu card->type:%d, CI:%08x AI:%08x",
  ------------------
  |  |   71|    249|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 6044|    249|			card->max_send_size, card->max_recv_size, card->type, priv->card_issues, priv->alg_ids);
 6045|    249|	card->cla = 0x00;
 6046|    249|	if (card->name == NULL)
  ------------------
  |  Branch (6046:6): [True: 249, False: 0]
  ------------------
 6047|    249|		card->name = card->driver->name;
 6048|       |
 6049|    249|	priv->enumtag = piv_aids[0].enumtag;
 6050|       |
 6051|       |	/* PKCS#11 may try to generate session keys, and get confused
 6052|       |	 * if SC_ALGORITHM_ONBOARD_KEY_GEN is present
 6053|       |	 * piv-tool can still do this, just don't tell PKCS#11
 6054|       |	 */
 6055|       |
 6056|    249|	flags = SC_ALGORITHM_RSA_RAW;
  ------------------
  |  |  102|    249|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
 6057|       |
 6058|    249|	if (card->type == SC_CARD_TYPE_PIV_II_SWISSBIT) {
  ------------------
  |  Branch (6058:6): [True: 0, False: 249]
  ------------------
 6059|      0|		flags |= SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|      0|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
 6060|      0|	}
 6061|       |
 6062|    249|	if (priv->alg_ids & AI_RSA_1024)
  ------------------
  |  |  600|    249|#define AI_RSA_1024			    0x00000001U
  ------------------
  |  Branch (6062:6): [True: 248, False: 1]
  ------------------
 6063|    248|		_sc_card_add_rsa_alg(card, 1024, flags, 0); /* mandatory */
 6064|       |
 6065|    249|	if (priv->alg_ids & AI_RSA_2048)
  ------------------
  |  |  601|    249|#define AI_RSA_2048			    0x00000002U
  ------------------
  |  Branch (6065:6): [True: 247, False: 2]
  ------------------
 6066|    247|		_sc_card_add_rsa_alg(card, 2048, flags, 0); /* optional */
 6067|       |
 6068|    249|	if (priv->alg_ids & AI_RSA_3072)
  ------------------
  |  |  602|    249|#define AI_RSA_3072			    0x00000004U
  ------------------
  |  Branch (6068:6): [True: 248, False: 1]
  ------------------
 6069|    248|		_sc_card_add_rsa_alg(card, 3072, flags, 0); /* optional */
 6070|       |
 6071|    249|	if (priv->alg_ids & AI_RSA_4096)
  ------------------
  |  |  603|    249|#define AI_RSA_4096			    0x00000008U
  ------------------
  |  Branch (6071:6): [True: 12, False: 237]
  ------------------
 6072|     12|		_sc_card_add_rsa_alg(card, 4096, flags, 0); /* non standard */
 6073|       |
 6074|    249|	if (!(priv->card_issues & CI_NO_EC)) {
  ------------------
  |  |  597|    249|#define CI_NO_EC			    0x00000800U /* No EC at all */
  ------------------
  |  Branch (6074:6): [True: 249, False: 0]
  ------------------
 6075|    249|		int i;
 6076|    249|		flags = SC_ALGORITHM_ECDSA_RAW | SC_ALGORITHM_ECDH_CDH_RAW | SC_ALGORITHM_ECDSA_HASH_NONE;
  ------------------
  |  |  174|    249|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
              		flags = SC_ALGORITHM_ECDSA_RAW | SC_ALGORITHM_ECDH_CDH_RAW | SC_ALGORITHM_ECDSA_HASH_NONE;
  ------------------
  |  |  173|    249|#define SC_ALGORITHM_ECDH_CDH_RAW	0x00200000
  ------------------
              		flags = SC_ALGORITHM_ECDSA_RAW | SC_ALGORITHM_ECDH_CDH_RAW | SC_ALGORITHM_ECDSA_HASH_NONE;
  ------------------
  |  |  175|    249|#define SC_ALGORITHM_ECDSA_HASH_NONE		SC_ALGORITHM_RSA_HASH_NONE
  |  |  ------------------
  |  |  |  |  133|    249|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  ------------------
 6077|    249|		ext_flags = SC_ALGORITHM_EXT_EC_NAMEDCURVE | SC_ALGORITHM_EXT_EC_UNCOMPRESES;
  ------------------
  |  |  201|    249|#define SC_ALGORITHM_EXT_EC_NAMEDCURVE   0x00000008
  ------------------
              		ext_flags = SC_ALGORITHM_EXT_EC_NAMEDCURVE | SC_ALGORITHM_EXT_EC_UNCOMPRESES;
  ------------------
  |  |  202|    249|#define SC_ALGORITHM_EXT_EC_UNCOMPRESES  0x00000010
  ------------------
 6078|    249|		flags_eddsa = SC_ALGORITHM_EDDSA_RAW;
  ------------------
  |  |  188|    249|#define SC_ALGORITHM_EDDSA_RAW		0x00400000
  ------------------
 6079|    249|		flags_xeddsa = SC_ALGORITHM_XEDDSA_RAW | SC_ALGORITHM_ECDH_CDH_RAW;
  ------------------
  |  |  189|    249|#define SC_ALGORITHM_XEDDSA_RAW		0x00800000
  ------------------
              		flags_xeddsa = SC_ALGORITHM_XEDDSA_RAW | SC_ALGORITHM_ECDH_CDH_RAW;
  ------------------
  |  |  173|    249|#define SC_ALGORITHM_ECDH_CDH_RAW	0x00200000
  ------------------
 6080|       |
 6081|  1.24k|		for (i = 0; ec_curves[i].oid.value[0] >= 0; i++) {
  ------------------
  |  Branch (6081:15): [True: 996, False: 249]
  ------------------
 6082|    996|			if (ec_curves[i].key_type == SC_ALGORITHM_EC) {
  ------------------
  |  |   70|    996|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (6082:8): [True: 498, False: 498]
  ------------------
 6083|    498|				if (!(priv->card_issues & CI_NO_EC384 && ec_curves[i].size == 384))
  ------------------
  |  |  596|    996|#define CI_NO_EC384			    0x00000400U /* does not have EC 384 */
  ------------------
  |  Branch (6083:11): [True: 62, False: 436]
  |  Branch (6083:46): [True: 31, False: 31]
  ------------------
 6084|    467|					_sc_card_add_ec_alg(card, ec_curves[i].size, flags, ext_flags, &ec_curves[i].oid);
 6085|    498|			}
 6086|       |
 6087|    498|			else if (priv->alg_ids & AI_25519 && ec_curves[i].key_type == SC_ALGORITHM_EDDSA)
  ------------------
  |  |  606|    996|#define AI_25519			    0x00100000U
  ------------------
              			else if (priv->alg_ids & AI_25519 && ec_curves[i].key_type == SC_ALGORITHM_EDDSA)
  ------------------
  |  |   72|     28|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (6087:13): [True: 28, False: 470]
  |  Branch (6087:41): [True: 14, False: 14]
  ------------------
 6088|     14|				_sc_card_add_eddsa_alg(card, ec_curves[i].size, flags_eddsa, ext_flags, &ec_curves[i].oid);
 6089|       |
 6090|    484|			else if (priv->alg_ids & AI_X25519 && ec_curves[i].key_type == SC_ALGORITHM_XEDDSA)
  ------------------
  |  |  607|    968|#define AI_X25519			    0x00200000U
  ------------------
              			else if (priv->alg_ids & AI_X25519 && ec_curves[i].key_type == SC_ALGORITHM_XEDDSA)
  ------------------
  |  |   73|     14|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (6090:13): [True: 14, False: 470]
  |  Branch (6090:42): [True: 13, False: 1]
  ------------------
 6091|     13|				_sc_card_add_xeddsa_alg(card, ec_curves[i].size, flags_xeddsa, ext_flags, &ec_curves[i].oid);
 6092|    996|		}
 6093|    249|	}
 6094|       |
 6095|    249|	if (!(priv->card_issues & CI_NO_RANDOM))
  ------------------
  |  |  587|    249|#define CI_NO_RANDOM			    0x00000004U /* can not use Challenge to get random data or no 9B key */
  ------------------
  |  Branch (6095:6): [True: 247, False: 2]
  ------------------
 6096|    247|		card->caps |= SC_CARD_CAP_RNG;
  ------------------
  |  |  550|    247|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
 6097|       |
 6098|       |	/* May turn off SC_CARD_CAP_ISO7816_PIN_INFO later */
 6099|    249|	card->caps |= SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  553|    249|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
 6100|       |
 6101|       |	/*
 6102|       |	 * 800-73-3 cards may have discovery. "piv-like cards may or may not.
 6103|       |	 * 800-73-4 with VCI must have it as it has the pin policy needed for VCI .
 6104|       |	 */
 6105|       |
 6106|       |#ifdef ENABLE_PIV_SM
 6107|       |	/*
 6108|       |	 * 800-73-4
 6109|       |	 * Response of AID says if SM is supported. Look for Cipher Suite
 6110|       |	 */
 6111|       |	if (priv->csID && priv->cs != NULL) {
 6112|       |		/*
 6113|       |		 * Main point in SM and VCI is to allow contactless access
 6114|       |		 */
 6115|       |		/* Only piv_init and piv_reader_lock_obtained should call piv_sm_open */
 6116|       |
 6117|       |		/* If user said PIV_SM_FLAGS_NEVER, dont start SM; implies limited contatless access */
 6118|       |		if (priv->sm_flags & PIV_SM_FLAGS_NEVER) {
 6119|       |			sc_log(card->ctx, "User has requested PIV_SM_FLAGS_NEVER");
 6120|       |			r = SC_SUCCESS; /* Users choice */
 6121|       |
 6122|       |		} else if ((priv->init_flags & PIV_INIT_CONTACTLESS) &&
 6123|       |				!(priv->pin_policy & PIV_PP_VCI_IMPL)) {
 6124|       |			sc_log(card->ctx, "Contactless and no card support for VCI");
 6125|       |			r = SC_SUCCESS; /* User should know VCI is not possible with their card; use like 800-73-3 contactless  */
 6126|       |
 6127|       |		} else if ((priv->init_flags & PIV_INIT_CONTACTLESS) &&
 6128|       |				!(priv->pin_policy & PIV_PP_VCI_WITHOUT_PC) &&
 6129|       |				(priv->pairing_code[0] == 0x00)) {
 6130|       |			sc_log(card->ctx, "Contactless, pairing_code required and no pairing code");
 6131|       |			r = SC_ERROR_PIN_CODE_INCORRECT; /* User should know they need to set pairing code */
 6132|       |
 6133|       |		} else {
 6134|       |			priv->sm_flags |= PIV_SM_FLAGS_DEFER_OPEN; /* tell priv_sm_open, OK to open */
 6135|       |			r = piv_sm_open(card);
 6136|       |			sc_log(card->ctx, "piv_sm_open returned:%d", r);
 6137|       |		}
 6138|       |
 6139|       |		/* If failed, and user said PIV_SM_FLAGS_ALWAYS quit */
 6140|       |		if (priv->sm_flags & PIV_SM_FLAGS_ALWAYS && r < 0) {
 6141|       |			sc_log(card->ctx, "User has requested PIV_SM_FLAGS_ALWAYS, SM has failed to start, don't use the card");
 6142|       |			LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_ALLOWED);
 6143|       |		}
 6144|       |
 6145|       |		/* user has wrong or no required pairing code */
 6146|       |		if (r == SC_ERROR_PIN_CODE_INCORRECT)
 6147|       |			LOG_FUNC_RETURN(card->ctx, r);
 6148|       |
 6149|       |		/* If SM did not start, or is not expected to start, continue on without it */
 6150|       |	}
 6151|       |#endif /* ENABLE_PIV_SM */
 6152|       |
 6153|       |	/*
 6154|       |	 * 800-73-3 cards may have a history object
 6155|       |	 * We want to process it now as this has information on what
 6156|       |	 * keys and certs. "piv like" cards may or may not have history
 6157|       |	 */
 6158|    249|	piv_process_history(card);
 6159|       |
 6160|    249|	priv->pstate = PIV_STATE_NORMAL;
 6161|    249|	sc_unlock(card);
 6162|    249|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    249|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    249|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    249|	int _ret = r; \
  |  |  |  |  155|    249|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 249, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    249|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 249]
  |  |  |  |  ------------------
  |  |  |  |  157|    249|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    249|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    249|	return _ret; \
  |  |  |  |  163|    249|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6163|    249|}
card-piv.c:piv_load_options:
 1686|    249|{
 1687|    249|	int r;
 1688|    249|	size_t i, j;
 1689|    249|	scconf_block **found_blocks, *block;
 1690|       |
 1691|       |#ifdef ENABLE_PIV_SM
 1692|       |	piv_private_data_t *priv = PIV_DATA(card);
 1693|       |	const char *option = NULL;
 1694|       |	int piv_pairing_code_found = 0;
 1695|       |	int piv_use_sm_found = 0;
 1696|       |
 1697|       |	/* pairing code is 8 decimal digits and is card specific */
 1698|       |	if ((option = getenv("PIV_PAIRING_CODE")) != NULL) {
 1699|       |		sc_log(card->ctx, "getenv(\"PIV_PAIRING_CODE\") found");
 1700|       |		if (piv_parse_pairing_code(card, option) == SC_SUCCESS) {
 1701|       |			memcpy(priv->pairing_code, option, PIV_PAIRING_CODE_LEN);
 1702|       |			piv_pairing_code_found = 1;
 1703|       |		}
 1704|       |	}
 1705|       |
 1706|       |	if ((option = getenv("PIV_USE_SM")) != NULL) {
 1707|       |		sc_log(card->ctx, "getenv(\"PIV_USE_SM\")=\"%s\"", option);
 1708|       |		if (!strcmp(option, "never")) {
 1709|       |			priv->sm_flags |= PIV_SM_FLAGS_NEVER;
 1710|       |			piv_use_sm_found = 1;
 1711|       |		} else if (!strcmp(option, "always")) {
 1712|       |			priv->sm_flags |= PIV_SM_FLAGS_ALWAYS;
 1713|       |			piv_use_sm_found = 1;
 1714|       |		} else {
 1715|       |			sc_log(card->ctx, "Invalid piv_use_sm: \"%s\"", option);
 1716|       |		}
 1717|       |	}
 1718|       |#endif
 1719|       |
 1720|    498|	for (i = 0; card->ctx->conf_blocks[i]; i++) {
  ------------------
  |  Branch (1720:14): [True: 249, False: 249]
  ------------------
 1721|    249|		found_blocks = scconf_find_blocks(card->ctx->conf, card->ctx->conf_blocks[i],
 1722|    249|				"card_driver", "PIV-II");
 1723|    249|		if (!found_blocks)
  ------------------
  |  Branch (1723:7): [True: 0, False: 249]
  ------------------
 1724|      0|			continue;
 1725|       |
 1726|    249|		for (j = 0, block = found_blocks[j]; block; j++, block = found_blocks[j]) {
  ------------------
  |  Branch (1726:40): [True: 0, False: 249]
  ------------------
 1727|       |
 1728|       |#ifdef ENABLE_PIV_SM
 1729|       |			/*
 1730|       |			 * "piv_use_sm" if card supports NIST sp800-73-4 sm, when should it be used
 1731|       |			 * never - use card like 800-73-3, i.e. contactless is very limited on
 1732|       |			 * true PIV cards. Some  PIV-like" card may allow this.
 1733|       |			 * this security risk
 1734|       |			 * always - Use even for contact interface.
 1735|       |			 * PINS, crypto and reading of object will not show up in logs
 1736|       |			 * or over network.
 1737|       |			 */
 1738|       |
 1739|       |			if (piv_use_sm_found == 0) {
 1740|       |				option = scconf_get_str(block, "piv_use_sm", "default");
 1741|       |				sc_log(card->ctx, "conf: \"piv_use_sm\"=\"%s\"", option);
 1742|       |				if (!strcmp(option, "default")) {
 1743|       |					/* no new flags */
 1744|       |				} else if (!strcmp(option, "never")) {
 1745|       |					priv->sm_flags |= PIV_SM_FLAGS_NEVER;
 1746|       |				} else if (!strcmp(option, "always")) {
 1747|       |					priv->sm_flags |= PIV_SM_FLAGS_ALWAYS;
 1748|       |				} else {
 1749|       |					sc_log(card->ctx, "Invalid piv_use_sm: \"%s\"", option);
 1750|       |				}
 1751|       |			}
 1752|       |
 1753|       |			/* This is really a card specific value and should not be in the conf file */
 1754|       |			if (piv_pairing_code_found == 0) {
 1755|       |				option = scconf_get_str(block, "piv_pairing_code", NULL);
 1756|       |				if (option && piv_parse_pairing_code(card, option) == SC_SUCCESS) {
 1757|       |					memcpy(priv->pairing_code, option, PIV_PAIRING_CODE_LEN);
 1758|       |				}
 1759|       |			}
 1760|       |#endif
 1761|      0|		}
 1762|    249|		free(found_blocks);
 1763|    249|	}
 1764|    249|	r = SC_SUCCESS;
  ------------------
  |  |   28|    249|#define SC_SUCCESS				0
  ------------------
 1765|    249|	return r;
 1766|    249|}
card-piv.c:piv_process_history:
 5211|    249|{
 5212|    249|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  440|    249|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 5213|    249|	int r;
 5214|    249|	int i, tmplen, tmplen2, tmplen3;
 5215|    249|	int enumtag;
 5216|    249|	u8 *rbuf = NULL;
 5217|    249|	size_t rbuflen = 0;
 5218|    249|	const u8 *body;
 5219|    249|	size_t bodylen;
 5220|    249|	const u8 *num;
 5221|    249|	size_t numlen;
 5222|    249|	const u8 *url = NULL;
 5223|    249|	size_t urllen;
 5224|    249|	u8 *ocfhfbuf = NULL;
 5225|    249|	unsigned int cla_out, tag_out;
 5226|    249|	size_t ocfhflen;
 5227|    249|	const u8 *seq;
 5228|    249|	const u8 *seqtag;
 5229|    249|	size_t seqlen;
 5230|    249|	const u8 *keyref;
 5231|    249|	size_t keyreflen;
 5232|    249|	const u8 *cert;
 5233|    249|	size_t certlen;
 5234|    249|	size_t certobjlen, i2;
 5235|    249|	u8 *certobj;
 5236|    249|	u8 *cp;
 5237|       |
 5238|    249|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    249|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    249|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    249|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 249]
  |  |  ------------------
  ------------------
 5239|       |
 5240|    249|	r = piv_get_cached_data(card, PIV_OBJ_HISTORY, &rbuf, &rbuflen);
 5241|    249|	if (r == SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|    249|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (5241:6): [True: 10, False: 239]
  ------------------
 5242|     10|		r = 0; /* OK if not found */
 5243|    249|	if (r <= 0) {
  ------------------
  |  Branch (5243:6): [True: 172, False: 77]
  ------------------
 5244|    172|		priv->obj_cache[PIV_OBJ_HISTORY].flags |= PIV_OBJ_CACHE_NOT_PRESENT;
  ------------------
  |  |  153|    172|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
 5245|    172|		goto err; /* no file, must be pre 800-73-3 card and not on card */
 5246|    172|	}
 5247|       |
 5248|       |	/* the object is now cached, see what we have */
 5249|     77|	if (rbuflen != 0) {
  ------------------
  |  Branch (5249:6): [True: 77, False: 0]
  ------------------
 5250|     77|		body = rbuf;
 5251|     77|		if ((r = sc_asn1_read_tag(&body, rbuflen, &cla_out, &tag_out, &bodylen)) != SC_SUCCESS ||
  ------------------
  |  |   28|    154|#define SC_SUCCESS				0
  ------------------
  |  Branch (5251:7): [True: 0, False: 77]
  ------------------
 5252|     77|				((cla_out << 24 | tag_out) != piv_objects[PIV_OBJ_HISTORY].resp_tag)) {
  ------------------
  |  Branch (5252:5): [True: 0, False: 77]
  ------------------
 5253|      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__
  |  |  ------------------
  ------------------
 5254|      0|			r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5255|      0|			goto err;
 5256|      0|		}
 5257|       |
 5258|     77|		if (body != NULL && bodylen != 0) {
  ------------------
  |  Branch (5258:7): [True: 77, False: 0]
  |  Branch (5258:23): [True: 76, False: 1]
  ------------------
 5259|     76|			numlen = 0;
 5260|     76|			num = sc_asn1_find_tag(card->ctx, body, bodylen, 0xC1, &numlen);
 5261|     76|			if (num) {
  ------------------
  |  Branch (5261:8): [True: 9, False: 67]
  ------------------
 5262|      9|				if (numlen != 1 || *num > PIV_OBJ_RETIRED_X509_20 - PIV_OBJ_RETIRED_X509_1 + 1) {
  ------------------
  |  Branch (5262:9): [True: 1, False: 8]
  |  Branch (5262:24): [True: 2, False: 6]
  ------------------
 5263|      3|					r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      3|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5264|      3|					goto err;
 5265|      3|				}
 5266|       |
 5267|      6|				priv->keysWithOnCardCerts = *num;
 5268|      6|			}
 5269|       |
 5270|     73|			numlen = 0;
 5271|     73|			num = sc_asn1_find_tag(card->ctx, body, bodylen, 0xC2, &numlen);
 5272|     73|			if (num) {
  ------------------
  |  Branch (5272:8): [True: 7, False: 66]
  ------------------
 5273|      7|				if (numlen != 1 || *num > PIV_OBJ_RETIRED_X509_20 - PIV_OBJ_RETIRED_X509_1 + 1) {
  ------------------
  |  Branch (5273:9): [True: 1, False: 6]
  |  Branch (5273:24): [True: 3, False: 3]
  ------------------
 5274|      4|					r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      4|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5275|      4|					goto err;
 5276|      4|				}
 5277|       |
 5278|      3|				priv->keysWithOffCardCerts = *num;
 5279|      3|			}
 5280|       |
 5281|     69|			url = sc_asn1_find_tag(card->ctx, body, bodylen, 0xF3, &urllen);
 5282|     69|			if (url) {
  ------------------
  |  Branch (5282:8): [True: 54, False: 15]
  ------------------
 5283|     54|				if (urllen > 118) {
  ------------------
  |  Branch (5283:9): [True: 0, False: 54]
  ------------------
 5284|      0|					r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5285|      0|					goto err;
 5286|      0|				}
 5287|     54|				priv->offCardCertURL = calloc(1, urllen + 1);
 5288|     54|				if (priv->offCardCertURL == NULL)
  ------------------
  |  Branch (5288:9): [True: 0, False: 54]
  ------------------
 5289|     54|					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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5290|     54|				memcpy(priv->offCardCertURL, url, urllen);
 5291|     54|			}
 5292|     69|		} else {
 5293|      1|			sc_log(card->ctx, "Problem with History object\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__
  |  |  ------------------
  ------------------
 5294|      1|			r = SC_SUCCESS; /* OK if not found */
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
 5295|      1|			goto err;
 5296|      1|		}
 5297|     77|	}
 5298|     69|	sc_log(card->ctx, "History on=%d off=%d URL=%s",
  ------------------
  |  |   71|    138|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  |  Branch (71:122): [True: 54, False: 15]
  |  |  ------------------
  ------------------
 5299|     69|			priv->keysWithOnCardCerts, priv->keysWithOffCardCerts,
 5300|     69|			priv->offCardCertURL ? priv->offCardCertURL : "NONE");
 5301|       |
 5302|       |	/* now mark what objects are on the card */
 5303|    108|	for (i = 0; i < priv->keysWithOnCardCerts; i++)
  ------------------
  |  Branch (5303:14): [True: 39, False: 69]
  ------------------
 5304|     39|		priv->obj_cache[PIV_OBJ_RETIRED_X509_1 + i].flags &= ~PIV_OBJ_CACHE_NOT_PRESENT;
  ------------------
  |  |  153|    108|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
 5305|       |
 5306|       |	/*
 5307|       |	 * If user has gotten copy of the file from the offCardCertsURL,
 5308|       |	 * we will read in and add the certs to the cache as listed on
 5309|       |	 * the card. some of the certs may be on the card as well.
 5310|       |	 *
 5311|       |	 * Get file name from url. verify that the filename is valid
 5312|       |	 * The URL ends in a SHA-256 string. We will use this as the filename
 5313|       |	 * in the directory used for the  PKCS15 cache
 5314|       |	 * "http://" <DNS name> "/" <ASCII-HEX encoded SHA-256 hash of OffCardKeyHistoryFile>
 5315|       |	 */
 5316|       |
 5317|     69|	r = 0;
 5318|     69|	if (priv->offCardCertURL) {
  ------------------
  |  Branch (5318:6): [True: 54, False: 15]
  ------------------
 5319|     54|		char *fp;
 5320|     54|		char filename[PATH_MAX];
 5321|       |
 5322|     54|		if (strncmp("http://", priv->offCardCertURL, 7)) {
  ------------------
  |  Branch (5322:7): [True: 52, False: 2]
  ------------------
 5323|     52|			r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|     52|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 5324|     52|			goto err;
 5325|     52|		}
 5326|       |		/* find the last /  so we have the filename part */
 5327|      2|		fp = strrchr(priv->offCardCertURL + 7, '/');
 5328|      2|		if (fp == NULL) {
  ------------------
  |  Branch (5328:7): [True: 1, False: 1]
  ------------------
 5329|      1|			r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      1|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 5330|      1|			goto err;
 5331|      1|		}
 5332|      1|		fp++;
 5333|      1|		if (strlen(fp) != 64) { /* ASCII-HEX encoded SHA-256 */
  ------------------
  |  Branch (5333:7): [True: 1, False: 0]
  ------------------
 5334|      1|			r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      1|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 5335|      1|			goto err;
 5336|      1|		}
 5337|      0|		for (i = 0; i < 64; i++) {
  ------------------
  |  Branch (5337:15): [True: 0, False: 0]
  ------------------
 5338|      0|			if (isxdigit((unsigned char)fp[i]) == 0) {
  ------------------
  |  Branch (5338:8): [True: 0, False: 0]
  ------------------
 5339|      0|				r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 5340|      0|				goto err;
 5341|      0|			}
 5342|      0|		}
 5343|       |
 5344|       |		/* Use the same directory as used for other OpenSC cached items */
 5345|      0|		r = sc_get_cache_dir(card->ctx, filename, sizeof(filename) - strlen(fp) - 2);
 5346|      0|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (5346:7): [True: 0, False: 0]
  ------------------
 5347|      0|			goto err;
 5348|       |#ifdef _WIN32
 5349|       |		strlcat(filename, "\\", PATH_MAX);
 5350|       |#else
 5351|      0|		strlcat(filename, "/", PATH_MAX);
 5352|      0|#endif
 5353|      0|		strlcat(filename, fp, PATH_MAX);
 5354|       |
 5355|      0|		r = piv_read_obj_from_file(card, filename,
 5356|      0|				&ocfhfbuf, &ocfhflen);
 5357|      0|		if (r == SC_ERROR_FILE_NOT_FOUND) {
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (5357:7): [True: 0, False: 0]
  ------------------
 5358|      0|			r = 0;
 5359|      0|			goto err;
 5360|      0|		}
 5361|       |
 5362|       |		/*
 5363|       |		 * Its a seq of seq of a key ref and cert
 5364|       |		 */
 5365|       |
 5366|      0|		body = ocfhfbuf;
 5367|      0|		if (sc_asn1_read_tag(&body, ocfhflen, &cla_out, &tag_out, &bodylen) != SC_SUCCESS ||
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (5367:7): [True: 0, False: 0]
  ------------------
 5368|      0|				body == NULL ||
  ------------------
  |  Branch (5368:5): [True: 0, False: 0]
  ------------------
 5369|      0|				bodylen == 0 ||
  ------------------
  |  Branch (5369:5): [True: 0, False: 0]
  ------------------
 5370|      0|				(cla_out | tag_out) != 0x30) {
  ------------------
  |  Branch (5370:5): [True: 0, False: 0]
  ------------------
 5371|      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__
  |  |  ------------------
  ------------------
 5372|      0|			r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5373|      0|			goto err;
 5374|      0|		}
 5375|      0|		seq = body;
 5376|      0|		while (bodylen > 0) {
  ------------------
  |  Branch (5376:10): [True: 0, False: 0]
  ------------------
 5377|      0|			seqtag = seq;
 5378|      0|			if (sc_asn1_read_tag(&seq, bodylen, &cla_out, &tag_out, &seqlen) != SC_SUCCESS ||
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (5378:8): [True: 0, False: 0]
  ------------------
 5379|      0|					seq == 0 ||
  ------------------
  |  Branch (5379:6): [True: 0, False: 0]
  ------------------
 5380|      0|					seqlen == 0 ||
  ------------------
  |  Branch (5380:6): [True: 0, False: 0]
  ------------------
 5381|      0|					(cla_out | tag_out) != 0x30) {
  ------------------
  |  Branch (5381:6): [True: 0, False: 0]
  ------------------
 5382|      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__
  |  |  ------------------
  ------------------
 5383|      0|				r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5384|      0|				goto err;
 5385|      0|			}
 5386|      0|			keyref = sc_asn1_find_tag(card->ctx, seq, seqlen, 0x04, &keyreflen);
 5387|      0|			if (!keyref || keyreflen != 1 ||
  ------------------
  |  Branch (5387:8): [True: 0, False: 0]
  |  Branch (5387:19): [True: 0, False: 0]
  ------------------
 5388|      0|					(*keyref < 0x82 || *keyref > 0x95)) {
  ------------------
  |  Branch (5388:7): [True: 0, False: 0]
  |  Branch (5388:25): [True: 0, False: 0]
  ------------------
 5389|      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__
  |  |  ------------------
  ------------------
 5390|      0|				r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5391|      0|				goto err;
 5392|      0|			}
 5393|      0|			cert = keyref + keyreflen;
 5394|      0|			certlen = seqlen - (cert - seq);
 5395|       |
 5396|      0|			enumtag = PIV_OBJ_RETIRED_X509_1 + *keyref - 0x82;
 5397|       |			/* now add the cert like another object */
 5398|       |
 5399|      0|			if ((tmplen = sc_asn1_put_tag(0x70, NULL, certlen, NULL, 0, NULL)) <= 0 ||
  ------------------
  |  Branch (5399:8): [True: 0, False: 0]
  ------------------
 5400|      0|					(tmplen2 = sc_asn1_put_tag(0x71, NULL, 1, NULL, 0, NULL)) <= 0 ||
  ------------------
  |  Branch (5400:6): [True: 0, False: 0]
  ------------------
 5401|      0|					(tmplen3 = sc_asn1_put_tag(0xFE, NULL, 0, NULL, 0, NULL)) <= 0) {
  ------------------
  |  Branch (5401:6): [True: 0, False: 0]
  ------------------
 5402|      0|				r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5403|      0|				goto err;
 5404|      0|			}
 5405|      0|			i2 = tmplen + tmplen2 + tmplen3;
 5406|      0|			tmplen = sc_asn1_put_tag(0x53, NULL, i2, NULL, 0, NULL);
 5407|      0|			if (tmplen <= 0) {
  ------------------
  |  Branch (5407:8): [True: 0, False: 0]
  ------------------
 5408|      0|				r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5409|      0|				goto err;
 5410|      0|			}
 5411|       |
 5412|      0|			certobjlen = tmplen;
 5413|      0|			certobj = malloc(certobjlen);
 5414|      0|			if (certobj == NULL) {
  ------------------
  |  Branch (5414:8): [True: 0, False: 0]
  ------------------
 5415|      0|				r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 5416|      0|				goto err;
 5417|      0|			}
 5418|      0|			cp = certobj;
 5419|      0|			if ((r = sc_asn1_put_tag(0x53, NULL, i2, cp, certobjlen, &cp)) != SC_SUCCESS ||
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (5419:8): [True: 0, False: 0]
  ------------------
 5420|      0|					(r = sc_asn1_put_tag(0x70, cert, certlen, cp, certobjlen - (cp - certobj), &cp)) != SC_SUCCESS ||
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (5420:6): [True: 0, False: 0]
  ------------------
 5421|      0|					(r = sc_asn1_put_tag(0x71, NULL, 1, cp, certobjlen - (cp - certobj), &cp)) != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (5421:6): [True: 0, False: 0]
  ------------------
 5422|      0|				goto err;
 5423|      0|			}
 5424|      0|			*cp++ = 0x00;
 5425|      0|			r = sc_asn1_put_tag(0xFE, NULL, 0, cp, certobjlen - (cp - certobj), &cp);
 5426|      0|			if (r != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (5426:8): [True: 0, False: 0]
  ------------------
 5427|      0|				goto err;
 5428|      0|			}
 5429|       |
 5430|      0|			priv->obj_cache[enumtag].obj_data = certobj;
 5431|      0|			priv->obj_cache[enumtag].obj_len = certobjlen;
 5432|      0|			priv->obj_cache[enumtag].flags |= PIV_OBJ_CACHE_VALID;
  ------------------
  |  |  151|      0|#define PIV_OBJ_CACHE_VALID		1
  ------------------
 5433|      0|			priv->obj_cache[enumtag].flags &= ~PIV_OBJ_CACHE_NOT_PRESENT;
  ------------------
  |  |  153|      0|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
 5434|       |
 5435|      0|			r = piv_cache_internal_data(card, enumtag);
 5436|      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__
  |  |  ------------------
  ------------------
 5437|       |
 5438|      0|			sc_log(card->ctx, "Added from off card file #%d %p:%zu 0x%02X",
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5439|      0|					enumtag,
 5440|      0|					priv->obj_cache[enumtag].obj_data,
 5441|      0|					priv->obj_cache[enumtag].obj_len, *keyref);
 5442|       |
 5443|      0|			bodylen -= (seqlen + seq - seqtag);
 5444|      0|			seq += seqlen;
 5445|      0|		}
 5446|      0|	}
 5447|    249|err:
 5448|    249|	if (ocfhfbuf)
  ------------------
  |  Branch (5448:6): [True: 0, False: 249]
  ------------------
 5449|      0|		free(ocfhfbuf);
 5450|    249|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    249|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    249|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    249|	int _ret = r; \
  |  |  |  |  155|    249|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 249, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    249|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    223|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 223, False: 26]
  |  |  |  |  ------------------
  |  |  |  |  157|    249|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    249|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    249|	return _ret; \
  |  |  |  |  163|    249|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5451|    249|}
card-piv.c:piv_finish:
 5474|  8.51k|{
 5475|  8.51k|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  440|  8.51k|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 5476|  8.51k|	int i;
 5477|       |
 5478|  8.51k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  8.51k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  8.51k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  8.51k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 8.51k]
  |  |  ------------------
  ------------------
 5479|  8.51k|	if (priv) {
  ------------------
  |  Branch (5479:6): [True: 4.38k, False: 4.13k]
  ------------------
 5480|  4.38k|		if (priv->context_specific) {
  ------------------
  |  Branch (5480:7): [True: 0, False: 4.38k]
  ------------------
 5481|      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__
  |  |  ------------------
  ------------------
 5482|      0|			priv->context_specific = 0;
 5483|      0|			sc_unlock(card);
 5484|      0|		}
 5485|  4.38k|		free(priv->aid_der.value);
 5486|  4.38k|		free(priv->al_label);
 5487|  4.38k|		if (priv->w_buf)
  ------------------
  |  Branch (5487:7): [True: 0, False: 4.38k]
  ------------------
 5488|      0|			free(priv->w_buf);
 5489|  4.38k|		if (priv->offCardCertURL)
  ------------------
  |  Branch (5489:7): [True: 54, False: 4.32k]
  ------------------
 5490|     54|			free(priv->offCardCertURL);
 5491|   267k|		for (i = 0; i < PIV_OBJ_LAST_ENUM - 1; i++) {
  ------------------
  |  Branch (5491:15): [True: 262k, False: 4.38k]
  ------------------
 5492|   262k|			piv_obj_cache_free_entry(card, i, 0);
 5493|   262k|		}
 5494|       |#ifdef ENABLE_PIV_SM
 5495|       |		piv_clear_cvc_content(&priv->sm_cvc);
 5496|       |		piv_clear_cvc_content(&priv->sm_in_cvc);
 5497|       |		piv_clear_sm_session(&priv->sm_session);
 5498|       |#endif /* ENABLE_PIV_SM */
 5499|       |
 5500|  4.38k|		free(priv);
 5501|       |		card->drv_data = NULL; /* priv */
 5502|  4.38k|	}
 5503|  8.51k|	return 0;
 5504|  8.51k|}
card-piv.c:piv_check_sw:
 6167|  5.18k|{
 6168|  5.18k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 6169|       |
 6170|  5.18k|	int r;
 6171|       |#ifdef ENABLE_PIV_SM
 6172|       |	int i;
 6173|       |#endif
 6174|  5.18k|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  440|  5.18k|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 6175|       |
 6176|  5.18k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  5.18k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  5.18k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  5.18k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 5.18k]
  |  |  ------------------
  ------------------
 6177|       |
 6178|       |	/* may be called before piv_init has allocated priv */
 6179|  5.18k|	if (priv) {
  ------------------
  |  Branch (6179:6): [True: 5.18k, False: 0]
  ------------------
 6180|       |		/* need to save sw1 and sw2 if trying to determine card_state from pin_cmd */
 6181|       |
 6182|  5.18k|		if (priv->pin_cmd_verify) {
  ------------------
  |  Branch (6182:7): [True: 0, False: 5.18k]
  ------------------
 6183|      0|			priv->pin_cmd_verify_sw1 = sw1;
 6184|      0|			priv->pin_cmd_verify_sw2 = sw2;
 6185|  5.18k|		} else {
 6186|       |			/* a command has completed and it is not verify
 6187|       |			 * If we are in a context_specific sequence, unlock
 6188|       |			 * This just decrements the extra lock count
 6189|       |			 */
 6190|  5.18k|			if (priv->context_specific) {
  ------------------
  |  Branch (6190:8): [True: 0, False: 5.18k]
  ------------------
 6191|      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__
  |  |  ------------------
  ------------------
 6192|      0|				priv->context_specific = 0;
 6193|      0|				sc_unlock(card);
 6194|      0|			}
 6195|  5.18k|		}
 6196|       |
 6197|  5.18k|		if (priv->card_issues & CI_VERIFY_630X) {
  ------------------
  |  |  584|  5.18k|#define CI_VERIFY_630X			    0x00000001U /* VERIFY tries left returns 630X rather then 63CX */
  ------------------
  |  Branch (6197:7): [True: 63, False: 5.12k]
  ------------------
 6198|       |
 6199|       |			/* Handle the Yubikey NEO or any other PIV card which returns in response to a verify
 6200|       |			 * 63 0X rather than 63 CX indicate the number of remaining PIN retries.
 6201|       |			 * Perhaps they misread the spec and thought 0xCX meant "clear" or "don't care", not a literal 0xC!
 6202|       |			 */
 6203|     63|			if (priv->pin_cmd_verify && sw1 == 0x63U) {
  ------------------
  |  Branch (6203:8): [True: 0, False: 63]
  |  Branch (6203:32): [True: 0, False: 0]
  ------------------
 6204|      0|				priv->pin_cmd_verify_sw2 |= 0xC0U; /* make it easier to test in other code */
 6205|      0|				if ((sw2 & ~0x0fU) == 0x00U) {
  ------------------
  |  Branch (6205:9): [True: 0, False: 0]
  ------------------
 6206|      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__
  |  |  ------------------
  ------------------
 6207|      0|					return SC_ERROR_PIN_CODE_INCORRECT;
  ------------------
  |  |   64|      0|#define SC_ERROR_PIN_CODE_INCORRECT		-1214
  ------------------
 6208|       |					/* this is what the iso_check_sw returns for 63 C0 */
 6209|      0|				}
 6210|      0|			}
 6211|     63|		}
 6212|  5.18k|	}
 6213|       |#ifdef ENABLE_PIV_SM
 6214|       |	/* Note 6982 is map to SC_ERROR_SM_NO_SESSION_KEYS but iso maps it to SC_ERROR_SECURITY_STATUS_NOT_SATISFIED */
 6215|       |	/* we do this because 6982 could also mean a verify is not allowed over contactless without VCI */
 6216|       |	/* we stashed the sw1 and sw2 above for verify */
 6217|       |	/* Check specific NIST sp800-73-4 SM  errors */
 6218|       |	for (i = 0; piv_sm_errors[i].SWs != 0; i++) {
 6219|       |		if (piv_sm_errors[i].SWs == ((sw1 << 8) | sw2)) {
 6220|       |			sc_log(card->ctx, "%s", piv_sm_errors[i].errorstr);
 6221|       |			return piv_sm_errors[i].errorno;
 6222|       |		}
 6223|       |	}
 6224|       |#endif
 6225|  5.18k|	r = iso_drv->ops->check_sw(card, sw1, sw2);
 6226|  5.18k|	return r;
 6227|  5.18k|}
card-piv.c:piv_card_ctl:
 4565|    249|{
 4566|    249|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  440|    249|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 4567|    249|	u8 *opts; /*  A or M, key_ref, alg_id */
 4568|       |
 4569|    249|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    249|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    249|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    249|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    249|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 249]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4570|       |
 4571|    249|	if (priv == NULL) {
  ------------------
  |  Branch (4571:6): [True: 0, False: 249]
  ------------------
 4572|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4573|      0|	}
 4574|    249|	switch (cmd) {
  ------------------
  |  Branch (4574:10): [True: 0, False: 249]
  ------------------
 4575|      0|	case SC_CARDCTL_PIV_AUTHENTICATE:
  ------------------
  |  Branch (4575:2): [True: 0, False: 249]
  ------------------
 4576|      0|		opts = (u8 *)ptr;
 4577|      0|		switch (*opts) {
  ------------------
  |  Branch (4577:11): [True: 0, False: 0]
  ------------------
 4578|      0|		case 'A':
  ------------------
  |  Branch (4578:3): [True: 0, False: 0]
  ------------------
 4579|      0|			return piv_general_external_authenticate(card,
 4580|      0|					*(opts + 1), *(opts + 2));
 4581|      0|			break;
 4582|      0|		case 'M':
  ------------------
  |  Branch (4582:3): [True: 0, False: 0]
  ------------------
 4583|      0|			return piv_general_mutual_authenticate(card,
 4584|      0|					*(opts + 1), *(opts + 2));
 4585|      0|			break;
 4586|      0|		}
 4587|      0|		break;
 4588|      0|	case SC_CARDCTL_PIV_GENERATE_KEY:
  ------------------
  |  Branch (4588:2): [True: 0, False: 249]
  ------------------
 4589|      0|		return piv_generate_key(card,
 4590|      0|				(sc_cardctl_piv_genkey_info_t *)ptr);
 4591|      0|		break;
 4592|      0|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (4592:2): [True: 0, False: 249]
  ------------------
 4593|      0|		return piv_get_serial_nr_from_CHUI(card, (sc_serial_number_t *)ptr);
 4594|      0|		break;
 4595|      0|	case SC_CARDCTL_PIV_PIN_PREFERENCE:
  ------------------
  |  Branch (4595:2): [True: 0, False: 249]
  ------------------
 4596|      0|		return piv_get_pin_preference(card, ptr);
 4597|      0|		break;
 4598|      0|	case SC_CARDCTL_PIV_OBJECT_PRESENT:
  ------------------
  |  Branch (4598:2): [True: 0, False: 249]
  ------------------
 4599|      0|		return piv_is_object_present(card, ptr);
 4600|      0|		break;
 4601|      0|	case SC_CARDCTL_PIV_YK_PIN_POLICY:
  ------------------
  |  Branch (4601:2): [True: 0, False: 249]
  ------------------
 4602|      0|		return piv_yk_pin_policy(card, ptr);
 4603|      0|		break;
 4604|    249|	}
 4605|       |
 4606|    249|	LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|    249|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    249|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    249|	int _ret = r; \
  |  |  |  |  155|    249|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 249, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    249|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    249|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 249, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    249|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    249|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    249|	return _ret; \
  |  |  |  |  163|    249|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4607|    249|}
card-piv.c:piv_card_reader_lock_obtained:
 6474|  4.63k|{
 6475|  4.63k|	int r = 0;
 6476|  4.63k|	u8 temp[SC_MAX_APDU_BUFFER_SIZE];
 6477|  4.63k|	size_t templen = sizeof(temp);
 6478|  4.63k|	piv_private_data_t *priv = PIV_DATA(card); /* may be null */
  ------------------
  |  |  440|  4.63k|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 6479|       |
 6480|  4.63k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  4.63k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  4.63k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  4.63k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 4.63k]
  |  |  ------------------
  ------------------
 6481|       |
 6482|       |	/* We have a PCSC transaction and sc_lock */
 6483|  4.63k|	if (priv == NULL || priv->pstate == PIV_STATE_MATCH) {
  ------------------
  |  Branch (6483:6): [True: 4.38k, False: 249]
  |  Branch (6483:22): [True: 249, False: 0]
  ------------------
 6484|  4.63k|		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|  9.26k|#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: 249, False: 4.38k]
  |  |  ------------------
  ------------------
 6485|  4.63k|				priv ? "PIV_STATE_MATCH" : "priv==NULL");
 6486|  4.63k|		r = 0; /* do nothing, piv_match will take care of it */
 6487|  4.63k|		goto err;
 6488|  4.63k|	}
 6489|       |
 6490|      0|	priv->init_flags |= PIV_INIT_IN_READER_LOCK_OBTAINED;
  ------------------
  |  |  384|      0|#define PIV_INIT_IN_READER_LOCK_OBTAINED	0x00000010u
  ------------------
 6491|       |
 6492|       |	/* make sure our application is active */
 6493|       |
 6494|       |	/* first see if AID is active AID by reading discovery object '7E' */
 6495|       |	/* If not try selecting AID */
 6496|       |
 6497|       |	/* but if card does not support DISCOVERY object we can not use it */
 6498|      0|	if (priv->card_issues & CI_DISCOVERY_USELESS) {
  ------------------
  |  |  590|      0|#define CI_DISCOVERY_USELESS		    0x00000020U /* Discovery can not be used to query active AID invalid or no data returned */
  ------------------
  |  Branch (6498:6): [True: 0, False: 0]
  ------------------
 6499|      0|		r = SC_ERROR_NO_CARD_SUPPORT;
  ------------------
  |  |   58|      0|#define SC_ERROR_NO_CARD_SUPPORT		-1208
  ------------------
 6500|      0|	} else {
 6501|      0|		r = piv_find_discovery(card);
 6502|       |#ifdef ENABLE_PIV_SM
 6503|       |		/*
 6504|       |		 * All 800-73-4 cards that support SM, also have a discovery object with
 6505|       |		 * the pin_policy, so can not have CI_DISCOVERY_USELESS
 6506|       |		 * Discovery object can be read with contact or contactless
 6507|       |		 * If read with SM and fails with 69 88  SC_ERROR_SM_INVALID_SESSION_KEY
 6508|       |		 * sm.c will close the SM connectrion, and set defer
 6509|       |		 */
 6510|       |		if (was_reset == 0 && (r == SC_ERROR_SM_INVALID_SESSION_KEY || priv->sm_flags & PIV_SM_FLAGS_DEFER_OPEN)) {
 6511|       |			sc_log(card->ctx, "SC_ERROR_SM_INVALID_SESSION_KEY || PIV_SM_FLAGS_DEFER_OPEN");
 6512|       |			piv_sm_open(card);
 6513|       |			r = piv_find_discovery(card);
 6514|       |		}
 6515|       |#endif /* ENABLE_PIV_SM */
 6516|      0|	}
 6517|       |
 6518|      0|	if (r < 0) {
  ------------------
  |  Branch (6518:6): [True: 0, False: 0]
  ------------------
 6519|      0|		if (was_reset > 0 || !(priv->card_issues & CI_PIV_AID_LOSE_STATE)) {
  ------------------
  |  |  591|      0|#define CI_PIV_AID_LOSE_STATE		    0x00000040U /* PIV AID can lose the login state run with out it*/
  ------------------
  |  Branch (6519:7): [True: 0, False: 0]
  |  Branch (6519:24): [True: 0, False: 0]
  ------------------
 6520|      0|			r = iso7816_select_aid(card, piv_aids[0].value, piv_aids[0].len_short, temp, &templen);
 6521|      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__
  |  |  ------------------
  ------------------
 6522|      0|		} else {
 6523|      0|			r = 0; /* can't do anything with this card, hope there was no interference */
 6524|      0|		}
 6525|      0|	}
 6526|       |
 6527|      0|	if (r < 0) /* bad error return will show up in sc_lock as error*/
  ------------------
  |  Branch (6527:6): [True: 0, False: 0]
  ------------------
 6528|      0|		goto err;
 6529|       |
 6530|      0|	if (was_reset > 0)
  ------------------
  |  Branch (6530:6): [True: 0, False: 0]
  ------------------
 6531|      0|		priv->logged_in = SC_PIN_STATE_UNKNOWN;
  ------------------
  |  |  430|      0|#define SC_PIN_STATE_UNKNOWN	0
  ------------------
 6532|       |
 6533|      0|	r = 0;
 6534|       |
 6535|  4.63k|err:
 6536|  4.63k|	if (priv)
  ------------------
  |  Branch (6536:6): [True: 249, False: 4.38k]
  ------------------
 6537|    249|		priv->init_flags &= ~PIV_INIT_IN_READER_LOCK_OBTAINED;
  ------------------
  |  |  384|    249|#define PIV_INIT_IN_READER_LOCK_OBTAINED	0x00000010u
  ------------------
 6538|  4.63k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  4.63k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  4.63k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  4.63k|	int _ret = r; \
  |  |  |  |  155|  4.63k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4.63k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  4.63k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 4.63k]
  |  |  |  |  ------------------
  |  |  |  |  157|  4.63k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  4.63k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|  4.63k|	return _ret; \
  |  |  |  |  163|  4.63k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6539|  4.63k|}

sc_get_rtecp_driver:
  868|  16.3k|{
  869|  16.3k|	if (iso_ops == NULL)
  ------------------
  |  Branch (869:6): [True: 1, False: 16.3k]
  ------------------
  870|      1|		iso_ops = sc_get_iso7816_driver()->ops;
  871|  16.3k|	rtecp_ops = *iso_ops;
  872|       |
  873|  16.3k|	rtecp_ops.match_card = rtecp_match_card;
  874|  16.3k|	rtecp_ops.init = rtecp_init;
  875|       |	/* read_binary */
  876|  16.3k|	rtecp_ops.write_binary = NULL;
  877|       |	/* update_binary */
  878|  16.3k|	rtecp_ops.read_record = NULL;
  879|  16.3k|	rtecp_ops.write_record = NULL;
  880|  16.3k|	rtecp_ops.append_record = NULL;
  881|  16.3k|	rtecp_ops.update_record = NULL;
  882|  16.3k|	rtecp_ops.select_file = rtecp_select_file;
  883|       |	/* get_response */
  884|       |	/* get_challenge */
  885|  16.3k|	rtecp_ops.verify = rtecp_verify;
  886|  16.3k|	rtecp_ops.logout = rtecp_logout;
  887|       |	/* restore_security_env */
  888|  16.3k|	rtecp_ops.set_security_env = rtecp_set_security_env;
  889|  16.3k|	rtecp_ops.decipher = rtecp_decipher;
  890|  16.3k|	rtecp_ops.compute_signature = rtecp_compute_signature;
  891|  16.3k|	rtecp_ops.change_reference_data = rtecp_change_reference_data;
  892|  16.3k|	rtecp_ops.reset_retry_counter = rtecp_reset_retry_counter;
  893|  16.3k|	rtecp_ops.create_file = rtecp_create_file;
  894|       |	/* delete_file */
  895|  16.3k|	rtecp_ops.list_files = rtecp_list_files;
  896|       |	/* check_sw */
  897|  16.3k|	rtecp_ops.card_ctl = rtecp_card_ctl;
  898|       |	/* process_fci */
  899|  16.3k|	rtecp_ops.construct_fci = rtecp_construct_fci;
  900|       |	rtecp_ops.pin_cmd = NULL;
  901|  16.3k|	return &rtecp_drv;
  902|  16.3k|}
card-rtecp.c:rtecp_match_card:
   73|  10.8k|{
   74|  10.8k|	int i = -1;
   75|  10.8k|	i = _sc_match_atr(card, rtecp_atrs, &card->type);
   76|  10.8k|	if (i >= 0) {
  ------------------
  |  Branch (76:6): [True: 149, False: 10.6k]
  ------------------
   77|    149|		card->name = rtecp_atrs[i].name;
   78|    149|		LOG_FUNC_RETURN(card->ctx, 1);
  ------------------
  |  |  164|    149|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    149|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    149|	int _ret = r; \
  |  |  |  |  155|    149|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 149]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    149|	} else { \
  |  |  |  |  159|    149|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    149|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    149|	} \
  |  |  |  |  162|    149|	return _ret; \
  |  |  |  |  163|    149|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   79|    149|	}
   80|  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   81|  10.6k|}
card-rtecp.c:rtecp_init:
   84|    149|{
   85|    149|	sc_algorithm_info_t info;
   86|    149|	unsigned long flags;
   87|       |
   88|    149|	if (!card || !card->ctx)
  ------------------
  |  Branch (88:6): [True: 0, False: 149]
  |  Branch (88:15): [True: 0, False: 149]
  ------------------
   89|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   90|       |
   91|    149|	card->cla = 0;
   92|       |
   93|    149|	if (card->type == SC_CARD_TYPE_RUTOKEN_LITE
  ------------------
  |  Branch (93:6): [True: 0, False: 149]
  ------------------
   94|    149|			|| card->type == SC_CARD_TYPE_RUTOKEN_LITE_SC)
  ------------------
  |  Branch (94:7): [True: 3, False: 146]
  ------------------
   95|      3|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
   96|       |
   97|    146|	card->caps |= SC_CARD_CAP_RNG;
  ------------------
  |  |  550|    146|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
   98|       |
   99|    146|	flags = SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN
  ------------------
  |  |  102|    146|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
              	flags = SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN
  ------------------
  |  |   93|    146|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  100|    146|		| SC_ALGORITHM_RSA_PAD_NONE | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  104|    146|#define SC_ALGORITHM_RSA_PAD_NONE	0x00000001
  ------------------
              		| SC_ALGORITHM_RSA_PAD_NONE | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  133|    146|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  101|       |
  102|    146|	_sc_card_add_rsa_alg(card, 256, flags, 0);
  103|    146|	_sc_card_add_rsa_alg(card, 512, flags, 0);
  104|    146|	_sc_card_add_rsa_alg(card, 768, flags, 0);
  105|    146|	_sc_card_add_rsa_alg(card, 1024, flags, 0);
  106|    146|	_sc_card_add_rsa_alg(card, 1280, flags, 0);
  107|    146|	_sc_card_add_rsa_alg(card, 1536, flags, 0);
  108|    146|	_sc_card_add_rsa_alg(card, 1792, flags, 0);
  109|    146|	_sc_card_add_rsa_alg(card, 2048, flags, 0);
  110|    146|	_sc_card_add_rsa_alg(card, 4096, flags, 0);
  111|       |
  112|    146|	memset(&info, 0, sizeof(info));
  113|    146|	info.algorithm = SC_ALGORITHM_GOSTR3410;
  ------------------
  |  |   71|    146|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  114|    146|	info.key_length = 256;
  115|    146|	info.flags = SC_ALGORITHM_GOSTR3410_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN
  ------------------
  |  |  156|    146|#define SC_ALGORITHM_GOSTR3410_RAW		0x00020000
  ------------------
              	info.flags = SC_ALGORITHM_GOSTR3410_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN
  ------------------
  |  |   93|    146|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  116|    146|		| SC_ALGORITHM_GOSTR3410_HASH_NONE;
  ------------------
  |  |  157|    146|#define SC_ALGORITHM_GOSTR3410_HASH_NONE	SC_ALGORITHM_GOSTR3410_RAW /*XXX*/
  |  |  ------------------
  |  |  |  |  156|    146|#define SC_ALGORITHM_GOSTR3410_RAW		0x00020000
  |  |  ------------------
  ------------------
  117|    146|	_sc_card_add_algorithm(card, &info);
  118|       |
  119|    146|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  120|    146|}
card-rtecp.c:rtecp_select_file:
  285|    729|{
  286|    729|	sc_file_t *file = NULL;
  287|    729|	int r = SC_SUCCESS;
  ------------------
  |  |   28|    729|#define SC_SUCCESS				0
  ------------------
  288|       |
  289|    729|	if (!card || !card->ctx || !in_path)
  ------------------
  |  Branch (289:6): [True: 0, False: 729]
  |  Branch (289:15): [True: 0, False: 729]
  |  Branch (289:29): [True: 0, False: 729]
  ------------------
  290|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  291|       |
  292|    729|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    729|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    729|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    729|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 729]
  |  |  ------------------
  ------------------
  293|       |
  294|    729|	switch (in_path->type)
  ------------------
  |  Branch (294:10): [True: 221, False: 508]
  ------------------
  295|    729|	{
  296|    221|	case SC_PATH_TYPE_DF_NAME:
  ------------------
  |  |  118|    221|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (296:2): [True: 221, False: 508]
  ------------------
  297|    221|	case SC_PATH_TYPE_FROM_CURRENT:
  ------------------
  |  |  122|    221|#define SC_PATH_TYPE_FROM_CURRENT	4
  ------------------
  |  Branch (297:2): [True: 0, False: 729]
  ------------------
  298|    221|	case SC_PATH_TYPE_PARENT:
  ------------------
  |  |  123|    221|#define SC_PATH_TYPE_PARENT		5
  ------------------
  |  Branch (298:2): [True: 0, False: 729]
  ------------------
  299|    221|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  153|    221|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    221|	int _ret = r; \
  |  |  155|    221|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 221, False: 0]
  |  |  ------------------
  |  |  156|    221|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|    221|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 221, False: 0]
  |  |  ------------------
  |  |  157|    221|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    221|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|    221|	return _ret; \
  |  |  163|    221|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  300|    729|	}
  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|    508|	r = iso_ops->select_file(card, in_path, &file);
  305|    508|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|    508|#define SC_SUCCESS				0
  ------------------
  |  Branch (305:6): [True: 449, False: 59]
  ------------------
  306|    449|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|    449|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    449|	int _ret = r; \
  |  |  155|    449|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 449, False: 0]
  |  |  ------------------
  |  |  156|    449|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|    449|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 449, False: 0]
  |  |  ------------------
  |  |  157|    449|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    449|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|    449|	return _ret; \
  |  |  163|    449|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  307|       |
  308|     59|	if (file->sec_attr && file->sec_attr_len == SC_RTECP_SEC_ATTR_SIZE)
  ------------------
  |  |  780|     47|#define SC_RTECP_SEC_ATTR_SIZE 15
  ------------------
  |  Branch (308:6): [True: 47, False: 12]
  |  Branch (308:24): [True: 37, False: 10]
  ------------------
  309|     37|		set_acl_from_sec_attr(card, file);
  310|     22|	else
  311|     22|	{
  312|     22|		sc_file_free(file);
  313|     22|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  314|     22|	}
  315|       |
  316|     37|	if (file_out)
  ------------------
  |  Branch (316:6): [True: 36, False: 1]
  ------------------
  317|     36|		*file_out = file;
  318|      1|	else
  319|      1|		sc_file_free(file);
  320|       |
  321|     37|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, 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]
  |  |  ------------------
  ------------------
  322|     37|}
card-rtecp.c:set_acl_from_sec_attr:
  167|     37|{
  168|     37|	unsigned int method;
  169|     37|	unsigned long key_ref;
  170|       |
  171|     37|	if (!card || !card->ctx || !file || !file->sec_attr
  ------------------
  |  Branch (171:6): [True: 0, False: 37]
  |  Branch (171:15): [True: 0, False: 37]
  |  Branch (171:29): [True: 0, False: 37]
  |  Branch (171:38): [True: 0, False: 37]
  ------------------
  172|     37|		|| file->sec_attr_len != SC_RTECP_SEC_ATTR_SIZE
  ------------------
  |  |  780|     74|#define SC_RTECP_SEC_ATTR_SIZE 15
  ------------------
  |  Branch (172:6): [True: 0, False: 37]
  ------------------
  173|      0|		|| 1 + 6 >= SC_RTECP_SEC_ATTR_SIZE)
  ------------------
  |  |  780|      0|#define SC_RTECP_SEC_ATTR_SIZE 15
  ------------------
  |  Branch (173:6): [Folded, False: 0]
  ------------------
  174|      0|	{
  175|      0|		return;
  176|      0|	}
  177|       |
  178|     37|	sc_file_add_acl_entry(file, SC_AC_OP_SELECT, SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  166|     37|#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|     37|#define SC_AC_NONE			0x00000000
  ------------------
              	sc_file_add_acl_entry(file, SC_AC_OP_SELECT, SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|     37|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  179|     37|	if (file->sec_attr[0] & 0x40) /* if AccessMode.6 */
  ------------------
  |  Branch (179:6): [True: 29, False: 8]
  ------------------
  180|     29|	{
  181|     29|		method = sec_attr_to_method(file->sec_attr[1 + 6]);
  182|     29|		key_ref = sec_attr_to_key_ref(file->sec_attr[1 + 6]);
  183|     29|		sc_log(card->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__
  |  |  ------------------
  ------------------
  184|     29|			"SC_AC_OP_DELETE %i %lu\n",
  185|     29|			(int)method, key_ref);
  186|     29|		sc_file_add_acl_entry(file, SC_AC_OP_DELETE, method, key_ref);
  ------------------
  |  |  168|     29|#define SC_AC_OP_DELETE			2
  ------------------
  187|     29|	}
  188|     37|	if (file->sec_attr[0] & 0x01) /* if AccessMode.0 */
  ------------------
  |  Branch (188:6): [True: 31, False: 6]
  ------------------
  189|     31|	{
  190|     31|		method = sec_attr_to_method(file->sec_attr[1 + 0]);
  191|     31|		key_ref = sec_attr_to_key_ref(file->sec_attr[1 + 0]);
  192|     31|		sc_log(card->ctx,
  ------------------
  |  |   71|     62|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  |  Branch (71:110): [True: 1, False: 30]
  |  |  ------------------
  ------------------
  193|     31|			(file->type == SC_FILE_TYPE_DF) ?
  194|     31|				"SC_AC_OP_CREATE %i %lu\n"
  195|     31|				: "SC_AC_OP_READ %i %lu\n",
  196|     31|			(int)method, key_ref);
  197|     31|		sc_file_add_acl_entry(file, (file->type == SC_FILE_TYPE_DF) ?
  ------------------
  |  |  214|     31|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (197:31): [True: 1, False: 30]
  ------------------
  198|     30|				SC_AC_OP_CREATE : SC_AC_OP_READ, method, key_ref);
  ------------------
  |  |  169|      1|#define SC_AC_OP_CREATE			3
  ------------------
              				SC_AC_OP_CREATE : SC_AC_OP_READ, method, key_ref);
  ------------------
  |  |  188|     61|#define SC_AC_OP_READ			22
  ------------------
  199|     31|	}
  200|     37|	if (file->type == SC_FILE_TYPE_DF)
  ------------------
  |  |  214|     37|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (200:6): [True: 1, False: 36]
  ------------------
  201|      1|	{
  202|      1|		sc_file_add_acl_entry(file, SC_AC_OP_LIST_FILES,
  ------------------
  |  |  172|      1|#define SC_AC_OP_LIST_FILES		6
  ------------------
  203|      1|				SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  150|      1|#define SC_AC_NONE			0x00000000
  ------------------
              				SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|      1|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  204|      1|	}
  205|     36|	else
  206|     36|		if (file->sec_attr[0] & 0x02) /* if AccessMode.1 */
  ------------------
  |  Branch (206:7): [True: 31, False: 5]
  ------------------
  207|     31|		{
  208|     31|			method = sec_attr_to_method(file->sec_attr[1 + 1]);
  209|     31|			key_ref = sec_attr_to_key_ref(file->sec_attr[1 + 1]);
  210|     31|			sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  211|     31|				"SC_AC_OP_UPDATE %i %lu\n",
  212|     31|				(int)method, key_ref);
  213|     31|			sc_file_add_acl_entry(file, SC_AC_OP_UPDATE, method, key_ref);
  ------------------
  |  |  189|     31|#define SC_AC_OP_UPDATE			23
  ------------------
  214|     31|			sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  215|     31|				"SC_AC_OP_WRITE %i %lu\n",
  216|     31|				(int)method, key_ref);
  217|     31|			sc_file_add_acl_entry(file, SC_AC_OP_WRITE, method, key_ref);
  ------------------
  |  |  190|     31|#define SC_AC_OP_WRITE			24
  ------------------
  218|     31|		}
  219|     37|}
card-rtecp.c:sec_attr_to_method:
  139|     91|{
  140|     91|	if (attr == 0xFF)
  ------------------
  |  Branch (140:6): [True: 8, False: 83]
  ------------------
  141|      8|		return SC_AC_NEVER;
  ------------------
  |  |  163|      8|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  142|     83|	else if (attr == 0)
  ------------------
  |  Branch (142:11): [True: 8, False: 75]
  ------------------
  143|      8|		return SC_AC_NONE;
  ------------------
  |  |  150|      8|#define SC_AC_NONE			0x00000000
  ------------------
  144|     75|	else if (attr & 0x03)
  ------------------
  |  Branch (144:11): [True: 57, False: 18]
  ------------------
  145|     57|		return SC_AC_CHV;
  ------------------
  |  |  151|     57|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  146|     18|	else
  147|     18|		return SC_AC_UNKNOWN;
  ------------------
  |  |  162|     18|#define SC_AC_UNKNOWN			0xFFFFFFFE
  ------------------
  148|     91|}
card-rtecp.c:sec_attr_to_key_ref:
  151|     91|{
  152|     91|	if (attr == 1 || attr == 2)
  ------------------
  |  Branch (152:6): [True: 8, False: 83]
  |  Branch (152:19): [True: 7, False: 76]
  ------------------
  153|     15|		return attr;
  154|     76|	return 0;
  155|     91|}
card-rtecp.c:rtecp_create_file:
  621|     65|{
  622|     65|	int r;
  623|       |
  624|     65|	if (!card || !card->ctx || !file)
  ------------------
  |  Branch (624:6): [True: 0, False: 65]
  |  Branch (624:15): [True: 0, False: 65]
  |  Branch (624:29): [True: 0, False: 65]
  ------------------
  625|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  626|       |
  627|     65|	if (file->sec_attr_len == 0)
  ------------------
  |  Branch (627:6): [True: 65, False: 0]
  ------------------
  628|     65|	{
  629|     65|		r = set_sec_attr_from_acl(card, file);
  630|     65|		LOG_TEST_RET(card->ctx, r, "Set sec_attr from ACL 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  631|     65|	}
  632|       |
  633|     65|	r = iso_ops->create_file(card, file);
  634|     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|     60|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 60, False: 5]
  |  |  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  635|     65|}
card-rtecp.c:set_sec_attr_from_acl:
  222|     65|{
  223|     65|	const sc_acl_entry_t *entry;
  224|     65|	u8 sec_attr[SC_RTECP_SEC_ATTR_SIZE] = { 0 };
  225|     65|	int r;
  226|       |
  227|     65|	if (!card || !card->ctx || !file
  ------------------
  |  Branch (227:6): [True: 0, False: 65]
  |  Branch (227:15): [True: 0, False: 65]
  |  Branch (227:29): [True: 0, False: 65]
  ------------------
  228|     65|		|| file->sec_attr || file->sec_attr_len != 0)
  ------------------
  |  Branch (228:6): [True: 0, False: 65]
  |  Branch (228:24): [True: 0, False: 65]
  ------------------
  229|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  230|       |
  231|     65|	entry = sc_file_get_acl_entry(file, SC_AC_OP_DELETE);
  ------------------
  |  |  168|     65|#define SC_AC_OP_DELETE			2
  ------------------
  232|     65|	if (entry)
  ------------------
  |  Branch (232:6): [True: 65, False: 0]
  ------------------
  233|     65|	{
  234|     65|		sec_attr[0] |= 0x40;
  235|     65|		sec_attr[1 + 6] = to_sec_attr(entry->method, entry->key_ref);
  236|     65|	}
  237|     65|	if (file->type == SC_FILE_TYPE_DF)
  ------------------
  |  |  214|     65|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (237:6): [True: 43, False: 22]
  ------------------
  238|     43|	{
  239|     43|		entry = sc_file_get_acl_entry(file, SC_AC_OP_CREATE);
  ------------------
  |  |  169|     43|#define SC_AC_OP_CREATE			3
  ------------------
  240|     43|		if (entry)
  ------------------
  |  Branch (240:7): [True: 43, False: 0]
  ------------------
  241|     43|		{
  242|       |			/* ATTR: Create DF/EF file */
  243|     43|			sec_attr[0] |= 0x01;
  244|     43|			sec_attr[1 + 0] = to_sec_attr(entry->method, entry->key_ref);
  245|       |			/* ATTR: Create Internal EF (RSF) file */
  246|     43|			sec_attr[0] |= 0x02;
  247|     43|			sec_attr[1 + 1] = to_sec_attr(entry->method, entry->key_ref);
  248|     43|		}
  249|     43|	}
  250|     22|	else
  251|     22|	{
  252|     22|		entry = sc_file_get_acl_entry(file, SC_AC_OP_READ);
  ------------------
  |  |  188|     22|#define SC_AC_OP_READ			22
  ------------------
  253|     22|		if (entry)
  ------------------
  |  Branch (253:7): [True: 22, False: 0]
  ------------------
  254|     22|		{
  255|     22|			sec_attr[0] |= 0x01;
  256|     22|			sec_attr[1 + 0] = to_sec_attr(entry->method, entry->key_ref);
  257|     22|		}
  258|     22|		entry = sc_file_get_acl_entry(file, SC_AC_OP_WRITE);
  ------------------
  |  |  190|     22|#define SC_AC_OP_WRITE			24
  ------------------
  259|     22|		if (entry)
  ------------------
  |  Branch (259:7): [True: 22, False: 0]
  ------------------
  260|     22|		{
  261|     22|			sec_attr[0] |= 0x02;
  262|     22|			sec_attr[1 + 1] = to_sec_attr(entry->method, entry->key_ref);
  263|     22|		}
  264|     22|		entry = sc_file_get_acl_entry(file, SC_AC_OP_UPDATE);
  ------------------
  |  |  189|     22|#define SC_AC_OP_UPDATE			23
  ------------------
  265|     22|		if (entry)
  ------------------
  |  Branch (265:7): [True: 22, False: 0]
  ------------------
  266|     22|		{
  267|       |			/* rewrite if sec_attr[1 + 1] already set */
  268|     22|			sec_attr[0] |= 0x02;
  269|     22|			sec_attr[1 + 1] = to_sec_attr(entry->method, entry->key_ref);
  270|     22|		}
  271|     22|	}
  272|       |	/* FIXME: Find the best solution */
  273|     65|	if (file->path.len == 2 && !memcmp(file->path.value, "\x3F\x00", 2))
  ------------------
  |  Branch (273:6): [True: 19, False: 46]
  |  Branch (273:29): [True: 1, False: 18]
  ------------------
  274|      1|	{
  275|       |		/* ATTR: Put data */
  276|      1|		sec_attr[0] |= 0x04;
  277|      1|		sec_attr[1 + 2] = 1; /* so-pin reference */
  278|      1|	}
  279|     65|	r = sc_file_set_sec_attr(file, sec_attr, sizeof(sec_attr));
  280|     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]
  |  |  ------------------
  ------------------
  281|     65|}
card-rtecp.c:to_sec_attr:
  158|    217|{
  159|    217|	if (method == SC_AC_NEVER || method == SC_AC_NONE)
  ------------------
  |  |  163|    434|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
              	if (method == SC_AC_NEVER || method == SC_AC_NONE)
  ------------------
  |  |  150|    207|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (159:6): [True: 10, False: 207]
  |  Branch (159:31): [True: 116, False: 91]
  ------------------
  160|    126|		return method;
  161|     91|	if (method == SC_AC_CHV  &&  (key_ref == 1 || key_ref == 2))
  ------------------
  |  |  151|    182|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (161:6): [True: 10, False: 81]
  |  Branch (161:32): [True: 0, False: 10]
  |  Branch (161:48): [True: 0, False: 10]
  ------------------
  162|      0|		return key_ref;
  163|     91|	return 0;
  164|     91|}
card-rtecp.c:rtecp_card_ctl:
  704|    167|{
  705|    167|	sc_apdu_t apdu;
  706|    167|	u8 buf[512];
  707|    167|	sc_rtecp_genkey_data_t *genkey_data = data;
  708|    167|	sc_serial_number_t *serial = data;
  709|    167|	int r;
  710|       |
  711|    167|	const unsigned char rsa_prop[] = {0xA6, 0x06, 0x94, 0x04, 0x01, 0x00, 0x01, 0x00};
  712|       |
  713|    167|	if (!card || !card->ctx)
  ------------------
  |  Branch (713:6): [True: 0, False: 167]
  |  Branch (713:15): [True: 0, False: 167]
  ------------------
  714|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  715|       |
  716|    167|	switch (request)
  717|    167|	{
  718|      9|	case SC_CARDCTL_RTECP_INIT:
  ------------------
  |  Branch (718:2): [True: 9, False: 158]
  ------------------
  719|      9|		sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x8A, 0, 0);
  ------------------
  |  |  291|      9|#define SC_APDU_CASE_1			0x01
  ------------------
  720|      9|		apdu.cla = 0x80;
  721|      9|		break;
  722|      9|	case SC_CARDCTL_RTECP_INIT_END:
  ------------------
  |  Branch (722:2): [True: 9, False: 158]
  ------------------
  723|      9|		sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x84, 0x4E, 0x19);
  ------------------
  |  |  291|      9|#define SC_APDU_CASE_1			0x01
  ------------------
  724|      9|		apdu.cla = 0x80;
  725|      9|		break;
  726|      0|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (726:2): [True: 0, False: 167]
  ------------------
  727|      0|		if (!serial)
  ------------------
  |  Branch (727:7): [True: 0, False: 0]
  ------------------
  728|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  729|      0|		sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xCA, 0x01, 0x81);
  ------------------
  |  |  292|      0|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  730|      0|		apdu.resp = buf;
  731|      0|		apdu.resplen = sizeof(buf);
  732|      0|		apdu.le = 256;
  733|      0|		serial->len = sizeof(serial->value);
  734|      0|		break;
  735|      0|	case SC_CARDCTL_RTECP_GENERATE_KEY:
  ------------------
  |  Branch (735:2): [True: 0, False: 167]
  ------------------
  736|      0|		if (!genkey_data)
  ------------------
  |  Branch (736:7): [True: 0, False: 0]
  ------------------
  737|      0|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  738|      0|		sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0x46, 0x80,
  ------------------
  |  |  292|      0|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  739|      0|				genkey_data->key_id);
  740|      0|		apdu.resp = buf;
  741|      0|		apdu.resplen = sizeof(buf);
  742|      0|		apdu.le = 256;
  743|      0|		if (genkey_data->type == SC_ALGORITHM_RSA) {
  ------------------
  |  |   69|      0|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (743:7): [True: 0, False: 0]
  ------------------
  744|      0|			apdu.cse = SC_APDU_CASE_4_SHORT;
  ------------------
  |  |  294|      0|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  745|      0|			apdu.data = rsa_prop;
  746|      0|			apdu.datalen = sizeof(rsa_prop);
  747|      0|			apdu.lc = sizeof(rsa_prop);
  748|      0|		}
  749|      0|		break;
  750|    149|	case SC_CARDCTL_LIFECYCLE_SET:
  ------------------
  |  Branch (750:2): [True: 149, False: 18]
  ------------------
  751|    149|		sc_log(card->ctx,  "%s\n",
  ------------------
  |  |   71|    149|#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|    149|				"SC_CARDCTL_LIFECYCLE_SET not supported");
  753|       |		/* no call sc_debug (SC_FUNC_RETURN) */
  754|    149|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    149|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  755|      0|	default:
  ------------------
  |  Branch (755:2): [True: 0, False: 167]
  ------------------
  756|      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__
  |  |  ------------------
  ------------------
  757|      0|			"request = 0x%lx\n", request);
  758|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  759|    167|	}
  760|     18|	r = sc_transmit_apdu(card, &apdu);
  761|     18|	LOG_TEST_RET(card->ctx, r, "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: 3, False: 15]
  |  |  |  |  ------------------
  |  |  |  |  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|     18|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 15]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  762|     15|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  763|     15|	if (!r && request == SC_CARDCTL_RTECP_GENERATE_KEY)
  ------------------
  |  Branch (763:6): [True: 3, False: 12]
  |  Branch (763:12): [True: 0, False: 3]
  ------------------
  764|      0|	{
  765|      0|		if (genkey_data->type == SC_ALGORITHM_RSA &&
  ------------------
  |  |   69|      0|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (765:7): [True: 0, False: 0]
  ------------------
  766|      0|				genkey_data->u.rsa.modulus_len >= apdu.resplen &&
  ------------------
  |  Branch (766:5): [True: 0, False: 0]
  ------------------
  767|      0|				genkey_data->u.rsa.exponent_len >= 3)
  ------------------
  |  Branch (767:5): [True: 0, False: 0]
  ------------------
  768|      0|		{
  769|      0|			memcpy(genkey_data->u.rsa.modulus, apdu.resp, apdu.resplen);
  770|      0|			genkey_data->u.rsa.modulus_len = apdu.resplen;
  771|      0|			reverse(genkey_data->u.rsa.modulus,
  772|      0|					genkey_data->u.rsa.modulus_len);
  773|      0|			memcpy(genkey_data->u.rsa.exponent, "\x01\x00\x01", 3);
  774|      0|			genkey_data->u.rsa.exponent_len = 3;
  775|      0|		}
  776|      0|		else if (genkey_data->type == SC_ALGORITHM_GOSTR3410 &&
  ------------------
  |  |   71|      0|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (776:12): [True: 0, False: 0]
  ------------------
  777|      0|				genkey_data->u.gostr3410.xy_len >= apdu.resplen)
  ------------------
  |  Branch (777:5): [True: 0, False: 0]
  ------------------
  778|      0|		{
  779|      0|			memcpy(genkey_data->u.gostr3410.xy, apdu.resp, apdu.resplen);
  780|      0|			genkey_data->u.gostr3410.xy_len = apdu.resplen;
  781|      0|		}
  782|      0|		else
  783|      0|			r = SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  784|      0|	}
  785|     15|	else if (!r && request == SC_CARDCTL_GET_SERIALNR)
  ------------------
  |  Branch (785:11): [True: 3, False: 12]
  |  Branch (785:17): [True: 0, False: 3]
  ------------------
  786|      0|	{
  787|      0|		if (apdu.resplen <= sizeof(serial->value))
  ------------------
  |  Branch (787:7): [True: 0, False: 0]
  ------------------
  788|      0|		{
  789|      0|			memcpy(serial->value, apdu.resp, apdu.resplen);
  790|      0|			serial->len = apdu.resplen;
  791|      0|		}
  792|      0|		else
  793|      0|			r = SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  794|      0|	}
  795|     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|     12|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 12, False: 3]
  |  |  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  796|     15|}
card-rtecp.c:rtecp_construct_fci:
  800|     65|{
  801|     65|	u8 buf[64], *p = out;
  802|       |
  803|     65|	if (!card || !card->ctx || !file || !out || !outlen
  ------------------
  |  Branch (803:6): [True: 0, False: 65]
  |  Branch (803:15): [True: 0, False: 65]
  |  Branch (803:29): [True: 0, False: 65]
  |  Branch (803:38): [True: 0, False: 65]
  |  Branch (803:46): [True: 0, False: 65]
  ------------------
  804|     65|		|| (*outlen < (size_t)(p - out) + 2))
  ------------------
  |  Branch (804:6): [True: 0, False: 65]
  ------------------
  805|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  806|       |
  807|     65|	*p++ = 0x6F; /* FCI template */
  808|     65|	p++; /* for length */
  809|       |
  810|       |	/* 0x80 - Number of data bytes in the file, excluding structural information */
  811|     65|	buf[0] = (file->size >> 8) & 0xFF;
  812|     65|	buf[1] = file->size & 0xFF;
  813|     65|	sc_asn1_put_tag(0x80, buf, 2, p, *outlen - (p - out), &p);
  814|       |
  815|       |	/* 0x82 - File descriptor byte */
  816|     65|	if (file->type_attr_len)
  ------------------
  |  Branch (816:6): [True: 0, False: 65]
  ------------------
  817|      0|	{
  818|      0|		if (sizeof(buf) < file->type_attr_len)
  ------------------
  |  Branch (818:7): [True: 0, False: 0]
  ------------------
  819|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  820|      0|		memcpy(buf, file->type_attr, file->type_attr_len);
  821|      0|		sc_asn1_put_tag(0x82, buf, file->type_attr_len,
  822|      0|				p, *outlen - (p - out), &p);
  823|      0|	}
  824|     65|	else
  825|     65|	{
  826|     65|		switch (file->type)
  827|     65|		{
  828|     19|		case SC_FILE_TYPE_WORKING_EF:
  ------------------
  |  |  216|     19|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (828:3): [True: 19, False: 46]
  ------------------
  829|     19|			buf[0] = 0x01;
  830|     19|			break;
  831|     43|		case SC_FILE_TYPE_DF:
  ------------------
  |  |  214|     43|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (831:3): [True: 43, False: 22]
  ------------------
  832|     43|			buf[0] = 0x38;
  833|     43|			break;
  834|      1|		case SC_FILE_TYPE_INTERNAL_EF:
  ------------------
  |  |  215|      1|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (834:3): [True: 1, False: 64]
  ------------------
  835|      3|		default:
  ------------------
  |  Branch (835:3): [True: 2, False: 63]
  ------------------
  836|      3|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|      3|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      3|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      3|	int _ret = r; \
  |  |  |  |  155|      3|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      3|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      3|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      3|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      3|	return _ret; \
  |  |  |  |  163|      3|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  837|     65|		}
  838|     62|		buf[1] = 0;
  839|     62|		sc_asn1_put_tag(0x82, buf, 2, p, *outlen - (p - out), &p);
  840|     62|	}
  841|       |	/* 0x83 - File identifier */
  842|     62|	buf[0] = (file->id >> 8) & 0xFF;
  843|     62|	buf[1] = file->id & 0xFF;
  844|     62|	sc_asn1_put_tag(0x83, buf, 2, p, *outlen - (p - out), &p);
  845|       |
  846|     62|	if (file->prop_attr_len)
  ------------------
  |  Branch (846:6): [True: 3, False: 59]
  ------------------
  847|      3|	{
  848|      3|		if (sizeof(buf) < file->prop_attr_len)
  ------------------
  |  Branch (848:7): [True: 2, False: 1]
  ------------------
  849|      3|			LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  850|      1|		memcpy(buf, file->prop_attr, file->prop_attr_len);
  851|      1|		sc_asn1_put_tag(0x85, buf, file->prop_attr_len,
  852|      1|				p, *outlen - (p - out), &p);
  853|      1|	}
  854|     60|	if (file->sec_attr_len)
  ------------------
  |  Branch (854:6): [True: 60, False: 0]
  ------------------
  855|     60|	{
  856|     60|		if (sizeof(buf) < file->sec_attr_len)
  ------------------
  |  Branch (856:7): [True: 0, False: 60]
  ------------------
  857|     60|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  858|     60|		memcpy(buf, file->sec_attr, file->sec_attr_len);
  859|     60|		sc_asn1_put_tag(0x86, buf, file->sec_attr_len,
  860|     60|				p, *outlen - (p - out), &p);
  861|     60|	}
  862|     60|	out[1] = p - out - 2; /* length */
  863|     60|	*outlen = p - out;
  864|     60|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, 0);
  ------------------
  |  |  153|     60|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|     60|	int _ret = r; \
  |  |  155|     60|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 60, False: 0]
  |  |  ------------------
  |  |  156|     60|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 60]
  |  |  ------------------
  |  |  157|     60|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|     60|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|     60|	return _ret; \
  |  |  163|     60|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  865|     60|}

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

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

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

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

sc_get_srbeid_driver:
  305|  16.3k|{
  306|       |	/* Save ISO ops for delegation, then override what we handle. */
  307|  16.3k|	iso_ops = sc_get_iso7816_driver()->ops;
  308|  16.3k|	srbeid_ops = *iso_ops;
  309|  16.3k|	srbeid_ops.match_card = srbeid_match_card;
  310|  16.3k|	srbeid_ops.init = srbeid_init;
  311|  16.3k|	srbeid_ops.select_file = srbeid_select_file;
  312|  16.3k|	srbeid_ops.set_security_env = srbeid_set_security_env;
  313|  16.3k|	srbeid_ops.compute_signature = srbeid_compute_signature;
  314|  16.3k|	srbeid_ops.decipher = srbeid_decipher;
  315|       |
  316|  16.3k|	return &srbeid_drv;
  317|  16.3k|}
card-srbeid.c:srbeid_match_card:
   72|  9.15k|{
   73|  9.15k|	int i = _sc_match_atr(card, srbeid_atrs, &card->type);
   74|  9.15k|	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 (74:6): [True: 0, False: 9.15k]
  |  Branch (74:16): [True: 0, False: 0]
  ------------------
   75|      0|		card->name = srbeid_atrs[i].name;
   76|      0|		return 1;
   77|      0|	}
   78|  9.15k|	return 0;
   79|  9.15k|}

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

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

sc_check_sw:
   45|   512k|{
   46|   512k|	if (card == NULL)
  ------------------
  |  Branch (46:6): [True: 0, False: 512k]
  ------------------
   47|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   48|   512k|	if (card->ops->check_sw == NULL)
  ------------------
  |  Branch (48:6): [True: 0, False: 512k]
  ------------------
   49|      0|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
   50|   512k|	return card->ops->check_sw(card, sw1, sw2);
   51|   512k|}
sc_format_apdu:
   55|   700k|{
   56|   700k|	if (card == NULL || apdu == NULL) {
  ------------------
  |  Branch (56:6): [True: 0, False: 700k]
  |  Branch (56:22): [True: 0, False: 700k]
  ------------------
   57|      0|		return;
   58|      0|	}
   59|   700k|	memset(apdu, 0, sizeof(*apdu));
   60|   700k|	apdu->cla = (u8) card->cla;
   61|   700k|	apdu->cse = cse;
   62|   700k|	apdu->ins = (u8) ins;
   63|   700k|	apdu->p1 = (u8) p1;
   64|   700k|	apdu->p2 = (u8) p2;
   65|   700k|}
sc_format_apdu_cse_lc_le:
   68|  2.68k|{
   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|  2.68k|	if (!apdu)
  ------------------
  |  Branch (73:6): [True: 0, False: 2.68k]
  ------------------
   74|      0|		return;
   75|  2.68k|	if (apdu->datalen > SC_MAX_APDU_DATA_SIZE
  ------------------
  |  |   35|  5.36k|#define SC_MAX_APDU_DATA_SIZE		0xFF
  ------------------
  |  Branch (75:6): [True: 0, False: 2.68k]
  ------------------
   76|  2.68k|			|| apdu->resplen > SC_MAX_APDU_RESP_SIZE) {
  ------------------
  |  |   36|  2.68k|#define SC_MAX_APDU_RESP_SIZE		(0xFF+1)
  ------------------
  |  Branch (76:7): [True: 0, False: 2.68k]
  ------------------
   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|  2.68k|	} else {
   89|       |		/* short length */
   90|  2.68k|		if (apdu->datalen <= SC_MAX_APDU_DATA_SIZE)
  ------------------
  |  |   35|  2.68k|#define SC_MAX_APDU_DATA_SIZE		0xFF
  ------------------
  |  Branch (90:7): [True: 2.68k, False: 0]
  ------------------
   91|  2.68k|			apdu->lc = apdu->datalen;
   92|  2.68k|		if (apdu->resplen <= SC_MAX_APDU_RESP_SIZE)
  ------------------
  |  |   36|  2.68k|#define SC_MAX_APDU_RESP_SIZE		(0xFF+1)
  ------------------
  |  Branch (92:7): [True: 2.68k, False: 0]
  ------------------
   93|  2.68k|			apdu->le = apdu->resplen;
   94|  2.68k|		if (!apdu->resplen && !apdu->datalen)
  ------------------
  |  Branch (94:7): [True: 2.45k, False: 232]
  |  Branch (94:25): [True: 0, False: 2.45k]
  ------------------
   95|      0|			apdu->cse = SC_APDU_CASE_1;
  ------------------
  |  |  291|      0|#define SC_APDU_CASE_1			0x01
  ------------------
   96|  2.68k|		if (apdu->resplen && !apdu->datalen)
  ------------------
  |  Branch (96:7): [True: 232, False: 2.45k]
  |  Branch (96:24): [True: 104, False: 128]
  ------------------
   97|    104|			apdu->cse = SC_APDU_CASE_2_SHORT;
  ------------------
  |  |  292|    104|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
   98|  2.68k|		if (!apdu->resplen && apdu->datalen)
  ------------------
  |  Branch (98:7): [True: 2.45k, False: 232]
  |  Branch (98:25): [True: 2.45k, False: 0]
  ------------------
   99|  2.45k|			apdu->cse = SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|  2.45k|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  100|  2.68k|		if (apdu->resplen && apdu->datalen)
  ------------------
  |  Branch (100:7): [True: 232, False: 2.45k]
  |  Branch (100:24): [True: 128, False: 104]
  ------------------
  101|    128|			apdu->cse = SC_APDU_CASE_4_SHORT;
  ------------------
  |  |  294|    128|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  102|  2.68k|	}
  103|  2.68k|}
sc_format_apdu_ex:
  109|  2.68k|{
  110|  2.68k|	if (!apdu) {
  ------------------
  |  Branch (110:6): [True: 0, False: 2.68k]
  ------------------
  111|      0|		return;
  112|      0|	}
  113|       |
  114|  2.68k|	memset(apdu, 0, sizeof(*apdu));
  115|  2.68k|	apdu->cla = cla;
  116|  2.68k|	apdu->ins = ins;
  117|  2.68k|	apdu->p1 = p1;
  118|  2.68k|	apdu->p2 = p2;
  119|  2.68k|	apdu->resp = resp;
  120|  2.68k|	apdu->resplen = resplen;
  121|  2.68k|	apdu->data = data;
  122|  2.68k|	apdu->datalen = datalen;
  123|  2.68k|	sc_format_apdu_cse_lc_le(apdu);
  124|  2.68k|}
sc_get_max_recv_size:
  188|   251k|{
  189|   251k|	size_t max_recv_size;
  190|   251k|	if (card == NULL || card->reader == NULL) {
  ------------------
  |  Branch (190:6): [True: 0, False: 251k]
  |  Branch (190:22): [True: 0, False: 251k]
  ------------------
  191|      0|		return 0;
  192|      0|	}
  193|   251k|	max_recv_size = card->max_recv_size;
  194|       |
  195|       |	/* initialize max_recv_size to a meaningful value */
  196|   251k|	if (card->caps & SC_CARD_CAP_APDU_EXT) {
  ------------------
  |  |  547|   251k|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (196:6): [True: 23.7k, False: 227k]
  ------------------
  197|  23.7k|		if (!max_recv_size)
  ------------------
  |  Branch (197:7): [True: 2.25k, False: 21.5k]
  ------------------
  198|  2.25k|			max_recv_size = 65536;
  199|   227k|	} else {
  200|   227k|		if (!max_recv_size)
  ------------------
  |  Branch (200:7): [True: 129k, False: 97.9k]
  ------------------
  201|   129k|			max_recv_size = 256;
  202|   227k|	}
  203|       |
  204|       |	/*  Override card limitations with reader limitations. */
  205|   251k|	if (card->reader->max_recv_size != 0
  ------------------
  |  Branch (205:6): [True: 14.7k, False: 236k]
  ------------------
  206|  14.7k|			&& (card->reader->max_recv_size < card->max_recv_size))
  ------------------
  |  Branch (206:7): [True: 0, False: 14.7k]
  ------------------
  207|      0|		max_recv_size = card->reader->max_recv_size;
  208|       |
  209|   251k|	return max_recv_size;
  210|   251k|}
sc_get_max_send_size:
  213|  37.7k|{
  214|  37.7k|	size_t max_send_size;
  215|       |
  216|  37.7k|	if (card == NULL || card->reader == NULL) {
  ------------------
  |  Branch (216:6): [True: 0, False: 37.7k]
  |  Branch (216:22): [True: 0, False: 37.7k]
  ------------------
  217|      0|		return 0;
  218|      0|	}
  219|       |
  220|  37.7k|	max_send_size = card->max_send_size;
  221|       |
  222|       |	/* initialize max_send_size to a meaningful value */
  223|  37.7k|	if (card->caps & SC_CARD_CAP_APDU_EXT
  ------------------
  |  |  547|  75.5k|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (223:6): [True: 5.73k, False: 32.0k]
  ------------------
  224|  5.73k|			&& card->reader->active_protocol != SC_PROTO_T0) {
  ------------------
  |  |  352|  5.73k|#define SC_PROTO_T0		0x00000001
  ------------------
  |  Branch (224:7): [True: 5.73k, False: 0]
  ------------------
  225|  5.73k|		if (!max_send_size)
  ------------------
  |  Branch (225:7): [True: 814, False: 4.92k]
  ------------------
  226|    814|			max_send_size = 65535;
  227|  32.0k|	} else {
  228|  32.0k|		if (!max_send_size)
  ------------------
  |  Branch (228:7): [True: 8.92k, False: 23.0k]
  ------------------
  229|  8.92k|			max_send_size = 255;
  230|  32.0k|	}
  231|       |
  232|       |	/*  Override card limitations with reader limitations. */
  233|  37.7k|	if (card->reader->max_send_size != 0
  ------------------
  |  Branch (233:6): [True: 0, False: 37.7k]
  ------------------
  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|  37.7k|	return max_send_size;
  238|  37.7k|}
sc_connect_card:
  241|  16.3k|{
  242|  16.3k|	sc_card_t *card;
  243|  16.3k|	sc_context_t *ctx;
  244|  16.3k|	struct sc_card_driver *driver;
  245|  16.3k|	int i, r = 0, idx, connected = 0;
  246|       |
  247|  16.3k|	if (card_out == NULL || reader == NULL)
  ------------------
  |  Branch (247:6): [True: 0, False: 16.3k]
  |  Branch (247:26): [True: 0, False: 16.3k]
  ------------------
  248|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  249|  16.3k|	ctx = reader->ctx;
  250|  16.3k|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  16.3k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  16.3k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  16.3k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 16.3k]
  |  |  ------------------
  ------------------
  251|  16.3k|	if (reader->ops->connect == NULL)
  ------------------
  |  Branch (251:6): [True: 0, False: 16.3k]
  ------------------
  252|  16.3k|		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|  16.3k|	card = sc_card_new(ctx);
  255|  16.3k|	if (card == NULL)
  ------------------
  |  Branch (255:6): [True: 0, False: 16.3k]
  ------------------
  256|  16.3k|		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|  16.3k|	r = reader->ops->connect(reader);
  258|  16.3k|	if (r)
  ------------------
  |  Branch (258:6): [True: 0, False: 16.3k]
  ------------------
  259|      0|		goto err;
  260|       |
  261|  16.3k|	connected = 1;
  262|  16.3k|	card->reader = reader;
  263|  16.3k|	card->ctx = ctx;
  264|       |
  265|  16.3k|	if (reader->flags & SC_READER_ENABLE_ESCAPE)
  ------------------
  |  |  372|  16.3k|#define SC_READER_ENABLE_ESCAPE		0x00000040
  ------------------
  |  Branch (265:6): [True: 0, False: 16.3k]
  ------------------
  266|      0|		sc_detect_escape_cmds(reader);
  267|       |
  268|  16.3k|	memcpy(&card->atr, &reader->atr, sizeof(card->atr));
  269|  16.3k|	memcpy(&card->uid, &reader->uid, sizeof(card->uid));
  270|       |
  271|  16.3k|	_sc_parse_atr(reader);
  272|       |
  273|       |	/* See if the ATR matches any ATR specified in the config file */
  274|  16.3k|	if ((driver = ctx->forced_driver) == NULL) {
  ------------------
  |  Branch (274:6): [True: 16.3k, False: 0]
  ------------------
  275|  16.3k|		sc_log(ctx, "matching configured ATRs");
  ------------------
  |  |   71|  16.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__
  |  |  ------------------
  ------------------
  276|   752k|		for (i = 0; ctx->card_drivers[i] != NULL; i++) {
  ------------------
  |  Branch (276:15): [True: 736k, False: 16.3k]
  ------------------
  277|   736k|			driver = ctx->card_drivers[i];
  278|       |
  279|   736k|			if (driver->atr_map == NULL ||
  ------------------
  |  Branch (279:8): [True: 736k, False: 0]
  ------------------
  280|   736k|			    !strcmp(driver->short_name, "default")) {
  ------------------
  |  Branch (280:8): [True: 0, False: 0]
  ------------------
  281|   736k|				driver = NULL;
  282|   736k|				continue;
  283|   736k|			}
  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|  16.3k|	}
  299|       |
  300|  16.3k|	if (driver != NULL) {
  ------------------
  |  Branch (300:6): [True: 0, False: 16.3k]
  ------------------
  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|  16.3k|	else {
  318|  16.3k|		sc_card_t uninitialized = *card;
  319|  16.3k|		sc_log(ctx, "matching built-in ATRs");
  ------------------
  |  |   71|  16.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__
  |  |  ------------------
  ------------------
  320|   433k|		for (i = 0; ctx->card_drivers[i] != NULL; i++) {
  ------------------
  |  Branch (320:15): [True: 430k, False: 2.43k]
  ------------------
  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|   430k|			*card = uninitialized;
  333|       |
  334|   430k|			struct sc_card_driver *drv = ctx->card_drivers[i];
  335|   430k|			const struct sc_card_operations *ops = drv->ops;
  336|       |
  337|   430k|			sc_log(ctx, "trying driver '%s'", drv->short_name);
  ------------------
  |  |   71|   430k|#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|   430k|			if (ops == NULL || ops->match_card == NULL)   {
  ------------------
  |  Branch (338:8): [True: 0, False: 430k]
  |  Branch (338:23): [True: 0, False: 430k]
  ------------------
  339|      0|				continue;
  340|      0|			}
  341|   430k|			else if (!(ctx->flags & SC_CTX_FLAG_ENABLE_DEFAULT_DRIVER)
  ------------------
  |  |  860|   430k|#define SC_CTX_FLAG_ENABLE_DEFAULT_DRIVER	0x00000008
  ------------------
  |  Branch (341:13): [True: 430k, False: 0]
  ------------------
  342|   430k|				   	&& !strcmp("default", drv->short_name))   {
  ------------------
  |  Branch (342:12): [True: 2.43k, False: 428k]
  ------------------
  343|  2.43k|				sc_log(ctx , "ignore 'default' card driver");
  ------------------
  |  |   71|  2.43k|#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|  2.43k|				continue;
  345|  2.43k|			}
  346|       |
  347|       |			/* Needed if match_card() needs to talk with the card (e.g. card-muscle) */
  348|   428k|			*card->ops = *ops;
  349|   428k|			if (ops->match_card(card) != 1)
  ------------------
  |  Branch (349:8): [True: 413k, False: 14.8k]
  ------------------
  350|   413k|				continue;
  351|  14.8k|			sc_log(ctx, "matched: %s", drv->name);
  ------------------
  |  |   71|  14.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__
  |  |  ------------------
  ------------------
  352|  14.8k|			memcpy(card->ops, ops, sizeof(struct sc_card_operations));
  353|  14.8k|			card->driver = drv;
  354|  14.8k|			r = ops->init(card);
  355|  14.8k|			if (r) {
  ------------------
  |  Branch (355:8): [True: 1.59k, False: 13.2k]
  ------------------
  356|  1.59k|				sc_log(ctx, "driver '%s' init() failed: %s", drv->name, sc_strerror(r));
  ------------------
  |  |   71|  1.59k|#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|  1.59k|				if (r == SC_ERROR_INVALID_CARD) {
  ------------------
  |  |   60|  1.59k|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  |  Branch (357:9): [True: 958, False: 636]
  ------------------
  358|    958|					card->driver = NULL;
  359|    958|					continue;
  360|    958|				}
  361|    636|				goto err;
  362|  1.59k|			}
  363|  13.2k|			break;
  364|  14.8k|		}
  365|  16.3k|	}
  366|  15.7k|	if (card->driver == NULL) {
  ------------------
  |  Branch (366:6): [True: 2.43k, False: 13.2k]
  ------------------
  367|  2.43k|		sc_log(ctx, "unable to find driver for inserted card");
  ------------------
  |  |   71|  2.43k|#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|  2.43k|		r = SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|  2.43k|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  369|  2.43k|		goto err;
  370|  2.43k|	}
  371|  13.2k|	if (card->name == NULL)
  ------------------
  |  Branch (371:6): [True: 1.73k, False: 11.5k]
  ------------------
  372|  1.73k|		card->name = card->driver->name;
  373|       |
  374|       |	/* initialize max_send_size/max_recv_size to a meaningful value */
  375|  13.2k|	card->max_recv_size = sc_get_max_recv_size(card);
  376|  13.2k|	card->max_send_size = sc_get_max_send_size(card);
  377|       |
  378|  13.2k|	sc_log(ctx, "card info name:'%s', type:%i, flags:0x%lX, max_send/recv_size:%zu/%zu",
  ------------------
  |  |   71|  13.2k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  379|  13.2k|			card->name, card->type, card->flags, card->max_send_size, card->max_recv_size);
  380|       |
  381|  13.2k|#ifdef ENABLE_SM
  382|       |	/* Check, if secure messaging module present. */
  383|  13.2k|	r = sc_card_sm_check(card);
  384|  13.2k|	if (r)   {
  ------------------
  |  Branch (384:6): [True: 0, False: 13.2k]
  ------------------
  385|      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__
  |  |  ------------------
  ------------------
  386|      0|		goto err;
  387|      0|	}
  388|  13.2k|#endif
  389|  13.2k|	*card_out = card;
  390|       |
  391|  13.2k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  13.2k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  13.2k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  13.2k|	int _ret = r; \
  |  |  |  |  155|  13.2k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 13.2k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  13.2k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 13.2k]
  |  |  |  |  ------------------
  |  |  |  |  157|  13.2k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  13.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|  13.2k|	return _ret; \
  |  |  |  |  163|  13.2k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  392|  3.07k|err:
  393|  3.07k|	if (connected)
  ------------------
  |  Branch (393:6): [True: 3.07k, False: 0]
  ------------------
  394|  3.07k|		reader->ops->disconnect(reader);
  395|  3.07k|	if (card != NULL)
  ------------------
  |  Branch (395:6): [True: 3.07k, False: 0]
  ------------------
  396|  3.07k|		sc_card_free(card);
  397|  3.07k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  3.07k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.07k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.07k|	int _ret = r; \
  |  |  |  |  155|  3.07k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.07k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.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|  3.07k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 3.07k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.07k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.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|  3.07k|	return _ret; \
  |  |  |  |  163|  3.07k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  398|  3.07k|}
sc_disconnect_card:
  401|  13.2k|{
  402|  13.2k|	sc_context_t *ctx;
  403|       |
  404|  13.2k|	if (!card)
  ------------------
  |  Branch (404:6): [True: 0, False: 13.2k]
  ------------------
  405|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  406|       |
  407|  13.2k|	ctx = card->ctx;
  408|  13.2k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  13.2k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  13.2k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  13.2k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  13.2k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 13.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  409|       |
  410|  13.2k|	if (card->ops->finish) {
  ------------------
  |  Branch (410:6): [True: 12.3k, False: 940]
  ------------------
  411|  12.3k|		int r = card->ops->finish(card);
  412|  12.3k|		if (r)
  ------------------
  |  Branch (412:7): [True: 7, False: 12.3k]
  ------------------
  413|      7|			sc_log(ctx, "card driver finish() failed: %s", sc_strerror(r));
  ------------------
  |  |   71|      7|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  414|  12.3k|	}
  415|       |
  416|  13.2k|	if (card->reader->ops->disconnect) {
  ------------------
  |  Branch (416:6): [True: 13.2k, False: 0]
  ------------------
  417|  13.2k|		int r = card->reader->ops->disconnect(card->reader);
  418|  13.2k|		if (r)
  ------------------
  |  Branch (418:7): [True: 0, False: 13.2k]
  ------------------
  419|      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__
  |  |  ------------------
  ------------------
  420|  13.2k|	}
  421|       |
  422|  13.2k|#ifdef ENABLE_SM
  423|       |	/* release SM related resources */
  424|  13.2k|	sc_card_sm_unload(card);
  425|  13.2k|#endif
  426|       |
  427|  13.2k|	sc_card_free(card);
  428|  13.2k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  13.2k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  13.2k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  13.2k|	int _ret = r; \
  |  |  |  |  155|  13.2k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 13.2k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  13.2k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 13.2k]
  |  |  |  |  ------------------
  |  |  |  |  157|  13.2k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  13.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|  13.2k|	return _ret; \
  |  |  |  |  163|  13.2k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  429|  13.2k|}
sc_lock:
  456|   769k|{
  457|   769k|	int r = 0, r2 = 0;
  458|   769k|	int was_reset = 0;
  459|   769k|	int reader_lock_obtained  = 0;
  460|       |
  461|   769k|	if (card == NULL)
  ------------------
  |  Branch (461:6): [True: 0, False: 769k]
  ------------------
  462|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  463|       |
  464|   769k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|   769k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|   769k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|   769k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|   769k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 769k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  465|       |
  466|   769k|	r = sc_mutex_lock(card->ctx, card->mutex);
  467|   769k|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|   769k|#define SC_SUCCESS				0
  ------------------
  |  Branch (467:6): [True: 0, False: 769k]
  ------------------
  468|      0|		return r;
  469|   769k|	if (card->lock_count == 0) {
  ------------------
  |  Branch (469:6): [True: 474k, False: 294k]
  ------------------
  470|   474k|		if (card->reader->ops->lock != NULL) {
  ------------------
  |  Branch (470:7): [True: 474k, False: 0]
  ------------------
  471|   474k|			r = card->reader->ops->lock(card->reader);
  472|   474k|			while (r == SC_ERROR_CARD_RESET || r == SC_ERROR_READER_REATTACHED) {
  ------------------
  |  |   37|   949k|#define SC_ERROR_CARD_RESET			-1106
  ------------------
              			while (r == SC_ERROR_CARD_RESET || r == SC_ERROR_READER_REATTACHED) {
  ------------------
  |  |   46|   474k|#define SC_ERROR_READER_REATTACHED		-1115
  ------------------
  |  Branch (472:11): [True: 0, False: 474k]
  |  Branch (472:39): [True: 0, False: 474k]
  ------------------
  473|      0|				if (was_reset++ > 4) /* TODO retry a few times */
  ------------------
  |  Branch (473:9): [True: 0, False: 0]
  ------------------
  474|      0|					break;
  475|      0|				r = card->reader->ops->lock(card->reader);
  476|      0|			}
  477|   474k|			if (r == 0)
  ------------------
  |  Branch (477:8): [True: 474k, False: 0]
  ------------------
  478|   474k|				reader_lock_obtained = 1;
  479|   474k|		}
  480|   474k|	}
  481|   769k|	if (r == 0)
  ------------------
  |  Branch (481:6): [True: 769k, False: 0]
  ------------------
  482|   769k|		card->lock_count++;
  483|       |
  484|   769k|	r2 = sc_mutex_unlock(card->ctx, card->mutex);
  485|   769k|	if (r2 != SC_SUCCESS) {
  ------------------
  |  |   28|   769k|#define SC_SUCCESS				0
  ------------------
  |  Branch (485:6): [True: 0, False: 769k]
  ------------------
  486|      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__
  |  |  ------------------
  ------------------
  487|      0|		r = r != SC_SUCCESS ? r : r2;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (487:7): [True: 0, False: 0]
  ------------------
  488|      0|	}
  489|       |
  490|   769k|	if (r == 0 && was_reset > 0) {
  ------------------
  |  Branch (490:6): [True: 769k, False: 0]
  |  Branch (490:16): [True: 0, False: 769k]
  ------------------
  491|      0|#ifdef ENABLE_SM
  492|      0|		if (card->sm_ctx.ops.open)
  ------------------
  |  Branch (492:7): [True: 0, False: 0]
  ------------------
  493|      0|			card->sm_ctx.ops.open(card);
  494|      0|#endif
  495|      0|	}
  496|       |
  497|       |	/* give card driver a chance to do something when reader lock first obtained */
  498|   769k|	if (r == 0 && reader_lock_obtained == 1  && card->ops->card_reader_lock_obtained) {
  ------------------
  |  Branch (498:6): [True: 769k, False: 0]
  |  Branch (498:16): [True: 474k, False: 294k]
  |  Branch (498:46): [True: 236k, False: 237k]
  ------------------
  499|   236k|		if (SC_SUCCESS != card->ops->card_reader_lock_obtained(card, was_reset))
  ------------------
  |  |   28|   236k|#define SC_SUCCESS				0
  ------------------
  |  Branch (499:7): [True: 0, False: 236k]
  ------------------
  500|      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__
  |  |  ------------------
  ------------------
  501|   236k|	}
  502|       |
  503|   769k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|   769k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|   769k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|   769k|	int _ret = r; \
  |  |  |  |  155|   769k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 769k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|   769k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 769k]
  |  |  |  |  ------------------
  |  |  |  |  157|   769k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|   769k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|   769k|	return _ret; \
  |  |  |  |  163|   769k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  504|   769k|}
sc_unlock:
  507|   769k|{
  508|   769k|	int r, r2;
  509|       |
  510|   769k|	if (!card)
  ------------------
  |  Branch (510:6): [True: 0, False: 769k]
  ------------------
  511|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  512|       |
  513|   769k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|   769k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|   769k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|   769k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|   769k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 769k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  514|       |
  515|   769k|	r = sc_mutex_lock(card->ctx, card->mutex);
  516|   769k|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|   769k|#define SC_SUCCESS				0
  ------------------
  |  Branch (516:6): [True: 0, False: 769k]
  ------------------
  517|   769k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  518|       |
  519|   769k|	if (card->lock_count < 1) {
  ------------------
  |  Branch (519:6): [True: 0, False: 769k]
  ------------------
  520|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  521|      0|	}
  522|   769k|	if (--card->lock_count == 0) {
  ------------------
  |  Branch (522:6): [True: 474k, False: 294k]
  ------------------
  523|       |		/* release reader lock */
  524|   474k|		if (card->reader->ops->unlock != NULL)
  ------------------
  |  Branch (524:7): [True: 474k, False: 0]
  ------------------
  525|   474k|			r = card->reader->ops->unlock(card->reader);
  526|   474k|	}
  527|   769k|	r2 = sc_mutex_unlock(card->ctx, card->mutex);
  528|   769k|	if (r2 != SC_SUCCESS) {
  ------------------
  |  |   28|   769k|#define SC_SUCCESS				0
  ------------------
  |  Branch (528:6): [True: 0, False: 769k]
  ------------------
  529|      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__
  |  |  ------------------
  ------------------
  530|      0|		r = (r == SC_SUCCESS) ? r2 : r;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (530:7): [True: 0, False: 0]
  ------------------
  531|      0|	}
  532|       |
  533|   769k|	return r;
  534|   769k|}
sc_list_files:
  537|    691|{
  538|    691|	int r;
  539|       |
  540|    691|	if (card == NULL) {
  ------------------
  |  Branch (540:6): [True: 0, False: 691]
  ------------------
  541|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  542|      0|	}
  543|    691|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    691|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    691|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    691|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    691|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 691]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  544|       |
  545|    691|	if (card->ops->list_files == NULL)
  ------------------
  |  Branch (545:6): [True: 0, False: 691]
  ------------------
  546|    691|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  547|    691|	r = card->ops->list_files(card, buf, buflen);
  548|       |
  549|    691|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    691|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    691|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    691|	int _ret = r; \
  |  |  |  |  155|    691|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 628, False: 63]
  |  |  |  |  ------------------
  |  |  |  |  156|    628|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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: 611]
  |  |  |  |  ------------------
  |  |  |  |  157|    628|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    628|	} else { \
  |  |  |  |  159|     63|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     63|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     63|	} \
  |  |  |  |  162|    691|	return _ret; \
  |  |  |  |  163|    691|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  550|    691|}
sc_create_file:
  553|  2.87k|{
  554|  2.87k|	int r;
  555|  2.87k|	char pbuf[SC_MAX_PATH_STRING_SIZE];
  556|  2.87k|	const sc_path_t *in_path;
  557|       |
  558|  2.87k|	if (card == NULL || file == NULL) {
  ------------------
  |  Branch (558:6): [True: 0, False: 2.87k]
  |  Branch (558:22): [True: 0, False: 2.87k]
  ------------------
  559|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  560|      0|	}
  561|       |
  562|  2.87k|	in_path = &file->path;
  563|  2.87k|	r = sc_path_print(pbuf, sizeof(pbuf), in_path);
  564|  2.87k|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|  2.87k|#define SC_SUCCESS				0
  ------------------
  |  Branch (564:6): [True: 1, False: 2.87k]
  ------------------
  565|      1|		pbuf[0] = '\0';
  566|       |
  567|  2.87k|	sc_log(card->ctx, "called; type=%d, path=%s, id=%04i, size=%zu",
  ------------------
  |  |   71|  2.87k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  568|  2.87k|			in_path->type, pbuf, file->id, file->size);
  569|       |	/* ISO 7816-4: "Number of data bytes in the file, including structural information if any"
  570|       |	 * can not be bigger than two bytes */
  571|  2.87k|	if (file->size > 0xFFFF)
  ------------------
  |  Branch (571:6): [True: 9, False: 2.86k]
  ------------------
  572|  2.87k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|      9|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      9|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      9|	int _ret = r; \
  |  |  |  |  155|      9|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 9, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      9|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      9|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 9, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      9|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      9|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      9|	return _ret; \
  |  |  |  |  163|      9|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  573|       |
  574|  2.86k|	if (card->ops->create_file == NULL)
  ------------------
  |  Branch (574:6): [True: 0, False: 2.86k]
  ------------------
  575|  2.86k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  576|       |
  577|  2.86k|	r = card->ops->create_file(card, file);
  578|  2.86k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  2.86k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.86k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.86k|	int _ret = r; \
  |  |  |  |  155|  2.86k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.86k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.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|    772|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 772, False: 2.09k]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.86k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.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|  2.86k|	return _ret; \
  |  |  |  |  163|  2.86k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  579|  2.86k|}
sc_delete_file:
  582|    967|{
  583|    967|	int r;
  584|    967|	char pbuf[SC_MAX_PATH_STRING_SIZE];
  585|       |
  586|    967|	if (card == NULL) {
  ------------------
  |  Branch (586:6): [True: 0, False: 967]
  ------------------
  587|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  588|      0|	}
  589|       |
  590|    967|	r = sc_path_print(pbuf, sizeof(pbuf), path);
  591|    967|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|    967|#define SC_SUCCESS				0
  ------------------
  |  Branch (591:6): [True: 4, False: 963]
  ------------------
  592|      4|		pbuf[0] = '\0';
  593|       |
  594|    967|	sc_log(card->ctx, "called; type=%d, path=%s", path->type, pbuf);
  ------------------
  |  |   71|    967|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  595|    967|	if (card->ops->delete_file == NULL)
  ------------------
  |  Branch (595:6): [True: 7, False: 960]
  ------------------
  596|    967|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  597|    960|	r = card->ops->delete_file(card, path);
  598|       |
  599|    960|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    960|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    960|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    960|	int _ret = r; \
  |  |  |  |  155|    960|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 960, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    960|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    553|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 553, False: 407]
  |  |  |  |  ------------------
  |  |  |  |  157|    960|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    960|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    960|	return _ret; \
  |  |  |  |  163|    960|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  600|    960|}
sc_read_binary:
  604|  7.76k|{
  605|  7.76k|	size_t max_le = sc_get_max_recv_size(card);
  606|  7.76k|	size_t todo = count;
  607|  7.76k|	int r;
  608|       |
  609|  7.76k|	if (card == NULL || card->ops == NULL || buf == NULL) {
  ------------------
  |  Branch (609:6): [True: 0, False: 7.76k]
  |  Branch (609:22): [True: 0, False: 7.76k]
  |  Branch (609:43): [True: 0, False: 7.76k]
  ------------------
  610|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  611|      0|	}
  612|  7.76k|	sc_log(card->ctx, "called; %zu bytes at index %d", count, idx);
  ------------------
  |  |   71|  7.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__
  |  |  ------------------
  ------------------
  613|  7.76k|	if (count == 0)
  ------------------
  |  Branch (613:6): [True: 813, False: 6.95k]
  ------------------
  614|  7.76k|		LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    813|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    813|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    813|	int _ret = r; \
  |  |  |  |  155|    813|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 813, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    813|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 813]
  |  |  |  |  ------------------
  |  |  |  |  157|    813|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    813|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    813|	return _ret; \
  |  |  |  |  163|    813|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  615|       |
  616|  6.95k|#ifdef ENABLE_SM
  617|  6.95k|	if (card->sm_ctx.ops.read_binary)   {
  ------------------
  |  Branch (617:6): [True: 91, False: 6.86k]
  ------------------
  618|     91|		r = card->sm_ctx.ops.read_binary(card, idx, buf, count);
  619|     91|		if (r)
  ------------------
  |  Branch (619:7): [True: 71, False: 20]
  ------------------
  620|     91|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     71|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     71|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     71|	int _ret = r; \
  |  |  |  |  155|     71|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 71, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     71|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     71|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 71, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     71|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     71|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     71|	return _ret; \
  |  |  |  |  163|     71|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  621|     91|	}
  622|  6.88k|#endif
  623|       |
  624|  6.88k|	if (card->ops->read_binary == NULL)
  ------------------
  |  Branch (624:6): [True: 0, False: 6.88k]
  ------------------
  625|  6.88k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  626|       |
  627|       |	/* lock the card now to avoid deselection of the file */
  628|  6.88k|	r = sc_lock(card);
  629|  6.88k|	LOG_TEST_RET(card->ctx, r, "sc_lock() failed");
  ------------------
  |  |  174|  6.88k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  6.88k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  6.88k|	int _ret = (r); \
  |  |  |  |  168|  6.88k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 6.88k]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#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.88k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 6.88k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  630|       |
  631|  16.2k|	while (todo > 0) {
  ------------------
  |  Branch (631:9): [True: 15.5k, False: 699]
  ------------------
  632|  15.5k|		size_t chunk = MIN(todo, max_le);
  ------------------
  |  |   70|  15.5k|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 5.68k, False: 9.83k]
  |  |  ------------------
  ------------------
  633|       |
  634|  15.5k|		r = card->ops->read_binary(card, idx, buf, chunk, flags);
  635|  15.5k|		if (r == 0 || r == SC_ERROR_FILE_END_REACHED)
  ------------------
  |  |   69|  14.7k|#define SC_ERROR_FILE_END_REACHED		-1219
  ------------------
  |  Branch (635:7): [True: 819, False: 14.7k]
  |  Branch (635:17): [True: 2, False: 14.6k]
  ------------------
  636|    821|			break;
  637|  14.6k|		if (r < 0 && todo != count) {
  ------------------
  |  Branch (637:7): [True: 5.36k, False: 9.33k]
  |  Branch (637:16): [True: 1.49k, False: 3.86k]
  ------------------
  638|       |			/* the last command failed, but previous ones succeeded.
  639|       |			 * Let's just return what we've successfully read. */
  640|  1.49k|			sc_log(card->ctx, "Subsequent read failed with %d, returning what was read successfully.", r);
  ------------------
  |  |   71|  1.49k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  641|  1.49k|			break;
  642|  1.49k|		}
  643|  13.2k|		if (r < 0) {
  ------------------
  |  Branch (643:7): [True: 3.86k, False: 9.33k]
  ------------------
  644|  3.86k|			sc_unlock(card);
  645|  3.86k|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  3.86k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.86k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.86k|	int _ret = r; \
  |  |  |  |  155|  3.86k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.86k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.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|  3.86k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 3.86k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.86k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.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|  3.86k|	return _ret; \
  |  |  |  |  163|  3.86k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  646|  3.86k|		}
  647|  9.33k|		if ((idx > SIZE_MAX - (size_t) r) || (size_t) r > todo) {
  ------------------
  |  Branch (647:7): [True: 0, False: 9.33k]
  |  Branch (647:40): [True: 0, False: 9.33k]
  ------------------
  648|       |			/* `idx + r` or `todo - r` would overflow */
  649|      0|			sc_unlock(card);
  650|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  651|      0|		}
  652|       |
  653|  9.33k|		todo -= (size_t) r;
  654|  9.33k|		buf  += (size_t) r;
  655|  9.33k|		idx  += (size_t) r;
  656|  9.33k|	}
  657|       |
  658|  3.01k|	sc_unlock(card);
  659|       |
  660|  3.01k|	LOG_FUNC_RETURN(card->ctx, (int)(count - todo));
  ------------------
  |  |  164|  3.01k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.01k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.01k|	int _ret = r; \
  |  |  |  |  155|  3.01k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 527, False: 2.48k]
  |  |  |  |  ------------------
  |  |  |  |  156|    527|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 527]
  |  |  |  |  ------------------
  |  |  |  |  157|    527|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.48k|	} else { \
  |  |  |  |  159|  2.48k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  2.48k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  2.48k|	} \
  |  |  |  |  162|  3.01k|	return _ret; \
  |  |  |  |  163|  3.01k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  661|  3.01k|}
sc_update_binary:
  712|  1.39k|{
  713|  1.39k|	size_t max_lc = sc_get_max_send_size(card);
  714|  1.39k|	size_t todo = count;
  715|  1.39k|	int r;
  716|       |
  717|  1.39k|	if (card == NULL || card->ops == NULL || buf == NULL) {
  ------------------
  |  Branch (717:6): [True: 0, False: 1.39k]
  |  Branch (717:22): [True: 0, False: 1.39k]
  |  Branch (717:43): [True: 0, False: 1.39k]
  ------------------
  718|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  719|      0|	}
  720|  1.39k|	sc_log(card->ctx, "called; %zu bytes at index %d", count, idx);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  721|  1.39k|	if (count == 0)
  ------------------
  |  Branch (721:6): [True: 6, False: 1.38k]
  ------------------
  722|  1.39k|		LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|      6|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      6|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      6|	int _ret = r; \
  |  |  |  |  155|      6|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      6|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 6]
  |  |  |  |  ------------------
  |  |  |  |  157|      6|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      6|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      6|	return _ret; \
  |  |  |  |  163|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  723|       |
  724|  1.38k|#ifdef ENABLE_SM
  725|  1.38k|	if (card->sm_ctx.ops.update_binary)   {
  ------------------
  |  Branch (725:6): [True: 4, False: 1.38k]
  ------------------
  726|      4|		r = card->sm_ctx.ops.update_binary(card, idx, buf, count);
  727|      4|		if (r)
  ------------------
  |  Branch (727:7): [True: 1, False: 3]
  ------------------
  728|      4|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  729|      4|	}
  730|  1.38k|#endif
  731|       |
  732|  1.38k|	if (card->ops->update_binary == NULL)
  ------------------
  |  Branch (732:6): [True: 6, False: 1.37k]
  ------------------
  733|  1.38k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  734|       |
  735|       |	/* lock the card now to avoid deselection of the file */
  736|  1.37k|	r = sc_lock(card);
  737|  1.37k|	LOG_TEST_RET(card->ctx, r, "sc_lock() 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: 0, False: 1.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|  1.37k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.37k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  738|       |
  739|  7.60k|	while (todo > 0) {
  ------------------
  |  Branch (739:9): [True: 6.42k, False: 1.18k]
  ------------------
  740|  6.42k|		size_t chunk = MIN(todo, max_lc);
  ------------------
  |  |   70|  6.42k|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 690, False: 5.73k]
  |  |  ------------------
  ------------------
  741|       |
  742|  6.42k|		r = card->ops->update_binary(card, idx, buf, chunk, flags);
  743|  6.42k|		if (r == 0 || r == SC_ERROR_FILE_END_REACHED)
  ------------------
  |  |   69|  6.42k|#define SC_ERROR_FILE_END_REACHED		-1219
  ------------------
  |  Branch (743:7): [True: 0, False: 6.42k]
  |  Branch (743:17): [True: 4, False: 6.42k]
  ------------------
  744|      4|			break;
  745|  6.42k|		if (r < 0) {
  ------------------
  |  Branch (745:7): [True: 193, False: 6.22k]
  ------------------
  746|    193|			sc_unlock(card);
  747|    193|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    193|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    193|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    193|	int _ret = r; \
  |  |  |  |  155|    193|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 193, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    193|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    193|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 193, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    193|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    193|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    193|	return _ret; \
  |  |  |  |  163|    193|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  748|    193|		}
  749|  6.22k|		if ((idx > SIZE_MAX - (size_t) r) || (size_t) r > todo) {
  ------------------
  |  Branch (749:7): [True: 0, False: 6.22k]
  |  Branch (749:40): [True: 0, False: 6.22k]
  ------------------
  750|       |			/* `idx + r` or `todo - r` would overflow */
  751|      0|			sc_unlock(card);
  752|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  753|      0|		}
  754|       |
  755|  6.22k|		todo -= (size_t) r;
  756|  6.22k|		buf  += (size_t) r;
  757|  6.22k|		idx  += (size_t) r;
  758|  6.22k|	}
  759|       |
  760|  1.18k|	sc_unlock(card);
  761|       |
  762|  1.18k|	LOG_FUNC_RETURN(card->ctx, (int)(count - todo));
  ------------------
  |  |  164|  1.18k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.18k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.18k|	int _ret = r; \
  |  |  |  |  155|  1.18k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4, False: 1.18k]
  |  |  |  |  ------------------
  |  |  |  |  156|      4|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  157|      4|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.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.18k|	return _ret; \
  |  |  |  |  163|  1.18k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  763|  1.18k|}
sc_erase_binary:
  767|     57|{
  768|     57|	int r;
  769|     57|	size_t todo = count;
  770|       |
  771|     57|	if (card == NULL || card->ops == NULL) {
  ------------------
  |  Branch (771:6): [True: 0, False: 57]
  |  Branch (771:22): [True: 0, False: 57]
  ------------------
  772|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  773|      0|	}
  774|     57|	sc_log(card->ctx, "called; erase %zu bytes from offset %d", count, idx);
  ------------------
  |  |   71|     57|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  775|     57|	if (count == 0)
  ------------------
  |  Branch (775:6): [True: 18, False: 39]
  ------------------
  776|     57|		LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 18]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  777|       |
  778|     39|	if (card->ops->erase_binary == NULL)
  ------------------
  |  Branch (778:6): [True: 0, False: 39]
  ------------------
  779|     39|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  780|       |
  781|       |	/* lock the card now to avoid deselection of the file */
  782|     39|	r = sc_lock(card);
  783|     39|	LOG_TEST_RET(card->ctx, r, "sc_lock() failed");
  ------------------
  |  |  174|     39|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     39|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     39|	int _ret = (r); \
  |  |  |  |  168|     39|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 39]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|     39|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 39]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  784|       |
  785|     57|	while (todo > 0) {
  ------------------
  |  Branch (785:9): [True: 39, False: 18]
  ------------------
  786|     39|		r = card->ops->erase_binary(card, idx, todo, flags);
  787|     39|		if (r == 0 || r == SC_ERROR_FILE_END_REACHED)
  ------------------
  |  |   69|     38|#define SC_ERROR_FILE_END_REACHED		-1219
  ------------------
  |  Branch (787:7): [True: 1, False: 38]
  |  Branch (787:17): [True: 0, False: 38]
  ------------------
  788|      1|			break;
  789|     38|		if (r < 0) {
  ------------------
  |  Branch (789:7): [True: 20, False: 18]
  ------------------
  790|     20|			sc_unlock(card);
  791|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  792|     20|		}
  793|     18|		if ((idx > SIZE_MAX - (size_t) r) || (size_t) r > todo) {
  ------------------
  |  Branch (793:7): [True: 0, False: 18]
  |  Branch (793:40): [True: 0, False: 18]
  ------------------
  794|       |			/* `idx + r` or `todo - r` would overflow */
  795|      0|			sc_unlock(card);
  796|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  797|      0|		}
  798|       |
  799|     18|		todo -= (size_t) r;
  800|     18|		idx  += (size_t) r;
  801|     18|	}
  802|       |
  803|     19|	sc_unlock(card);
  804|       |
  805|     19|	LOG_FUNC_RETURN(card->ctx, (int)(count - todo));
  ------------------
  |  |  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: 1, False: 18]
  |  |  |  |  ------------------
  |  |  |  |  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|     18|	} 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|     19|	return _ret; \
  |  |  |  |  163|     19|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  806|     19|}
sc_select_file:
  810|   135k|{
  811|   135k|	int r;
  812|   135k|	char pbuf[SC_MAX_PATH_STRING_SIZE];
  813|       |
  814|   135k|	if (card == NULL || in_path == NULL) {
  ------------------
  |  Branch (814:6): [True: 0, False: 135k]
  |  Branch (814:22): [True: 0, False: 135k]
  ------------------
  815|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  816|      0|	}
  817|       |
  818|   135k|	r = sc_path_print(pbuf, sizeof(pbuf), in_path);
  819|   135k|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|   135k|#define SC_SUCCESS				0
  ------------------
  |  Branch (819:6): [True: 385, False: 135k]
  ------------------
  820|    385|		pbuf[0] = '\0';
  821|       |
  822|       |	/* FIXME We should be a bit less strict and let the upper layers do
  823|       |	 * the initialization (including reuse of existing file objects). We
  824|       |	 * implemented this here because we are lazy. */
  825|   135k|	if (file != NULL)
  ------------------
  |  Branch (825:6): [True: 88.7k, False: 46.9k]
  ------------------
  826|  88.7k|		*file = NULL;
  827|       |
  828|   135k|	sc_log(card->ctx, "called; type=%d, path=%s", in_path->type, pbuf);
  ------------------
  |  |   71|   135k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  829|   135k|	if (in_path->len > SC_MAX_PATH_SIZE)
  ------------------
  |  |   47|   135k|#define SC_MAX_PATH_SIZE		16
  ------------------
  |  Branch (829:6): [True: 0, False: 135k]
  ------------------
  830|   135k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  831|       |
  832|   135k|	if (in_path->type == SC_PATH_TYPE_PATH) {
  ------------------
  |  |  119|   135k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (832:6): [True: 104k, False: 31.2k]
  ------------------
  833|       |		/* Perform a sanity check */
  834|   104k|		size_t i;
  835|       |
  836|   104k|		if ((in_path->len & 1) != 0)
  ------------------
  |  Branch (836:7): [True: 886, False: 103k]
  ------------------
  837|   104k|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|    886|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    886|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    886|	int _ret = r; \
  |  |  |  |  155|    886|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 886, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    886|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    886|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 886, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    886|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    886|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    886|	return _ret; \
  |  |  |  |  163|    886|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  838|       |
  839|   370k|		for (i = 0; i < in_path->len/2; i++) {
  ------------------
  |  Branch (839:15): [True: 267k, False: 103k]
  ------------------
  840|   267k|			u8 p1 = in_path->value[2*i],
  841|   267k|			   p2 = in_path->value[2*i+1];
  842|       |
  843|   267k|			if ((p1 == 0x3F && p2 == 0x00) && i != 0)
  ------------------
  |  Branch (843:9): [True: 103k, False: 163k]
  |  Branch (843:23): [True: 91.2k, False: 12.7k]
  |  Branch (843:38): [True: 209, False: 91.0k]
  ------------------
  844|   267k|				LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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|    209|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 209, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  845|   267k|		}
  846|   103k|	}
  847|   134k|	if (card->ops->select_file == NULL)
  ------------------
  |  Branch (847:6): [True: 0, False: 134k]
  ------------------
  848|   134k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  849|   134k|	r = card->ops->select_file(card, in_path, file);
  850|   134k|	LOG_TEST_RET(card->ctx, r, "'SELECT' error");
  ------------------
  |  |  174|   134k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|   134k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|   134k|	int _ret = (r); \
  |  |  |  |  168|   134k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 99.5k, False: 35.0k]
  |  |  |  |  ------------------
  |  |  |  |  169|  99.5k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.5k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  99.5k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  99.5k|		return _ret; \
  |  |  |  |  172|  99.5k|	} \
  |  |  |  |  173|   134k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 35.0k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  851|       |
  852|  35.0k|	if (file) {
  ------------------
  |  Branch (852:6): [True: 20.7k, False: 14.2k]
  ------------------
  853|  20.7k|		if (*file)
  ------------------
  |  Branch (853:7): [True: 20.1k, False: 626]
  ------------------
  854|       |			/* Remember file path */
  855|  20.1k|			(*file)->path = *in_path;
  856|    626|		else
  857|       |			/* FIXME We should be a bit less strict and let the upper layers do
  858|       |			 * the error checking. We implemented this here because we are
  859|       |			 * lazy.  */
  860|    626|			r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|    626|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  861|  20.7k|	}
  862|       |
  863|  35.0k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  35.0k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  35.0k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  35.0k|	int _ret = r; \
  |  |  |  |  155|  35.0k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 35.0k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  35.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|    626|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 626, False: 34.4k]
  |  |  |  |  ------------------
  |  |  |  |  157|  35.0k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  35.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|  35.0k|	return _ret; \
  |  |  |  |  163|  35.0k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  864|  35.0k|}
sc_get_data:
  868|  8.67k|{
  869|  8.67k|	int	r;
  870|       |
  871|  8.67k|	sc_log(card->ctx, "called, tag=%04x", tag);
  ------------------
  |  |   71|  8.67k|#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|  8.67k|	if (card->ops->get_data == NULL)
  ------------------
  |  Branch (872:6): [True: 0, False: 8.67k]
  ------------------
  873|  8.67k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  874|  8.67k|	r = card->ops->get_data(card, tag, buf, len);
  875|       |
  876|  8.67k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  8.67k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  8.67k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  8.67k|	int _ret = r; \
  |  |  |  |  155|  8.67k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 6.02k, False: 2.65k]
  |  |  |  |  ------------------
  |  |  |  |  156|  6.02k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  4.88k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 4.88k, False: 1.13k]
  |  |  |  |  ------------------
  |  |  |  |  157|  6.02k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  6.02k|	} else { \
  |  |  |  |  159|  2.65k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  2.65k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  2.65k|	} \
  |  |  |  |  162|  8.67k|	return _ret; \
  |  |  |  |  163|  8.67k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  877|  8.67k|}
sc_get_challenge:
  893|     14|{
  894|     14|	int r;
  895|       |
  896|     14|	if (len == 0)
  ------------------
  |  Branch (896:6): [True: 0, False: 14]
  ------------------
  897|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  898|       |
  899|     14|	if (card == NULL || rnd == NULL) {
  ------------------
  |  Branch (899:6): [True: 0, False: 14]
  |  Branch (899:22): [True: 0, False: 14]
  ------------------
  900|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  901|      0|	}
  902|       |
  903|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  904|       |
  905|     14|	if (card->ops == NULL || card->ops->get_challenge == NULL)
  ------------------
  |  Branch (905:6): [True: 0, False: 14]
  |  Branch (905:27): [True: 0, False: 14]
  ------------------
  906|     14|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  907|       |
  908|     14|	r = sc_lock(card);
  909|     14|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|     14|#define SC_SUCCESS				0
  ------------------
  |  Branch (909:6): [True: 0, False: 14]
  ------------------
  910|     14|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  911|       |
  912|     32|	while (len > 0) {
  ------------------
  |  Branch (912:9): [True: 26, False: 6]
  ------------------
  913|     26|		r = card->ops->get_challenge(card, rnd, len);
  914|     26|		if (r == 0)
  ------------------
  |  Branch (914:7): [True: 2, False: 24]
  ------------------
  915|      2|			r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      2|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  916|     26|		if (r < 0) {
  ------------------
  |  Branch (916:7): [True: 8, False: 18]
  ------------------
  917|      8|			sc_unlock(card);
  918|      8|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|      8|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      8|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      8|	int _ret = r; \
  |  |  |  |  155|      8|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 8, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      8|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      8|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 8, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      8|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      8|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      8|	return _ret; \
  |  |  |  |  163|      8|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  919|      8|		}
  920|       |
  921|     18|		rnd += (size_t) r;
  922|     18|		len -= (size_t) r;
  923|     18|	}
  924|       |
  925|      6|	sc_unlock(card);
  926|       |
  927|      6|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|      6|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      6|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      6|	int _ret = r; \
  |  |  |  |  155|      6|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      6|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 6]
  |  |  |  |  ------------------
  |  |  |  |  157|      6|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      6|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      6|	return _ret; \
  |  |  |  |  163|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  928|      6|}
sc_read_record:
  932|  5.18k|{
  933|  5.18k|	size_t max_le = sc_get_max_recv_size(card);
  934|  5.18k|	size_t todo = count;
  935|  5.18k|	int r;
  936|       |
  937|  5.18k|	if (card == NULL || card->ops == NULL || buf == NULL) {
  ------------------
  |  Branch (937:6): [True: 0, False: 5.18k]
  |  Branch (937:22): [True: 0, False: 5.18k]
  |  Branch (937:43): [True: 0, False: 5.18k]
  ------------------
  938|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  939|      0|	}
  940|  5.18k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  5.18k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  5.18k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  5.18k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  5.18k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 5.18k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  941|  5.18k|	if (count == 0)
  ------------------
  |  Branch (941:6): [True: 354, False: 4.83k]
  ------------------
  942|  5.18k|		LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    354|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    354|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    354|	int _ret = r; \
  |  |  |  |  155|    354|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 354, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    354|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 354]
  |  |  |  |  ------------------
  |  |  |  |  157|    354|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    354|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    354|	return _ret; \
  |  |  |  |  163|    354|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  943|       |
  944|  4.83k|	if (card->ops->read_record == NULL)
  ------------------
  |  Branch (944:6): [True: 18, False: 4.81k]
  ------------------
  945|  4.83k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|     18|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     18|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     18|	int _ret = r; \
  |  |  |  |  155|     18|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 18, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     18|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     18|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 18, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     18|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     18|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     18|	return _ret; \
  |  |  |  |  163|     18|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  946|       |
  947|       |	/* lock the card now to avoid deselection of the file */
  948|  4.81k|	r = sc_lock(card);
  949|  4.81k|	LOG_TEST_RET(card->ctx, r, "sc_lock() failed");
  ------------------
  |  |  174|  4.81k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  4.81k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  4.81k|	int _ret = (r); \
  |  |  |  |  168|  4.81k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 4.81k]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#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.81k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4.81k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  950|       |
  951|  8.64k|	while (todo > 0) {
  ------------------
  |  Branch (951:9): [True: 8.35k, False: 289]
  ------------------
  952|  8.35k|		size_t chunk = MIN(todo, max_le);
  ------------------
  |  |   70|  8.35k|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 4.19k, False: 4.15k]
  |  |  ------------------
  ------------------
  953|       |
  954|  8.35k|		r = card->ops->read_record(card, rec_nr, idx, buf, chunk, flags);
  955|  8.35k|		if (r == 0 || r == SC_ERROR_FILE_END_REACHED)
  ------------------
  |  |   69|  7.73k|#define SC_ERROR_FILE_END_REACHED		-1219
  ------------------
  |  Branch (955:7): [True: 621, False: 7.73k]
  |  Branch (955:17): [True: 323, False: 7.40k]
  ------------------
  956|    944|			break;
  957|  7.40k|		if (r < 0 && todo != count) {
  ------------------
  |  Branch (957:7): [True: 3.58k, False: 3.82k]
  |  Branch (957:16): [True: 3.21k, False: 362]
  ------------------
  958|       |			/* the last command failed, but previous ones succeeded.
  959|       |			 * Let's just return what we've successfully read. */
  960|  3.21k|			sc_log(card->ctx, "Subsequent read failed with %d, returning what was read successfully.", r);
  ------------------
  |  |   71|  3.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__
  |  |  ------------------
  ------------------
  961|  3.21k|			break;
  962|  3.21k|		}
  963|  4.18k|		if (r < 0) {
  ------------------
  |  Branch (963:7): [True: 362, False: 3.82k]
  ------------------
  964|    362|			sc_unlock(card);
  965|    362|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    362|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    362|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    362|	int _ret = r; \
  |  |  |  |  155|    362|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 362, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    362|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    362|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 362, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    362|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    362|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    362|	return _ret; \
  |  |  |  |  163|    362|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  966|    362|		}
  967|  3.82k|		if ((idx > SIZE_MAX - (size_t) r) || (size_t) r > todo) {
  ------------------
  |  Branch (967:7): [True: 0, False: 3.82k]
  |  Branch (967:40): [True: 0, False: 3.82k]
  ------------------
  968|       |			/* `idx + r` or `todo - r` would overflow */
  969|      0|			sc_unlock(card);
  970|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  971|      0|		}
  972|       |
  973|  3.82k|		todo -= (size_t) r;
  974|  3.82k|		buf  += (size_t) r;
  975|  3.82k|		idx  += (size_t) r;
  976|  3.82k|	}
  977|       |
  978|  4.45k|	sc_unlock(card);
  979|       |
  980|  4.45k|	LOG_FUNC_RETURN(card->ctx, (int)(count - todo));
  ------------------
  |  |  164|  4.45k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  4.45k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  4.45k|	int _ret = r; \
  |  |  |  |  155|  4.45k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 900, False: 3.55k]
  |  |  |  |  ------------------
  |  |  |  |  156|    900|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 900]
  |  |  |  |  ------------------
  |  |  |  |  157|    900|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.55k|	} else { \
  |  |  |  |  159|  3.55k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  3.55k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  3.55k|	} \
  |  |  |  |  162|  4.45k|	return _ret; \
  |  |  |  |  163|  4.45k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  981|  4.45k|}
sc_append_record:
 1006|      2|{
 1007|      2|	int r;
 1008|       |
 1009|      2|	if (card == NULL) {
  ------------------
  |  Branch (1009:6): [True: 0, False: 2]
  ------------------
 1010|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1011|      0|	}
 1012|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1013|       |
 1014|      2|	if (card->ops->append_record == NULL)
  ------------------
  |  Branch (1014:6): [True: 2, False: 0]
  ------------------
 1015|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1016|       |
 1017|      0|	r = card->ops->append_record(card, buf, count, flags);
 1018|      0|	if (r == SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1018:6): [True: 0, False: 0]
  ------------------
 1019|      0|		r = (int)count;
 1020|      0|	}
 1021|       |
 1022|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1023|      0|}
sc_update_record:
 1027|      2|{
 1028|      2|	size_t max_lc = sc_get_max_send_size(card);
 1029|      2|	size_t todo = count;
 1030|      2|	int r;
 1031|       |
 1032|      2|	if (card == NULL || card->ops == NULL || buf == NULL) {
  ------------------
  |  Branch (1032:6): [True: 0, False: 2]
  |  Branch (1032:22): [True: 0, False: 2]
  |  Branch (1032:43): [True: 0, False: 2]
  ------------------
 1033|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1034|      0|	}
 1035|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1036|      2|	if (count == 0)
  ------------------
  |  Branch (1036:6): [True: 0, False: 2]
  ------------------
 1037|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1038|       |
 1039|      2|	if (card->ops->update_record == NULL)
  ------------------
  |  Branch (1039:6): [True: 2, False: 0]
  ------------------
 1040|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1041|       |
 1042|       |	/* lock the card now to avoid deselection of the file */
 1043|      0|	r = sc_lock(card);
 1044|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1045|       |
 1046|      0|	while (todo > 0) {
  ------------------
  |  Branch (1046:9): [True: 0, False: 0]
  ------------------
 1047|      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]
  |  |  ------------------
  ------------------
 1048|       |
 1049|      0|		r = card->ops->update_record(card, rec_nr, idx, buf, chunk, flags);
 1050|      0|		if (r == 0 || r == SC_ERROR_FILE_END_REACHED)
  ------------------
  |  |   69|      0|#define SC_ERROR_FILE_END_REACHED		-1219
  ------------------
  |  Branch (1050:7): [True: 0, False: 0]
  |  Branch (1050:17): [True: 0, False: 0]
  ------------------
 1051|      0|			break;
 1052|      0|		if (r < 0) {
  ------------------
  |  Branch (1052:7): [True: 0, False: 0]
  ------------------
 1053|      0|			sc_unlock(card);
 1054|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1055|      0|		}
 1056|      0|		if ((idx > SIZE_MAX - (size_t) r) || (size_t) r > todo) {
  ------------------
  |  Branch (1056:7): [True: 0, False: 0]
  |  Branch (1056:40): [True: 0, False: 0]
  ------------------
 1057|       |			/* `idx + r` or `todo - r` would overflow */
 1058|      0|			sc_unlock(card);
 1059|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1060|      0|		}
 1061|       |
 1062|      0|		todo -= (size_t) r;
 1063|      0|		buf  += (size_t) r;
 1064|      0|		idx  += (size_t) r;
 1065|      0|	}
 1066|       |
 1067|      0|	sc_unlock(card);
 1068|       |
 1069|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1070|      0|}
sc_card_ctl:
 1091|  24.1k|{
 1092|  24.1k|	int r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|  24.1k|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1093|       |
 1094|  24.1k|	if (card == NULL) {
  ------------------
  |  Branch (1094:6): [True: 0, False: 24.1k]
  ------------------
 1095|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1096|      0|	}
 1097|  24.1k|	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "called with cmd=%lu\n", cmd);
  ------------------
  |  |   70|  24.1k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1098|       |
 1099|  24.1k|	if (card->ops->card_ctl != NULL)
  ------------------
  |  Branch (1099:6): [True: 24.0k, False: 125]
  ------------------
 1100|  24.0k|		r = card->ops->card_ctl(card, cmd, args);
 1101|       |
 1102|       |	/* suppress "not supported" error messages */
 1103|  24.1k|	if (r == SC_ERROR_NOT_SUPPORTED) {
  ------------------
  |  |   89|  24.1k|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  |  Branch (1103:6): [True: 15.7k, False: 8.43k]
  ------------------
 1104|  15.7k|		sc_log(card->ctx, "card_ctl(%lu) not supported", cmd);
  ------------------
  |  |   71|  15.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__
  |  |  ------------------
  ------------------
 1105|  15.7k|		return r;
 1106|  15.7k|	}
 1107|  8.43k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  8.43k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  8.43k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  8.43k|	int _ret = r; \
  |  |  |  |  155|  8.43k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 8.43k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  8.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|  5.80k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 5.80k, False: 2.63k]
  |  |  |  |  ------------------
  |  |  |  |  157|  8.43k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  8.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|  8.43k|	return _ret; \
  |  |  |  |  163|  8.43k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1108|  8.43k|}
_sc_card_add_algorithm:
 1111|  54.2k|{
 1112|  54.2k|	sc_algorithm_info_t *p;
 1113|       |
 1114|  54.2k|	if (info == NULL) {
  ------------------
  |  Branch (1114:6): [True: 0, False: 54.2k]
  ------------------
 1115|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1116|      0|	}
 1117|  54.2k|	p = (sc_algorithm_info_t *) realloc(card->algorithms, (card->algorithm_count + 1) * sizeof(*info));
 1118|  54.2k|	if (!p) {
  ------------------
  |  Branch (1118:6): [True: 0, False: 54.2k]
  ------------------
 1119|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1120|      0|	}
 1121|  54.2k|	card->algorithms = p;
 1122|  54.2k|	p += card->algorithm_count;
 1123|  54.2k|	card->algorithm_count++;
 1124|  54.2k|	*p = *info;
 1125|  54.2k|	return SC_SUCCESS;
  ------------------
  |  |   28|  54.2k|#define SC_SUCCESS				0
  ------------------
 1126|  54.2k|}
_sc_card_add_symmetric_alg:
 1130|  1.81k|{
 1131|  1.81k|	sc_algorithm_info_t info;
 1132|       |
 1133|  1.81k|	memset(&info, 0, sizeof(info));
 1134|  1.81k|	info.algorithm = algorithm;
 1135|  1.81k|	info.key_length = key_length;
 1136|  1.81k|	info.flags = flags;
 1137|       |
 1138|  1.81k|	return _sc_card_add_algorithm(card, &info);
 1139|  1.81k|}
_sc_card_add_ec_alg:
 1176|  9.93k|{
 1177|  9.93k|	return _sc_card_add_ec_alg_int(card, key_length, flags, ext_flags,
 1178|  9.93k|		curve_oid, SC_ALGORITHM_EC);
  ------------------
  |  |   70|  9.93k|#define SC_ALGORITHM_EC		2
  ------------------
 1179|  9.93k|}
_sc_card_add_eddsa_alg:
 1184|    259|{
 1185|       |	/* For simplicity, share the ec union with the curve information */
 1186|    259|	return _sc_card_add_ec_alg_int(card, key_length, flags, ext_flags,
 1187|    259|		curve_oid, SC_ALGORITHM_EDDSA);
  ------------------
  |  |   72|    259|#define SC_ALGORITHM_EDDSA		4
  ------------------
 1188|    259|}
_sc_card_add_xeddsa_alg:
 1193|  1.63k|{
 1194|       |	/* For simplicity, share the ec union with the curve information */
 1195|  1.63k|	return _sc_card_add_ec_alg_int(card, key_length, flags, ext_flags,
 1196|  1.63k|		curve_oid, SC_ALGORITHM_XEDDSA);
  ------------------
  |  |   73|  1.63k|#define SC_ALGORITHM_XEDDSA		5
  ------------------
 1197|  1.63k|}
sc_card_find_alg:
 1201|    243|{
 1202|    243|	int i;
 1203|       |
 1204|  1.23k|	for (i = 0; i < card->algorithm_count; i++) {
  ------------------
  |  Branch (1204:14): [True: 1.12k, False: 113]
  ------------------
 1205|  1.12k|		sc_algorithm_info_t *info = &card->algorithms[i];
 1206|       |
 1207|  1.12k|		if (param && (info->algorithm == SC_ALGORITHM_EC ||
  ------------------
  |  |   70|      0|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (1207:7): [True: 0, False: 1.12k]
  |  Branch (1207:17): [True: 0, False: 0]
  ------------------
 1208|      0|			info->algorithm == SC_ALGORITHM_EDDSA ||
  ------------------
  |  |   72|      0|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (1208:4): [True: 0, False: 0]
  ------------------
 1209|      0|			info->algorithm == SC_ALGORITHM_XEDDSA)) {
  ------------------
  |  |   73|      0|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (1209:4): [True: 0, False: 0]
  ------------------
 1210|      0|			if (sc_compare_oid((struct sc_object_id *)param, &info->u._ec.params.id))
  ------------------
  |  Branch (1210:8): [True: 0, False: 0]
  ------------------
 1211|      0|				return info;
 1212|  1.12k|		} else if (info->algorithm != algorithm) {
  ------------------
  |  Branch (1212:14): [True: 376, False: 747]
  ------------------
 1213|    376|			continue;
 1214|    747|		} else if (info->key_length == key_length)
  ------------------
  |  Branch (1214:14): [True: 130, False: 617]
  ------------------
 1215|    130|			return info;
 1216|  1.12k|	}
 1217|    113|	return NULL;
 1218|    243|}
sc_card_find_ec_alg:
 1222|     58|{
 1223|     58|	return sc_card_find_alg(card, SC_ALGORITHM_EC, key_length, curve_name);
  ------------------
  |  |   70|     58|#define SC_ALGORITHM_EC		2
  ------------------
 1224|     58|}
_sc_card_add_rsa_alg:
 1240|  40.4k|{
 1241|  40.4k|	sc_algorithm_info_t info;
 1242|       |
 1243|  40.4k|	memset(&info, 0, sizeof(info));
 1244|  40.4k|	info.algorithm = SC_ALGORITHM_RSA;
  ------------------
  |  |   69|  40.4k|#define SC_ALGORITHM_RSA		0
  ------------------
 1245|  40.4k|	info.key_length = key_length;
 1246|  40.4k|	info.flags = flags;
 1247|       |	/* disable particular PKCS1 v1.5 padding type if also RAW is supported on card */
 1248|  40.4k|	if ((info.flags & (SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_RAW)) == (SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_RAW)) {
  ------------------
  |  |  111|  40.4k|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|  40.4k|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|  40.4k|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
              	if ((info.flags & (SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_RAW)) == (SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_RAW)) {
  ------------------
  |  |  102|  40.4k|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
              	if ((info.flags & (SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_RAW)) == (SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_RAW)) {
  ------------------
  |  |  111|  40.4k|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|  40.4k|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|  40.4k|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
              	if ((info.flags & (SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_RAW)) == (SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_RAW)) {
  ------------------
  |  |  102|  40.4k|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
  |  Branch (1248:6): [True: 5.67k, False: 34.7k]
  ------------------
 1249|  5.67k|		if (card->ctx->disable_hw_pkcs1_padding & SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01)
  ------------------
  |  |  109|  5.67k|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  ------------------
  |  Branch (1249:7): [True: 0, False: 5.67k]
  ------------------
 1250|      0|			info.flags &= ~SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01;
  ------------------
  |  |  109|      0|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  ------------------
 1251|  5.67k|		if (card->ctx->disable_hw_pkcs1_padding & SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02)
  ------------------
  |  |  110|  5.67k|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  ------------------
  |  Branch (1251:7): [True: 5.67k, False: 0]
  ------------------
 1252|  5.67k|			info.flags &= ~SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02;
  ------------------
  |  |  110|  5.67k|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  ------------------
 1253|  5.67k|	}
 1254|  40.4k|	info.u._rsa.exponent = exponent;
 1255|       |
 1256|  40.4k|	return _sc_card_add_algorithm(card, &info);
 1257|  40.4k|}
sc_card_find_rsa_alg:
 1260|    185|{
 1261|    185|	return sc_card_find_alg(card, SC_ALGORITHM_RSA, key_length, NULL);
  ------------------
  |  |   69|    185|#define SC_ALGORITHM_RSA		0
  ------------------
 1262|    185|}
_sc_match_atr:
 1333|   370k|{
 1334|   370k|	int res;
 1335|       |
 1336|   370k|	if (card == NULL)
  ------------------
  |  Branch (1336:6): [True: 0, False: 370k]
  ------------------
 1337|      0|		return -1;
 1338|   370k|	res = match_atr_table(card->ctx, table, &card->atr);
 1339|   370k|	if (res < 0)
  ------------------
  |  Branch (1339:6): [True: 362k, False: 7.87k]
  ------------------
 1340|   362k|		return res;
 1341|  7.87k|	if (type_out != NULL)
  ------------------
  |  Branch (1341:6): [True: 7.29k, False: 583]
  ------------------
 1342|  7.29k|		*type_out = table[res].type;
 1343|  7.87k|	return res;
 1344|   370k|}
_sc_match_atr_block:
 1347|  13.2k|{
 1348|  13.2k|	struct sc_card_driver *drv;
 1349|  13.2k|	struct sc_atr_table *table;
 1350|  13.2k|	int res;
 1351|       |
 1352|  13.2k|	if (ctx == NULL)
  ------------------
  |  Branch (1352:6): [True: 0, False: 13.2k]
  ------------------
 1353|      0|		return NULL;
 1354|  13.2k|	if (driver) {
  ------------------
  |  Branch (1354:6): [True: 13.2k, False: 0]
  ------------------
 1355|  13.2k|		drv = driver;
 1356|  13.2k|		table = drv->atr_map;
 1357|  13.2k|		res = match_atr_table(ctx, table, atr);
 1358|  13.2k|		if (res < 0)
  ------------------
  |  Branch (1358:7): [True: 13.2k, False: 0]
  ------------------
 1359|  13.2k|			return NULL;
 1360|      0|		return table[res].card_atr;
 1361|  13.2k|	} else {
 1362|      0|		unsigned int i;
 1363|       |
 1364|      0|		for (i = 0; ctx->card_drivers[i] != NULL; i++) {
  ------------------
  |  Branch (1364:15): [True: 0, False: 0]
  ------------------
 1365|      0|			drv = ctx->card_drivers[i];
 1366|      0|			table = drv->atr_map;
 1367|      0|			res = match_atr_table(ctx, table, atr);
 1368|      0|			if (res < 0)
  ------------------
  |  Branch (1368:8): [True: 0, False: 0]
  ------------------
 1369|      0|				continue;
 1370|      0|			return table[res].card_atr;
 1371|      0|		}
 1372|      0|	}
 1373|      0|	return NULL;
 1374|  13.2k|}
sc_get_conf_block:
 1445|  36.3k|{
 1446|  36.3k|	int i;
 1447|  36.3k|	scconf_block *conf_block = NULL;
 1448|       |
 1449|  72.7k|	for (i = 0; ctx->conf_blocks[i] != NULL; i++) {
  ------------------
  |  Branch (1449:14): [True: 36.3k, False: 36.3k]
  ------------------
 1450|  36.3k|		scconf_block **blocks;
 1451|       |
 1452|  36.3k|		blocks = scconf_find_blocks(ctx->conf, ctx->conf_blocks[i], name1, name2);
 1453|  36.3k|		if (blocks != NULL) {
  ------------------
  |  Branch (1453:7): [True: 36.3k, False: 0]
  ------------------
 1454|  36.3k|			conf_block = blocks[0];
 1455|  36.3k|			free(blocks);
 1456|  36.3k|		}
 1457|  36.3k|		if (conf_block != NULL && priority)
  ------------------
  |  Branch (1457:7): [True: 0, False: 36.3k]
  |  Branch (1457:29): [True: 0, False: 0]
  ------------------
 1458|      0|			break;
 1459|  36.3k|	}
 1460|  36.3k|	return conf_block;
 1461|  36.3k|}
sc_clear_ec_params:
 1465|  16.8k|{
 1466|  16.8k|	if (ecp) {
  ------------------
  |  Branch (1466:6): [True: 16.8k, False: 0]
  ------------------
 1467|  16.8k|		free(ecp->named_curve);
 1468|  16.8k|		free(ecp->der.value);
 1469|  16.8k|		memset(ecp, 0, sizeof(struct sc_ec_parameters));
 1470|  16.8k|	}
 1471|  16.8k|	return;
 1472|  16.8k|}
sc_copy_ec_params:
 1475|  1.93k|{
 1476|  1.93k|	if (!dst || !src)
  ------------------
  |  Branch (1476:6): [True: 0, False: 1.93k]
  |  Branch (1476:14): [True: 0, False: 1.93k]
  ------------------
 1477|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1478|       |
 1479|  1.93k|	memset(dst, 0, sizeof(*dst));
 1480|  1.93k|	if (src->named_curve)   {
  ------------------
  |  Branch (1480:6): [True: 1.93k, False: 0]
  ------------------
 1481|  1.93k|		dst->named_curve = strdup(src->named_curve);
 1482|  1.93k|		if (!dst->named_curve)
  ------------------
  |  Branch (1482:7): [True: 0, False: 1.93k]
  ------------------
 1483|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1484|  1.93k|	}
 1485|  1.93k|	dst->id = src->id;
 1486|  1.93k|	if (src->der.value && src->der.len)   {
  ------------------
  |  Branch (1486:6): [True: 1.93k, False: 0]
  |  Branch (1486:24): [True: 1.93k, False: 0]
  ------------------
 1487|  1.93k|		dst->der.value = malloc(src->der.len);
 1488|  1.93k|		if (!dst->der.value) {
  ------------------
  |  Branch (1488:7): [True: 0, False: 1.93k]
  ------------------
 1489|      0|			free(dst->named_curve);
 1490|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1491|      0|		}
 1492|  1.93k|		memcpy(dst->der.value, src->der.value, src->der.len);
 1493|  1.93k|		dst->der.len = src->der.len;
 1494|  1.93k|	}
 1495|  1.93k|	dst->type = src->type;
 1496|  1.93k|	dst->field_length = src->field_length;
 1497|  1.93k|	dst->key_type = src->key_type;
 1498|       |
 1499|  1.93k|	return SC_SUCCESS;
  ------------------
  |  |   28|  1.93k|#define SC_SUCCESS				0
  ------------------
 1500|  1.93k|}
card.c:sc_card_new:
  127|  16.3k|{
  128|  16.3k|	sc_card_t *card;
  129|       |
  130|  16.3k|	if (ctx == NULL)
  ------------------
  |  Branch (130:6): [True: 0, False: 16.3k]
  ------------------
  131|      0|		return NULL;
  132|       |
  133|  16.3k|	card = calloc(1, sizeof(struct sc_card));
  134|  16.3k|	if (card == NULL)
  ------------------
  |  Branch (134:6): [True: 0, False: 16.3k]
  ------------------
  135|      0|		return NULL;
  136|  16.3k|	card->ops = malloc(sizeof(struct sc_card_operations));
  137|  16.3k|	if (card->ops == NULL) {
  ------------------
  |  Branch (137:6): [True: 0, False: 16.3k]
  ------------------
  138|      0|		free(card);
  139|      0|		return NULL;
  140|      0|	}
  141|       |
  142|  16.3k|	card->ctx = ctx;
  143|  16.3k|	if (sc_mutex_create(ctx, &card->mutex) != SC_SUCCESS) {
  ------------------
  |  |   28|  16.3k|#define SC_SUCCESS				0
  ------------------
  |  Branch (143:6): [True: 0, False: 16.3k]
  ------------------
  144|      0|		free(card->ops);
  145|      0|		free(card);
  146|      0|		return NULL;
  147|      0|	}
  148|       |
  149|  16.3k|	card->type = -1;
  150|  16.3k|	card->app_count = -1;
  151|       |
  152|  16.3k|	return card;
  153|  16.3k|}
card.c:sc_card_free:
  156|  16.3k|{
  157|  16.3k|	sc_free_apps(card);
  158|  16.3k|	sc_free_ef_atr(card);
  159|       |
  160|  16.3k|	free(card->ops);
  161|       |
  162|  16.3k|	if (card->algorithms != NULL)   {
  ------------------
  |  Branch (162:6): [True: 11.7k, False: 4.56k]
  ------------------
  163|  11.7k|		int i;
  164|  66.0k|		for (i=0; i<card->algorithm_count; i++)   {
  ------------------
  |  Branch (164:13): [True: 54.2k, False: 11.7k]
  ------------------
  165|  54.2k|			struct sc_algorithm_info *info = (card->algorithms + i);
  166|  54.2k|			if (info->algorithm == SC_ALGORITHM_EC ||
  ------------------
  |  |   70|   108k|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (166:8): [True: 9.93k, False: 44.2k]
  ------------------
  167|  44.2k|					info->algorithm == SC_ALGORITHM_EDDSA ||
  ------------------
  |  |   72|  98.5k|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (167:6): [True: 259, False: 44.0k]
  ------------------
  168|  44.0k|					info->algorithm == SC_ALGORITHM_XEDDSA) {
  ------------------
  |  |   73|  44.0k|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (168:6): [True: 1.63k, False: 42.4k]
  ------------------
  169|  11.8k|				sc_clear_ec_params(&info->u._ec.params);
  170|  11.8k|			}
  171|  54.2k|		}
  172|  11.7k|		free(card->algorithms);
  173|       |
  174|  11.7k|		card->algorithms = NULL;
  175|  11.7k|		card->algorithm_count = 0;
  176|  11.7k|	}
  177|       |
  178|  16.3k|	if (card->mutex != NULL) {
  ------------------
  |  Branch (178:6): [True: 0, False: 16.3k]
  ------------------
  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|  16.3k|	sc_mem_clear(card, sizeof(*card));
  184|  16.3k|	free(card);
  185|  16.3k|}
card.c:_sc_card_add_ec_alg_int:
 1146|  11.8k|{
 1147|  11.8k|	sc_algorithm_info_t info;
 1148|  11.8k|	int r;
 1149|       |
 1150|  11.8k|	memset(&info, 0, sizeof(info));
 1151|  11.8k|	sc_init_oid(&info.u._ec.params.id);
 1152|       |
 1153|  11.8k|	info.algorithm = algorithm;
 1154|  11.8k|	info.key_length = key_length;
 1155|  11.8k|	info.flags = flags;
 1156|       |
 1157|  11.8k|	info.u._ec.ext_flags = ext_flags;
 1158|  11.8k|	if (curve_oid) {
  ------------------
  |  Branch (1158:6): [True: 7.40k, False: 4.42k]
  ------------------
 1159|  7.40k|		info.u._ec.params.id = *curve_oid;
 1160|  7.40k|		r = sc_encode_oid(card->ctx, &info.u._ec.params.id, &info.u._ec.params.der.value, &info.u._ec.params.der.len);
 1161|  7.40k|		LOG_TEST_GOTO_ERR(card->ctx, r, "sc_encode_oid failed");
  ------------------
  |  |  184|  7.40k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  7.40k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  7.40k|	int _ret = (r); \
  |  |  |  |  178|  7.40k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 7.40k]
  |  |  |  |  ------------------
  |  |  |  |  179|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|  7.40k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 7.40k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1162|  7.40k|		r = sc_pkcs15_fix_ec_parameters(card->ctx, &info.u._ec.params);
 1163|  7.40k|		LOG_TEST_GOTO_ERR(card->ctx, r, "sc_pkcs15_fix_ec_parameters failed");
  ------------------
  |  |  184|  7.40k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  7.40k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  7.40k|	int _ret = (r); \
  |  |  |  |  178|  7.40k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 7.40k]
  |  |  |  |  ------------------
  |  |  |  |  179|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|  7.40k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 7.40k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1164|  7.40k|	}
 1165|       |
 1166|  11.8k|	r = _sc_card_add_algorithm(card, &info);
 1167|  11.8k|	return r;
 1168|      0|err:
 1169|      0|	sc_clear_ec_params(&info.u._ec.params);
 1170|      0|	return r;
 1171|  11.8k|}
card.c:match_atr_table:
 1270|   384k|{
 1271|   384k|	u8 *card_atr_bin;
 1272|   384k|	size_t card_atr_bin_len;
 1273|   384k|	char card_atr_hex[3 * SC_MAX_ATR_SIZE];
 1274|   384k|	size_t card_atr_hex_len;
 1275|   384k|	unsigned int i = 0;
 1276|       |
 1277|   384k|	if (ctx == NULL || table == NULL || atr == NULL)
  ------------------
  |  Branch (1277:6): [True: 0, False: 384k]
  |  Branch (1277:21): [True: 13.2k, False: 370k]
  |  Branch (1277:38): [True: 0, False: 370k]
  ------------------
 1278|  13.2k|		return -1;
 1279|   370k|	card_atr_bin = atr->value;
 1280|   370k|	card_atr_bin_len = atr->len;
 1281|   370k|	sc_bin_to_hex(card_atr_bin, card_atr_bin_len, card_atr_hex, sizeof(card_atr_hex), ':');
 1282|   370k|	card_atr_hex_len = strlen(card_atr_hex);
 1283|       |
 1284|   370k|	sc_debug(ctx, SC_LOG_DEBUG_MATCH, "ATR     : %s", card_atr_hex);
  ------------------
  |  |   70|   370k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1285|       |
 1286|  3.09M|	for (i = 0; table[i].atr != NULL; i++) {
  ------------------
  |  Branch (1286:14): [True: 2.72M, False: 362k]
  ------------------
 1287|  2.72M|		const char *tatr = table[i].atr;
 1288|  2.72M|		const char *matr = table[i].atrmask;
 1289|  2.72M|		size_t tatr_len = strlen(tatr);
 1290|  2.72M|		u8 mbin[SC_MAX_ATR_SIZE], tbin[SC_MAX_ATR_SIZE];
 1291|  2.72M|		size_t mbin_len, tbin_len, s, matr_len;
 1292|  2.72M|		size_t fix_hex_len = card_atr_hex_len;
 1293|  2.72M|		size_t fix_bin_len = card_atr_bin_len;
 1294|       |
 1295|  2.72M|		sc_debug(ctx, SC_LOG_DEBUG_MATCH, "ATR try : %s", tatr);
  ------------------
  |  |   70|  2.72M|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1296|       |
 1297|  2.72M|		if (tatr_len != fix_hex_len) {
  ------------------
  |  Branch (1297:7): [True: 2.65M, False: 68.1k]
  ------------------
 1298|  2.65M|			sc_debug(ctx, SC_LOG_DEBUG_MATCH, "ignored - wrong length");
  ------------------
  |  |   70|  2.65M|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1299|  2.65M|			continue;
 1300|  2.65M|		}
 1301|  68.1k|		if (matr != NULL) {
  ------------------
  |  Branch (1301:7): [True: 20.6k, False: 47.4k]
  ------------------
 1302|  20.6k|			sc_debug(ctx, SC_LOG_DEBUG_MATCH, "ATR mask: %s", matr);
  ------------------
  |  |   70|  20.6k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1303|       |
 1304|  20.6k|			matr_len = strlen(matr);
 1305|  20.6k|			if (tatr_len != matr_len)
  ------------------
  |  Branch (1305:8): [True: 0, False: 20.6k]
  ------------------
 1306|      0|				continue;
 1307|  20.6k|			tbin_len = sizeof(tbin);
 1308|  20.6k|			sc_hex_to_bin(tatr, tbin, &tbin_len);
 1309|  20.6k|			mbin_len = sizeof(mbin);
 1310|  20.6k|			sc_hex_to_bin(matr, mbin, &mbin_len);
 1311|  20.6k|			if (mbin_len != fix_bin_len) {
  ------------------
  |  Branch (1311:8): [True: 0, False: 20.6k]
  ------------------
 1312|      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__
  |  |  ------------------
  ------------------
 1313|      0|				continue;
 1314|      0|			}
 1315|   414k|			for (s = 0; s < tbin_len; s++) {
  ------------------
  |  Branch (1315:16): [True: 393k, False: 20.6k]
  ------------------
 1316|       |				/* reduce tatr with mask */
 1317|   393k|				tbin[s] = (tbin[s] & mbin[s]);
 1318|       |				/* create copy of card_atr_bin masked) */
 1319|   393k|				mbin[s] = (card_atr_bin[s] & mbin[s]);
 1320|   393k|			}
 1321|  20.6k|			if (memcmp(tbin, mbin, tbin_len) != 0)
  ------------------
  |  Branch (1321:8): [True: 17.3k, False: 3.35k]
  ------------------
 1322|  17.3k|				continue;
 1323|  47.4k|		} else {
 1324|  47.4k|			if (strncasecmp(tatr, card_atr_hex, tatr_len) != 0)
  ------------------
  |  Branch (1324:8): [True: 42.9k, False: 4.52k]
  ------------------
 1325|  42.9k|				continue;
 1326|  47.4k|		}
 1327|  7.87k|		return i;
 1328|  68.1k|	}
 1329|   362k|	return -1;
 1330|   370k|}
card.c:sc_card_sm_unload:
 1511|  13.2k|{
 1512|  13.2k|	if (card->sm_ctx.module.ops.module_cleanup)
  ------------------
  |  Branch (1512:6): [True: 0, False: 13.2k]
  ------------------
 1513|      0|		card->sm_ctx.module.ops.module_cleanup(card->ctx);
 1514|       |
 1515|  13.2k|	if (card->sm_ctx.module.handle)
  ------------------
  |  Branch (1515:6): [True: 0, False: 13.2k]
  ------------------
 1516|      0|		sc_dlclose(card->sm_ctx.module.handle);
 1517|       |	card->sm_ctx.module.handle = NULL;
 1518|  13.2k|	return 0;
 1519|  13.2k|}
card.c:sc_card_sm_check:
 1614|  13.2k|{
 1615|  13.2k|	const char *sm = NULL, *module_name = NULL, *module_path = NULL, *module_data = NULL, *sm_mode = NULL;
 1616|  13.2k|	struct sc_context *ctx = card->ctx;
 1617|  13.2k|	scconf_block *atrblock = NULL, *sm_conf_block = NULL;
 1618|  13.2k|	int rv, ii;
 1619|       |#ifdef _WIN32
 1620|       |	char temp_path[PATH_MAX];
 1621|       |	size_t temp_len = PATH_MAX - 1;
 1622|       |	char expanded_val[PATH_MAX];
 1623|       |	DWORD expanded_len = PATH_MAX;
 1624|       |#endif
 1625|       |
 1626|  13.2k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  13.2k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  13.2k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  13.2k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  13.2k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 13.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1627|       |
 1628|       |	/* get the name of card specific SM configuration section */
 1629|  13.2k|	atrblock = _sc_match_atr_block(ctx, card->driver, &card->atr);
 1630|  13.2k|	if (atrblock == NULL)
  ------------------
  |  Branch (1630:6): [True: 13.2k, False: 0]
  ------------------
 1631|  13.2k|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  13.2k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  13.2k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  13.2k|	int _ret = r; \
  |  |  |  |  155|  13.2k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 13.2k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  13.2k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 13.2k]
  |  |  |  |  ------------------
  |  |  |  |  157|  13.2k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  13.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|  13.2k|	return _ret; \
  |  |  |  |  163|  13.2k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1632|      0|	sm = scconf_get_str(atrblock, "secure_messaging", NULL);
 1633|      0|	if (!sm)
  ------------------
  |  Branch (1633:6): [True: 0, False: 0]
  ------------------
 1634|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1635|       |
 1636|       |	/* get SM configuration section by the name */
 1637|      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__
  |  |  ------------------
  ------------------
 1638|      0|        for (ii = 0; ctx->conf_blocks[ii]; ii++) {
  ------------------
  |  Branch (1638:22): [True: 0, False: 0]
  ------------------
 1639|      0|		scconf_block **blocks;
 1640|       |
 1641|      0|		blocks = scconf_find_blocks(ctx->conf, ctx->conf_blocks[ii], "secure_messaging", sm);
 1642|      0|		if (blocks) {
  ------------------
  |  Branch (1642:7): [True: 0, False: 0]
  ------------------
 1643|      0|			sm_conf_block = blocks[0];
 1644|      0|			free(blocks);
 1645|      0|		}
 1646|      0|		if (sm_conf_block != NULL)
  ------------------
  |  Branch (1646:7): [True: 0, False: 0]
  ------------------
 1647|      0|			break;
 1648|      0|	}
 1649|       |
 1650|      0|	if (!sm_conf_block)
  ------------------
  |  Branch (1650:6): [True: 0, False: 0]
  ------------------
 1651|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1652|       |
 1653|       |	/* check if an external SM module has to be used */
 1654|       |#ifdef _WIN32
 1655|       |	rv = sc_ctx_win32_get_config_value(NULL, "SmDir", "Software\\" OPENSC_VS_FF_COMPANY_NAME "\\OpenSC" OPENSC_ARCH_SUFFIX,
 1656|       |			temp_path, &temp_len);
 1657|       |	if (rv == SC_SUCCESS) {
 1658|       |		temp_path[temp_len] = '\0';
 1659|       |		module_path = temp_path;
 1660|       |	}
 1661|       |	expanded_len = ExpandEnvironmentStringsA(module_path, expanded_val, expanded_len);
 1662|       |	if (0 < expanded_len && expanded_len < sizeof expanded_val)
 1663|       |		module_path = expanded_val;
 1664|       |#else
 1665|      0|	module_path = scconf_get_str(sm_conf_block, "module_path", DEFAULT_SM_MODULE_PATH);
 1666|      0|#endif
 1667|      0|	module_name = scconf_get_str(sm_conf_block, "module_name", DEFAULT_SM_MODULE);
 1668|      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__
  |  |  ------------------
  ------------------
 1669|      0|	if (!module_name)
  ------------------
  |  Branch (1669:6): [True: 0, False: 0]
  ------------------
 1670|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1671|       |
 1672|      0|	rv = sc_card_sm_load(card, module_path, module_name);
 1673|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1674|       |
 1675|      0|	strlcpy(card->sm_ctx.module.filename, module_name, sizeof(card->sm_ctx.module.filename));
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
 1676|      0|	strlcpy(card->sm_ctx.config_section, sm, sizeof(card->sm_ctx.config_section));
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
 1677|       |
 1678|       |	/* allocate resources for the external SM module */
 1679|      0|	if (card->sm_ctx.module.ops.module_init)   {
  ------------------
  |  Branch (1679:6): [True: 0, False: 0]
  ------------------
 1680|      0|		module_data = scconf_get_str(sm_conf_block, "module_data", NULL);
 1681|       |
 1682|      0|		rv = card->sm_ctx.module.ops.module_init(ctx, module_data);
 1683|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1684|      0|	}
 1685|       |
 1686|       |	/* initialize SM session in the case of 'APDU TRANSMIT' SM mode */
 1687|      0|	sm_mode = scconf_get_str(sm_conf_block, "mode", NULL);
 1688|      0|	if (sm_mode && !strcasecmp("Transmit", sm_mode))   {
  ------------------
  |  Branch (1688:6): [True: 0, False: 0]
  |  Branch (1688:17): [True: 0, False: 0]
  ------------------
 1689|      0|		if (!card->sm_ctx.ops.open || !card->sm_ctx.ops.get_sm_apdu || !card->sm_ctx.ops.free_sm_apdu)
  ------------------
  |  Branch (1689:7): [True: 0, False: 0]
  |  Branch (1689:33): [True: 0, False: 0]
  |  Branch (1689:66): [True: 0, False: 0]
  ------------------
 1690|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1691|       |
 1692|      0|		card->sm_ctx.sm_mode = SM_MODE_TRANSMIT;
  ------------------
  |  |   47|      0|#define SM_MODE_TRANSMIT	0x200
  ------------------
 1693|      0|		rv = card->sm_ctx.ops.open(card);
 1694|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1695|      0|	}
 1696|       |
 1697|      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__
  |  |  ------------------
  ------------------
 1698|      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]
  |  |  ------------------
  ------------------
 1699|      0|}

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

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

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

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

sc_enum_apps:
  163|  6.64k|{
  164|  6.64k|	struct sc_context *ctx = card->ctx;
  165|  6.64k|	sc_path_t path;
  166|  6.64k|	int ef_structure;
  167|  6.64k|	size_t file_size, jj;
  168|  6.64k|	int r, ii, idx;
  169|  6.64k|	struct sc_file *ef_dir = NULL;
  170|       |
  171|  6.64k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  6.64k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  6.64k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  6.64k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  6.64k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 6.64k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  172|       |
  173|  6.64k|	sc_free_apps(card);
  174|  6.64k|	card->app_count = 0;
  175|       |
  176|  6.64k|	sc_format_path("3F002F00", &path);
  177|  6.64k|	r = sc_select_file(card, &path, &ef_dir);
  178|  6.64k|	if (r < 0)
  ------------------
  |  Branch (178:6): [True: 5.82k, False: 820]
  ------------------
  179|  5.82k|		sc_file_free(ef_dir);
  180|  6.64k|	LOG_TEST_RET(ctx, r, "Cannot select EF.DIR file");
  ------------------
  |  |  174|  6.64k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  6.64k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  6.64k|	int _ret = (r); \
  |  |  |  |  168|  6.64k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 5.82k, False: 820]
  |  |  |  |  ------------------
  |  |  |  |  169|  5.82k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.82k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  5.82k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  5.82k|		return _ret; \
  |  |  |  |  172|  5.82k|	} \
  |  |  |  |  173|  6.64k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 820]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  181|       |
  182|    820|	if (ef_dir->type != SC_FILE_TYPE_WORKING_EF) {
  ------------------
  |  |  216|    820|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (182:6): [True: 336, False: 484]
  ------------------
  183|    336|		sc_file_free(ef_dir);
  184|    336|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_CARD, "EF(DIR) is not a working EF.");
  ------------------
  |  |  174|    336|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    336|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    336|	int _ret = (r); \
  |  |  |  |  168|    336|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 336, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    336|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    336|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    336|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    336|		return _ret; \
  |  |  |  |  172|    336|	} \
  |  |  |  |  173|    336|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  185|    336|	}
  186|       |
  187|    484|	ef_structure = ef_dir->ef_structure;
  188|    484|	file_size = ef_dir->size;
  189|    484|	sc_file_free(ef_dir);
  190|    484|	if (ef_structure == SC_FILE_EF_TRANSPARENT) {
  ------------------
  |  |  221|    484|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (190:6): [True: 332, False: 152]
  ------------------
  191|    332|		u8 *buf = NULL, *p;
  192|    332|		size_t bufsize;
  193|       |
  194|    332|		if (file_size == 0)
  ------------------
  |  Branch (194:7): [True: 32, False: 300]
  ------------------
  195|    332|			LOG_FUNC_RETURN(ctx, 0);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  196|    300|		if (file_size > MAX_FILE_SIZE)
  ------------------
  |  |  220|    300|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (196:7): [True: 33, False: 267]
  ------------------
  197|    300|			LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  164|     33|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     33|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     33|	int _ret = r; \
  |  |  |  |  155|     33|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 33, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     33|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     33|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 33, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     33|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     33|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     33|	return _ret; \
  |  |  |  |  163|     33|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  198|       |
  199|    267|		buf = malloc(file_size);
  200|    267|		if (buf == NULL)
  ------------------
  |  Branch (200:7): [True: 0, False: 267]
  ------------------
  201|    267|			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|    267|		p = buf;
  203|    267|		r = sc_read_binary(card, 0, buf, file_size, 0);
  204|    267|		if (r < 0) {
  ------------------
  |  Branch (204:7): [True: 49, False: 218]
  ------------------
  205|     49|			free(buf);
  206|     49|			LOG_TEST_RET(ctx, r, "sc_read_binary() 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: 49, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     49|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     49|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     49|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     49|		return _ret; \
  |  |  |  |  172|     49|	} \
  |  |  |  |  173|     49|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  207|     49|		}
  208|    218|		bufsize = r;
  209|    329|		while (bufsize > 0) {
  ------------------
  |  Branch (209:10): [True: 228, False: 101]
  ------------------
  210|    228|			if (card->app_count == SC_MAX_CARD_APPS) {
  ------------------
  |  |   33|    228|#define SC_MAX_CARD_APPS		8
  ------------------
  |  Branch (210:8): [True: 0, False: 228]
  ------------------
  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|    228|			r = parse_dir_record(card, &p, &bufsize, -1);
  215|    228|			if (r)
  ------------------
  |  Branch (215:8): [True: 117, False: 111]
  ------------------
  216|    117|				break;
  217|    228|		}
  218|    218|		if (buf)
  ------------------
  |  Branch (218:7): [True: 218, False: 0]
  ------------------
  219|    218|			free(buf);
  220|       |
  221|    218|	}
  222|    152|	else {	/* record structure */
  223|    152|		unsigned char buf[256], *p;
  224|    152|		unsigned int rec_nr;
  225|    152|		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|    566|		for (rec_nr = 1; rec_nr < 16; rec_nr++) {
  ------------------
  |  Branch (229:20): [True: 563, False: 3]
  ------------------
  230|    563|			r = sc_read_record(card, rec_nr, 0, buf, sizeof(buf), SC_RECORD_BY_REC_NR);
  ------------------
  |  | 1298|    563|#define SC_RECORD_BY_REC_NR		0x00100UL
  ------------------
  231|    563|			if (r == SC_ERROR_RECORD_NOT_FOUND)
  ------------------
  |  |   52|    563|#define SC_ERROR_RECORD_NOT_FOUND		-1202
  ------------------
  |  Branch (231:8): [True: 1, False: 562]
  ------------------
  232|      1|				break;
  233|    562|			LOG_TEST_RET(ctx, r, "read_record() failed");
  ------------------
  |  |  174|    562|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    562|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    562|	int _ret = (r); \
  |  |  |  |  168|    562|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 148, False: 414]
  |  |  |  |  ------------------
  |  |  |  |  169|    148|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    148|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    148|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    148|		return _ret; \
  |  |  |  |  172|    148|	} \
  |  |  |  |  173|    562|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 414]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  234|       |
  235|    414|			if (card->app_count == SC_MAX_CARD_APPS) {
  ------------------
  |  |   33|    414|#define SC_MAX_CARD_APPS		8
  ------------------
  |  Branch (235:8): [True: 0, False: 414]
  ------------------
  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|    414|			rec_size = r;
  241|    414|			p = buf;
  242|    414|			parse_dir_record(card, &p, &rec_size, (int)rec_nr);
  243|    414|		}
  244|    152|	}
  245|       |
  246|       |	/* Move known PKCS#15 applications to the head of the list */
  247|    333|	for (ii=0, idx=0; ii<card->app_count; ii++)   {
  ------------------
  |  Branch (247:20): [True: 111, False: 222]
  ------------------
  248|    930|		for (jj=0; jj < sizeof(apps)/sizeof(apps[0]); jj++) {
  ------------------
  |  Branch (248:14): [True: 831, False: 99]
  ------------------
  249|    831|			if (apps[jj].aid_len != card->app[ii]->aid.len)
  ------------------
  |  Branch (249:8): [True: 752, False: 79]
  ------------------
  250|    752|				continue;
  251|     79|			if (memcmp(apps[jj].aid, card->app[ii]->aid.value, apps[jj].aid_len))
  ------------------
  |  Branch (251:8): [True: 67, False: 12]
  ------------------
  252|     67|				continue;
  253|     12|			break;
  254|     79|		}
  255|       |
  256|    111|		if (ii != idx && jj < sizeof(apps)/sizeof(apps[0]))   {
  ------------------
  |  Branch (256:7): [True: 45, False: 66]
  |  Branch (256:20): [True: 10, False: 35]
  ------------------
  257|     10|			struct sc_app_info *tmp = card->app[idx];
  258|       |
  259|     10|			card->app[idx] = card->app[ii];
  260|     10|			card->app[ii] = tmp;
  261|     10|			idx++;
  262|     10|		}
  263|    111|	}
  264|       |
  265|    222|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    222|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    222|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    222|	int _ret = r; \
  |  |  |  |  155|    222|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 222, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    222|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 222]
  |  |  |  |  ------------------
  |  |  |  |  157|    222|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    222|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    222|	return _ret; \
  |  |  |  |  163|    222|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  266|    222|}
sc_free_apps:
  269|  23.3k|{
  270|  23.3k|	int	i;
  271|       |
  272|  23.5k|	for (i = 0; i < card->app_count; i++) {
  ------------------
  |  Branch (272:14): [True: 193, False: 23.3k]
  ------------------
  273|    193|		free(card->app[i]->label);
  274|    193|		free(card->app[i]->ddo.value);
  275|    193|		free(card->app[i]);
  276|    193|	}
  277|  23.3k|	card->app_count = -1;
  278|  23.3k|}
sc_update_dir:
  402|     42|{
  403|     42|	sc_path_t path;
  404|     42|	sc_file_t *file;
  405|     42|	int r;
  406|       |
  407|     42|	sc_format_path("3F002F00", &path);
  408|       |
  409|     42|	r = sc_select_file(card, &path, &file);
  410|     42|	LOG_TEST_RET(card->ctx, r, "unable to select EF(DIR)");
  ------------------
  |  |  174|     42|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     42|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     42|	int _ret = (r); \
  |  |  |  |  168|     42|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 40]
  |  |  |  |  ------------------
  |  |  |  |  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|     42|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 40]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  411|       |
  412|     40|	if (file->ef_structure == SC_FILE_EF_TRANSPARENT)
  ------------------
  |  |  221|     40|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (412:6): [True: 37, False: 3]
  ------------------
  413|     37|		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|     40|	sc_file_free(file);
  419|     40|	return r;
  420|     42|}
dir.c:parse_dir_record:
   65|    642|{
   66|    642|	struct sc_context *ctx = card->ctx;
   67|    642|	struct sc_asn1_entry asn1_dirrecord[5], asn1_dir[2];
   68|    642|	scconf_block *conf_block = NULL;
   69|    642|	sc_app_info_t *app = NULL;
   70|    642|	struct sc_aid aid;
   71|    642|	u8 label[128], path[128], ddo[128];
   72|    642|	size_t label_len = sizeof(label) - 1, path_len = sizeof(path), ddo_len = sizeof(ddo);
   73|    642|	int r;
   74|       |
   75|    642|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    642|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    642|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    642|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    642|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 642]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   76|    642|	aid.len = sizeof(aid.value);
   77|       |
   78|    642|	memset(label, 0, sizeof(label));
   79|    642|	sc_copy_asn1_entry(c_asn1_dirrecord, asn1_dirrecord);
   80|    642|	sc_copy_asn1_entry(c_asn1_dir, asn1_dir);
   81|    642|	sc_format_asn1_entry(asn1_dir + 0, asn1_dirrecord, NULL, 0);
   82|    642|	sc_format_asn1_entry(asn1_dirrecord + 0, aid.value, &aid.len, 0);
   83|    642|	sc_format_asn1_entry(asn1_dirrecord + 1, label, &label_len, 0);
   84|    642|	sc_format_asn1_entry(asn1_dirrecord + 2, path, &path_len, 0);
   85|    642|	sc_format_asn1_entry(asn1_dirrecord + 3, ddo, &ddo_len, 0);
   86|       |
   87|    642|	r = sc_asn1_decode(ctx, asn1_dir, *buf, *buflen, (const u8 **) buf, buflen);
   88|    642|	if (r == SC_ERROR_ASN1_END_OF_CONTENTS)
  ------------------
  |  |   84|    642|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (88:6): [True: 121, False: 521]
  ------------------
   89|    642|		LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   90|    521|	LOG_TEST_RET(ctx, r, "EF(DIR) parsing failed");
  ------------------
  |  |  174|    521|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    521|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    521|	int _ret = (r); \
  |  |  |  |  168|    521|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 368, False: 153]
  |  |  |  |  ------------------
  |  |  |  |  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|    521|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 153]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   91|       |
   92|    153|	conf_block = sc_get_conf_block(ctx, "framework", "pkcs15", 1);
   93|    153|	if (conf_block)   {
  ------------------
  |  Branch (93:6): [True: 0, False: 153]
  ------------------
   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|    153|	app = calloc(1, sizeof(struct sc_app_info));
  112|    153|	if (app == NULL)
  ------------------
  |  Branch (112:6): [True: 0, False: 153]
  ------------------
  113|    153|		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|    153|	memcpy(&app->aid, &aid, sizeof(struct sc_aid));
  116|       |
  117|    153|	if (asn1_dirrecord[1].flags & SC_ASN1_PRESENT)
  ------------------
  |  |  147|    153|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (117:6): [True: 19, False: 134]
  ------------------
  118|     19|		app->label = strdup((char *) label);
  119|    134|	else
  120|    134|		app->label = NULL;
  121|       |
  122|    153|	if (asn1_dirrecord[2].flags & SC_ASN1_PRESENT && path_len > 0) {
  ------------------
  |  |  147|    306|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (122:6): [True: 24, False: 129]
  |  Branch (122:51): [True: 12, False: 12]
  ------------------
  123|       |		/* application path present: ignore AID */
  124|     12|		if (path_len > SC_MAX_PATH_SIZE) {
  ------------------
  |  |   47|     12|#define SC_MAX_PATH_SIZE		16
  ------------------
  |  Branch (124:7): [True: 2, False: 10]
  ------------------
  125|      2|			free(app->label);
  126|      2|			free(app);
  127|      2|			LOG_TEST_RET(ctx, SC_ERROR_INVALID_ASN1_OBJECT, "Application path is too long.");
  ------------------
  |  |  174|      2|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      2|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      2|	int _ret = (r); \
  |  |  |  |  168|      2|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      2|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      2|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      2|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      2|		return _ret; \
  |  |  |  |  172|      2|	} \
  |  |  |  |  173|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  128|      2|		}
  129|     10|		memcpy(app->path.value, path, path_len);
  130|     10|		app->path.len = path_len;
  131|     10|		app->path.type = SC_PATH_TYPE_PATH;
  ------------------
  |  |  119|     10|#define SC_PATH_TYPE_PATH		2
  ------------------
  132|     10|	}
  133|    141|	else {
  134|       |		/* application path not present: use AID as application path */
  135|    141|		memcpy(app->path.value, aid.value, aid.len);
  136|    141|		app->path.len = aid.len;
  137|    141|		app->path.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|    141|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  138|    141|	}
  139|       |
  140|    151|	if (asn1_dirrecord[3].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|    151|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (140:6): [True: 54, False: 97]
  ------------------
  141|     54|		app->ddo.value = malloc(ddo_len);
  142|     54|		if (app->ddo.value == NULL) {
  ------------------
  |  Branch (142:7): [True: 0, False: 54]
  ------------------
  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|     54|		memcpy(app->ddo.value, ddo, ddo_len);
  148|     54|		app->ddo.len = ddo_len;
  149|     97|	} else {
  150|     97|		app->ddo.value = NULL;
  151|     97|		app->ddo.len = 0;
  152|     97|	}
  153|       |
  154|    151|	app->rec_nr = rec_nr;
  155|    151|	card->app[card->app_count] = app;
  156|    151|	card->app_count++;
  157|       |
  158|    151|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    151|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    151|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    151|	int _ret = r; \
  |  |  |  |  155|    151|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 151, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    151|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 151]
  |  |  |  |  ------------------
  |  |  |  |  157|    151|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    151|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    151|	return _ret; \
  |  |  |  |  163|    151|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  159|    151|}
dir.c:update_transparent:
  309|     37|{
  310|     37|	u8 *rec, *buf = NULL, *tmp;
  311|     37|	size_t rec_size, buf_size = 0;
  312|     37|	int i, r;
  313|       |
  314|     73|	for (i = 0; i < card->app_count; i++) {
  ------------------
  |  Branch (314:14): [True: 37, False: 36]
  ------------------
  315|     37|		r = encode_dir_record(card->ctx, card->app[i], &rec, &rec_size);
  316|     37|		if (r) {
  ------------------
  |  Branch (316:7): [True: 1, False: 36]
  ------------------
  317|      1|			if (buf)
  ------------------
  |  Branch (317:8): [True: 0, False: 1]
  ------------------
  318|      0|				free(buf);
  319|      1|			return r;
  320|      1|		}
  321|     36|		if (!rec_size)
  ------------------
  |  Branch (321:7): [True: 0, False: 36]
  ------------------
  322|      0|			continue;
  323|     36|		tmp = (u8 *) realloc(buf, buf_size + rec_size);
  324|     36|		if (!tmp) {
  ------------------
  |  Branch (324:7): [True: 0, False: 36]
  ------------------
  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|     36|		buf = tmp;
  332|     36|		memcpy(buf + buf_size, rec, rec_size);
  333|     36|		buf_size += rec_size;
  334|     36|		free(rec);
  335|     36|		rec=NULL;
  336|     36|	}
  337|     36|	if (file->size > buf_size) {
  ------------------
  |  Branch (337:6): [True: 10, False: 26]
  ------------------
  338|     10|		tmp = (u8 *) realloc(buf, file->size);
  339|     10|		if (!tmp) {
  ------------------
  |  Branch (339:7): [True: 0, False: 10]
  ------------------
  340|      0|			free(buf);
  341|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  342|      0|		}
  343|     10|		buf = tmp;
  344|     10|		memset(buf + buf_size, 0, file->size - buf_size);
  345|     10|		buf_size = file->size;
  346|     10|	}
  347|     36|	r = sc_update_binary(card, 0, buf, buf_size, 0);
  348|     36|	free(buf);
  349|     36|	LOG_TEST_RET(card->ctx, r, "Unable to update EF(DIR)");
  ------------------
  |  |  174|     36|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     36|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     36|	int _ret = (r); \
  |  |  |  |  168|     36|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 28, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  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|     36|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  350|       |
  351|      8|	return SC_SUCCESS;
  ------------------
  |  |   28|      8|#define SC_SUCCESS				0
  ------------------
  352|     36|}
dir.c:encode_dir_record:
  282|     40|{
  283|     40|	struct sc_asn1_entry asn1_dirrecord[5], asn1_dir[2];
  284|     40|	sc_app_info_t   tapp = *app;
  285|     40|	int r;
  286|     40|	size_t label_len;
  287|       |
  288|     40|	sc_copy_asn1_entry(c_asn1_dirrecord, asn1_dirrecord);
  289|     40|	sc_copy_asn1_entry(c_asn1_dir, asn1_dir);
  290|     40|	sc_format_asn1_entry(asn1_dir + 0, asn1_dirrecord, NULL, 1);
  291|     40|	sc_format_asn1_entry(asn1_dirrecord + 0, (void *) tapp.aid.value, (void *) &tapp.aid.len, 1);
  292|     40|	if (tapp.label != NULL) {
  ------------------
  |  Branch (292:6): [True: 40, False: 0]
  ------------------
  293|     40|		label_len = strlen(tapp.label);
  294|     40|		sc_format_asn1_entry(asn1_dirrecord + 1, tapp.label, &label_len, 1);
  295|     40|	}
  296|     40|	if (tapp.path.len)
  ------------------
  |  Branch (296:6): [True: 39, False: 1]
  ------------------
  297|     39|		sc_format_asn1_entry(asn1_dirrecord + 2, (void *) tapp.path.value,
  298|     39|				     (void *) &tapp.path.len, 1);
  299|     40|	if (tapp.ddo.value != NULL && tapp.ddo.len)
  ------------------
  |  Branch (299:6): [True: 0, False: 40]
  |  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|     40|	r = sc_asn1_encode(ctx, asn1_dir, buf, buflen);
  303|     40|	LOG_TEST_RET(ctx, r, "Encode DIR record error");
  ------------------
  |  |  174|     40|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     40|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     40|	int _ret = (r); \
  |  |  |  |  168|     40|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 38]
  |  |  |  |  ------------------
  |  |  |  |  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|     40|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 38]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  304|       |
  305|     38|	return SC_SUCCESS;
  ------------------
  |  |   28|     38|#define SC_SUCCESS				0
  ------------------
  306|     40|}
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);
  ------------------
  |  | 1298|      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);
  ------------------
  |  | 1298|      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:
  135|  2.06k|{
  136|  2.06k|	struct sc_context *ctx = card->ctx;
  137|  2.06k|	struct sc_path path;
  138|  2.06k|	struct sc_file *file = NULL;
  139|  2.06k|	int rv;
  140|  2.06k|	unsigned char *buf = NULL;
  141|  2.06k|	size_t size;
  142|  2.06k|	size_t off = 0;
  143|       |
  144|  2.06k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  2.06k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  2.06k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  2.06k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  2.06k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2.06k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  145|       |
  146|  2.06k|	sc_format_path("3F002F01", &path);
  147|  2.06k|	rv = sc_select_file(card, &path, &file);
  148|  2.06k|	LOG_TEST_GOTO_ERR(ctx, rv, "Cannot select EF(ATR) file");
  ------------------
  |  |  184|  2.06k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  2.06k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  2.06k|	int _ret = (r); \
  |  |  |  |  178|  2.06k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 1.20k, False: 860]
  |  |  |  |  ------------------
  |  |  |  |  179|  1.20k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  1.20k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|  1.20k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|  1.20k|		goto err; \
  |  |  |  |  182|  1.20k|	} \
  |  |  |  |  183|  2.06k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 860]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  149|       |
  150|    860|	if (file->size) {
  ------------------
  |  Branch (150:6): [True: 45, False: 815]
  ------------------
  151|     45|		size = file->size;
  152|    815|	} else {
  153|    815|		size = 1024;
  154|    815|	}
  155|    860|	buf = malloc(size);
  156|    860|	if (!buf) {
  ------------------
  |  Branch (156:6): [True: 0, False: 860]
  ------------------
  157|      0|		rv = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  158|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  159|      0|	}
  160|    860|	rv = sc_read_binary(card, 0, buf, size, 0);
  161|    860|	LOG_TEST_GOTO_ERR(ctx, rv, "Cannot read EF(ATR) file");
  ------------------
  |  |  184|    860|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    860|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    860|	int _ret = (r); \
  |  |  |  |  178|    860|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 178, False: 682]
  |  |  |  |  ------------------
  |  |  |  |  179|    178|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    178|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    178|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    178|		goto err; \
  |  |  |  |  182|    178|	} \
  |  |  |  |  183|    860|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 682]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  162|       |
  163|       |	/* Workaround: Some cards seem to have a buggy storage of the EF.ATR */
  164|    682|	if ((card->type == SC_CARD_TYPE_IASECC_CPX) ||
  ------------------
  |  Branch (164:6): [True: 9, False: 673]
  ------------------
  165|    673|	    (card->type == SC_CARD_TYPE_IASECC_CPXCL)) {
  ------------------
  |  Branch (165:6): [True: 27, False: 646]
  ------------------
  166|       |		/* Let's keep the first byte */
  167|     36|		if ((rv > 1) &&
  ------------------
  |  Branch (167:7): [True: 33, False: 3]
  ------------------
  168|     33|		    (buf[0] == ISO7816_II_CATEGORY_TLV))
  ------------------
  |  |   28|     33|#define ISO7816_II_CATEGORY_TLV		0x80
  ------------------
  |  Branch (168:7): [True: 15, False: 18]
  ------------------
  169|     15|			off++;
  170|     36|	}
  171|    682|	rv = sc_parse_ef_atr_content(card, buf + off, rv - off);
  172|    682|	LOG_TEST_GOTO_ERR(ctx, rv, "EF(ATR) parse error");
  ------------------
  |  |  184|    682|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    682|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    682|	int _ret = (r); \
  |  |  |  |  178|    682|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 20, False: 662]
  |  |  |  |  ------------------
  |  |  |  |  179|     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
  |  |  |  |  ------------------
  |  |  |  |  180|     20|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     20|		goto err; \
  |  |  |  |  182|     20|	} \
  |  |  |  |  183|    682|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 662]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  173|       |
  174|    662|	rv = SC_SUCCESS;
  ------------------
  |  |   28|    662|#define SC_SUCCESS				0
  ------------------
  175|       |
  176|  2.06k|err:
  177|  2.06k|	sc_file_free(file);
  178|  2.06k|	free(buf);
  179|  2.06k|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|  2.06k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.06k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.06k|	int _ret = r; \
  |  |  |  |  155|  2.06k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.06k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.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.40k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.40k, False: 662]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.06k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.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|  2.06k|	return _ret; \
  |  |  |  |  163|  2.06k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  180|  2.06k|}
sc_free_ef_atr:
  183|  16.3k|{
  184|  16.3k|	if (card->ef_atr)
  ------------------
  |  Branch (184:6): [True: 712, False: 15.6k]
  ------------------
  185|    712|		free(card->ef_atr);
  186|       |	card->ef_atr = NULL;
  187|  16.3k|}
ef-atr.c:sc_parse_ef_atr_content:
   36|    682|{
   37|    682|	struct sc_context *ctx = card->ctx;
   38|    682|	const unsigned char *tag = NULL;
   39|    682|	size_t taglen;
   40|    682|	struct sc_ef_atr ef_atr;
   41|       |
   42|    682|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    682|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    682|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    682|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    682|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 682]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   43|       |
   44|    682|	memset(&ef_atr, 0, sizeof(struct sc_ef_atr));
   45|       |
   46|    682|	tag = sc_asn1_find_tag(ctx, buf, buflen, ISO7816_TAG_II_CARD_SERVICE, &taglen);
  ------------------
  |  |   31|    682|#define ISO7816_TAG_II_CARD_SERVICE		0x43
  ------------------
   47|    682|	if (tag && taglen >= 1)   {
  ------------------
  |  Branch (47:6): [True: 5, False: 677]
  |  Branch (47:13): [True: 3, False: 2]
  ------------------
   48|      3|		ef_atr.card_service = *tag;
   49|      3|		sc_log(ctx, "EF.ATR: card service 0x%X", ef_atr.card_service);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
   50|      3|	}
   51|       |
   52|    682|	tag = sc_asn1_find_tag(ctx, buf, buflen, ISO7816_TAG_II_PRE_ISSUING, &taglen);
  ------------------
  |  |   34|    682|#define ISO7816_TAG_II_PRE_ISSUING		0x46
  ------------------
   53|    682|	if (tag) {
  ------------------
  |  Branch (53:6): [True: 499, False: 183]
  ------------------
   54|    499|		size_t len = taglen > sizeof(ef_atr.pre_issuing) ? sizeof(ef_atr.pre_issuing) : taglen;
  ------------------
  |  Branch (54:16): [True: 19, False: 480]
  ------------------
   55|       |
   56|    499|		memcpy(ef_atr.pre_issuing, tag, len);
   57|    499|		ef_atr.pre_issuing_len = len;
   58|       |
   59|    499|		sc_log(ctx, "EF.ATR: Pre-Issuing data '%s'", sc_dump_hex(ef_atr.pre_issuing, ef_atr.pre_issuing_len));
  ------------------
  |  |   71|    499|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   60|    499|	}
   61|       |
   62|    682|	tag = sc_asn1_find_tag(ctx, buf, buflen, ISO7816_TAG_II_CARD_CAPABILITIES, &taglen);
  ------------------
  |  |   35|    682|#define ISO7816_TAG_II_CARD_CAPABILITIES	0x47
  ------------------
   63|    682|	if (tag && taglen >= 3) {
  ------------------
  |  Branch (63:6): [True: 3, False: 679]
  |  Branch (63:13): [True: 1, False: 2]
  ------------------
   64|      1|		ef_atr.df_selection =  *(tag + 0);
   65|      1|		ef_atr.unit_size = *(tag + 1);
   66|      1|		ef_atr.card_capabilities = *(tag + 2);
   67|      1|		sc_log(ctx, "EF.ATR: DF selection %X, unit_size %zX, card caps %X",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
   68|      1|				ef_atr.df_selection, ef_atr.unit_size, ef_atr.card_capabilities);
   69|      1|	}
   70|       |
   71|    682|	if (ef_atr.card_capabilities & ISO7816_CAP_EXTENDED_LENGTH_INFO) {
  ------------------
  |  |   45|    682|#define ISO7816_CAP_EXTENDED_LENGTH_INFO	0x20
  ------------------
  |  Branch (71:6): [True: 1, False: 681]
  ------------------
   72|       |		/* Extended Length Information in EF.ATR/INFO */
   73|      1|		tag = sc_asn1_find_tag(ctx, buf, buflen, ISO7816_TAG_II_EXTENDED_LENGTH, &taglen);
  ------------------
  |  |   41|      1|#define ISO7816_TAG_II_EXTENDED_LENGTH		0x7F66
  ------------------
   74|      1|		if (tag && taglen >= 8) {
  ------------------
  |  Branch (74:7): [True: 0, False: 1]
  |  Branch (74:14): [True: 0, False: 0]
  ------------------
   75|       |			/* The command- and response-APDU size limitations are defined by
   76|       |			 * two integers, each nested in a DO'02'.
   77|       |			 * We skip parsing the nested DOs and jump directly to the numbers */
   78|      0|			ef_atr.max_command_apdu = bebytes2ushort(tag + 2);
   79|      0|			ef_atr.max_response_apdu = bebytes2ushort(tag + 6);
   80|      0|			sc_log(ctx, "EF.ATR: Biggest command APDU %zu bytes, response APDU %zu",
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   81|      0|					ef_atr.max_command_apdu, ef_atr.max_response_apdu);
   82|      0|		}
   83|      1|	}
   84|       |
   85|    682|	tag = sc_asn1_find_tag(ctx, buf, buflen, ISO7816_TAG_II_AID, &taglen);
  ------------------
  |  |   36|    682|#define ISO7816_TAG_II_AID			0x4F
  ------------------
   86|    682|	if (tag) {
  ------------------
  |  Branch (86:6): [True: 33, False: 649]
  ------------------
   87|     33|		if (taglen > sizeof(ef_atr.aid.value))
  ------------------
  |  Branch (87:7): [True: 2, False: 31]
  ------------------
   88|     33|			LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid MF AID size");
  ------------------
  |  |  174|      2|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      2|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      2|	int _ret = (r); \
  |  |  |  |  168|      2|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      2|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      2|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      2|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      2|		return _ret; \
  |  |  |  |  172|      2|	} \
  |  |  |  |  173|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   89|     31|		memcpy(ef_atr.aid.value, tag, taglen);
   90|     31|		ef_atr.aid.len = taglen;
   91|     31|		sc_log(ctx, "EF.ATR: AID '%s'", sc_dump_hex(ef_atr.aid.value, ef_atr.aid.len));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
   92|     31|	}
   93|       |
   94|       |	/* IAS/ECC specific issuer data: contains the max send/recv buffer sizes in plain and SM modes */
   95|    680|	tag = sc_asn1_find_tag(ctx, buf, buflen, IASECC_TAG_II_IO_BUFFER_SIZES, &taglen);
  ------------------
  |  |   48|    680|#define IASECC_TAG_II_IO_BUFFER_SIZES		0xE0
  ------------------
   96|    680|	if (tag) {
  ------------------
  |  Branch (96:6): [True: 518, False: 162]
  ------------------
   97|    518|		size_t len = taglen > sizeof(ef_atr.issuer_data) ? sizeof(ef_atr.issuer_data) : taglen;
  ------------------
  |  Branch (97:16): [True: 399, False: 119]
  ------------------
   98|       |
   99|    518|		memcpy(ef_atr.issuer_data, tag, len);
  100|    518|		ef_atr.issuer_data_len = len;
  101|       |
  102|    518|		sc_log(ctx, "EF.ATR: Issuer data '%s'", sc_dump_hex(ef_atr.issuer_data, ef_atr.issuer_data_len));
  ------------------
  |  |   71|    518|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  103|    518|	}
  104|       |
  105|    680|	tag = sc_asn1_find_tag(ctx, buf, buflen, ISO7816_TAG_II_ALLOCATION_SCHEME, &taglen);
  ------------------
  |  |   37|    680|#define ISO7816_TAG_II_ALLOCATION_SCHEME        0x78
  ------------------
  106|    680|	if (tag)   {
  ------------------
  |  Branch (106:6): [True: 52, False: 628]
  ------------------
  107|     52|		sc_log(ctx, "EF.ATR: DER encoded OID %s", sc_dump_hex(tag, taglen));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  108|     52|		tag = sc_asn1_find_tag(ctx, tag, taglen, SC_ASN1_TAG_OBJECT, &taglen);
  ------------------
  |  |  200|     52|#define SC_ASN1_TAG_OBJECT		6
  ------------------
  109|     52|		if (tag)   {
  ------------------
  |  Branch (109:7): [True: 43, False: 9]
  ------------------
  110|     43|			sc_log(ctx, "EF.ATR: OID %s", sc_dump_hex(tag, taglen));
  ------------------
  |  |   71|     43|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  111|     43|			if(sc_asn1_decode_object_id(tag, taglen, &ef_atr.allocation_oid))
  ------------------
  |  Branch (111:7): [True: 18, False: 25]
  ------------------
  112|     43|				LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ASN1_OBJECT);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  113|     43|		}
  114|     52|	}
  115|       |
  116|    662|	tag = sc_asn1_find_tag(ctx, buf, buflen, ISO7816_TAG_II_STATUS_SW, &taglen);
  ------------------
  |  |   39|    662|#define ISO7816_TAG_II_STATUS_SW		0x82
  ------------------
  117|    662|	if (tag && taglen == 2)   {
  ------------------
  |  Branch (117:6): [True: 40, False: 622]
  |  Branch (117:13): [True: 12, False: 28]
  ------------------
  118|     12|		ef_atr.status = *(tag + 0) * 0x100 + *(tag + 1);
  119|     12|		sc_log(ctx, "EF.ATR: status word 0x%X", ef_atr.status);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  120|     12|	}
  121|       |
  122|    662|	if (!card->ef_atr)
  ------------------
  |  Branch (122:6): [True: 578, False: 84]
  ------------------
  123|    578|		card->ef_atr = calloc(1, sizeof(struct sc_ef_atr));
  124|       |
  125|    662|	if (!card->ef_atr)
  ------------------
  |  Branch (125:6): [True: 0, False: 662]
  ------------------
  126|    662|		LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  127|       |
  128|    662|	memcpy(card->ef_atr, &ef_atr, sizeof(struct sc_ef_atr));
  129|       |
  130|    662|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    662|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    662|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    662|	int _ret = r; \
  |  |  |  |  155|    662|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 662, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    662|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 662]
  |  |  |  |  ------------------
  |  |  |  |  157|    662|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    662|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    662|	return _ret; \
  |  |  |  |  163|    662|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  131|    662|}

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

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

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

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

iasecc_sm_initialize:
  270|     73|{
  271|     73|	struct sc_context *ctx = card->ctx;
  272|     73|#ifdef ENABLE_SM
  273|     73|	struct sm_info *sm_info = &card->sm_ctx.info;
  274|     73|	struct sm_cwa_session *cwa_session = &sm_info->session.cwa;
  275|     73|	struct sc_remote_data rdata;
  276|     73|	int rv;
  277|       |
  278|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  279|       |
  280|     73|	strlcpy(sm_info->config_section, card->sm_ctx.config_section, sizeof(sm_info->config_section));
  ------------------
  |  |   43|     73|#define strlcpy _strlcpy
  ------------------
  281|     73|	sm_info->cmd = cmd;
  282|     73|	sm_info->serialnr = card->serialnr;
  283|     73|	sm_info->card_type = card->type;
  284|     73|	sm_info->sm_type = SM_TYPE_CWA14890;
  ------------------
  |  |   39|     73|#define SM_TYPE_CWA14890	0x400
  ------------------
  285|       |
  286|     73|	rv = iasecc_sm_se_mutual_authentication(card, se_num);
  287|     73|	LOG_TEST_RET(ctx, rv, "iasecc_sm_initialize() MUTUAL AUTHENTICATION failed");
  ------------------
  |  |  174|     73|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     73|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     73|	int _ret = (r); \
  |  |  |  |  168|     73|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 73, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     73|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     73|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     73|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     73|		return _ret; \
  |  |  |  |  172|     73|	} \
  |  |  |  |  173|     73|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  288|       |
  289|      0|	rv = sc_get_challenge(card, cwa_session->card_challenge, SM_SMALL_CHALLENGE_LEN);
  ------------------
  |  |   85|      0|#define SM_SMALL_CHALLENGE_LEN	8
  ------------------
  290|      0|	LOG_TEST_RET(ctx, rv, "iasecc_sm_initialize() GET CHALLENGE failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  291|       |
  292|      0|	sc_remote_data_init(&rdata);
  293|       |
  294|      0|	rv = sm_save_sc_context(card, sm_info);
  295|      0|	LOG_TEST_RET(ctx, rv, "iasecc_sm_initialize() cannot save current context");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  296|       |
  297|      0|	if (!card->sm_ctx.module.ops.initialize)
  ------------------
  |  Branch (297:6): [True: 0, False: 0]
  ------------------
  298|      0|		LOG_TEST_RET(ctx, SC_ERROR_SM_NOT_INITIALIZED, "iasecc_sm_initialize() no SM module");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  299|      0|	rv = card->sm_ctx.module.ops.initialize(ctx, sm_info, &rdata);
  300|      0|	LOG_TEST_RET(ctx, rv, "iasecc_sm_initialize() INITIALIZE failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  301|       |
  302|       |
  303|      0|	if (rdata.length == 1)   {
  ------------------
  |  Branch (303:6): [True: 0, False: 0]
  ------------------
  304|      0|		rdata.data->flags |= SC_REMOTE_APDU_FLAG_RETURN_ANSWER;
  ------------------
  |  |  386|      0|#define SC_REMOTE_APDU_FLAG_RETURN_ANSWER	0x02
  ------------------
  305|      0|		rdata.data->apdu.flags &= ~SC_APDU_FLAGS_NO_GET_RESP;
  ------------------
  |  |  308|      0|#define SC_APDU_FLAGS_NO_GET_RESP	0x00000002UL
  ------------------
  306|      0|	}
  307|      0|	else   {
  308|      0|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "TODO: SM init with more then one APDU");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  309|      0|	}
  310|       |
  311|      0|	cwa_session->mdata_len = sizeof(cwa_session->mdata);
  312|      0|	rv = iasecc_sm_transmit_apdus (card, &rdata, cwa_session->mdata, &cwa_session->mdata_len);
  313|      0|	if (rv == SC_ERROR_PIN_CODE_INCORRECT)
  ------------------
  |  |   64|      0|#define SC_ERROR_PIN_CODE_INCORRECT		-1214
  ------------------
  |  Branch (313:6): [True: 0, False: 0]
  ------------------
  314|      0|		sc_log(ctx, "SM initialization failed, %i tries left", (rdata.data + rdata.length - 1)->apdu.sw2 & 0x0F);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  315|      0|	LOG_TEST_RET(ctx, rv, "iasecc_sm_initialize() transmit APDUs failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  316|       |
  317|      0|	rdata.free(&rdata);
  318|       |
  319|      0|	sc_log(ctx, "MA data(len:%zu) '%s'", cwa_session->mdata_len,
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  320|      0|			sc_dump_hex(cwa_session->mdata, cwa_session->mdata_len));
  321|      0|	if (cwa_session->mdata_len != 0x48)
  ------------------
  |  Branch (321:6): [True: 0, False: 0]
  ------------------
  322|      0|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "iasecc_sm_initialize() invalid MUTUAL AUTHENTICATE result data");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  323|       |
  324|      0|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  325|       |#else
  326|       |	LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "built without support of Secure-Messaging");
  327|       |	return SC_ERROR_NOT_SUPPORTED;
  328|       |#endif
  329|      0|}
iasecc_sm_create_file:
  551|      2|{
  552|      2|	struct sc_context *ctx = card->ctx;
  553|      2|#ifdef ENABLE_SM
  554|      2|	struct sm_info *sm_info = &card->sm_ctx.info;
  555|      2|	struct sc_remote_data rdata;
  556|      2|	struct iasecc_sm_cmd_create_file cmd_data;
  557|      2|	int rv;
  558|       |
  559|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  560|      2|	sc_log(ctx, "iasecc_sm_create_file() SE#%i, fcp(%zu) '%s'", se_num, fcp_len, sc_dump_hex(fcp, fcp_len));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  561|       |
  562|      2|	rv = iasecc_sm_initialize(card, se_num, SM_CMD_FILE_CREATE);
  ------------------
  |  |   58|      2|#define SM_CMD_FILE_CREATE		0x203
  ------------------
  563|      2|	LOG_TEST_RET(ctx, rv, "iasecc_sm_create_file() SM INITIALIZE 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  564|       |
  565|      0|	cmd_data.data = fcp;
  566|      0|	cmd_data.size = fcp_len;
  567|      0|	sm_info->cmd_data = &cmd_data;
  568|       |
  569|      0|	sc_remote_data_init(&rdata);
  570|      0|	rv= iasecc_sm_cmd(card, &rdata);
  571|      0|	LOG_TEST_RET(ctx, rv, "iasecc_sm_create_file() SM '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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  572|       |
  573|      0|	rv = sm_release (card, &rdata, NULL, 0);
  574|      0|	LOG_TEST_RET(ctx, rv, "iasecc_sm_create_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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  575|       |
  576|      0|	rdata.free(&rdata);
  577|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  578|       |#else
  579|       |	LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "built without support of Secure-Messaging");
  580|       |	return SC_ERROR_NOT_SUPPORTED;
  581|       |#endif
  582|      0|}
iasecc_sm_read_binary:
  586|     69|{
  587|     69|	struct sc_context *ctx = card->ctx;
  588|     69|#ifdef ENABLE_SM
  589|     69|	struct sm_info *sm_info = &card->sm_ctx.info;
  590|     69|	struct sc_remote_data rdata;
  591|     69|	struct iasecc_sm_cmd_update_binary cmd_data;
  592|     69|	int rv;
  593|       |
  594|     69|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     69|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     69|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     69|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     69|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 69]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  595|     69|	sc_log(ctx, "SM read binary: acl:%X, offs:%zu, count:%zu", se_num, offs, count);
  ------------------
  |  |   71|     69|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  596|       |
  597|     69|	rv = iasecc_sm_initialize(card, se_num, SM_CMD_FILE_READ);
  ------------------
  |  |   56|     69|#define SM_CMD_FILE_READ		0x201
  ------------------
  598|     69|	LOG_TEST_RET(ctx, rv, "iasecc_sm_read_binary() SM INITIALIZE 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  599|       |
  600|      0|	cmd_data.offs = offs;
  601|      0|	cmd_data.count = count;
  602|      0|	sm_info->cmd_data = &cmd_data;
  603|       |
  604|      0|	sc_remote_data_init(&rdata);
  605|      0|	rv = iasecc_sm_cmd(card, &rdata);
  606|      0|	LOG_TEST_RET(ctx, rv, "iasecc_sm_read_binary() SM 'READ BINARY' failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  607|       |
  608|      0|	sc_log(ctx, "IAS/ECC decode answer() rdata length %i", rdata.length);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  609|       |
  610|      0|	rv = sm_release (card, &rdata, buff, count);
  611|      0|	LOG_TEST_RET(ctx, rv, "iasecc_sm_read_binary() SM release failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  612|       |
  613|      0|	rdata.free(&rdata);
  614|      0|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  615|       |#else
  616|       |	LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "built without support of Secure-Messaging");
  617|       |	return SC_ERROR_NOT_SUPPORTED;
  618|       |#endif
  619|      0|}
iasecc_sm_delete_file:
  662|      2|{
  663|      2|	struct sc_context *ctx = card->ctx;
  664|      2|#ifdef ENABLE_SM
  665|      2|	struct sm_info *sm_info = &card->sm_ctx.info;
  666|      2|	struct sc_remote_data rdata;
  667|      2|	int rv;
  668|       |
  669|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  670|      2|	sc_log(ctx, "SM delete file: SE#:%X, file-id:%X", se_num, file_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__
  |  |  ------------------
  ------------------
  671|       |
  672|      2|	rv = iasecc_sm_initialize(card, se_num, SM_CMD_FILE_DELETE);
  ------------------
  |  |   59|      2|#define SM_CMD_FILE_DELETE		0x204
  ------------------
  673|      2|	LOG_TEST_RET(ctx, rv, "iasecc_sm_delete_file() SM INITIALIZE 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  674|       |
  675|      0|	sm_info->cmd_data = (void *)(uintptr_t)file_id;
  676|       |
  677|      0|	sc_remote_data_init(&rdata);
  678|      0|	rv = iasecc_sm_cmd(card, &rdata);
  679|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  680|       |
  681|      0|	rv = sm_release (card, &rdata, NULL, 0);
  682|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  683|       |
  684|      0|	rdata.free(&rdata);
  685|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  686|       |#else
  687|       |	LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "built without support of Secure-Messaging");
  688|       |	return SC_ERROR_NOT_SUPPORTED;
  689|       |#endif
  690|      0|}
iasecc-sm.c:iasecc_sm_se_mutual_authentication:
  222|     73|{
  223|     73|	struct sc_context *ctx = card->ctx;
  224|     73|	struct sm_info *sm_info = &card->sm_ctx.info;
  225|     73|	struct iasecc_se_info se;
  226|     73|	struct sc_crt *crt =  &sm_info->session.cwa.params.crt_at;
  227|     73|	struct sc_apdu apdu;
  228|     73|	unsigned char sbuf[0x100];
  229|     73|	int rv, offs;
  230|       |
  231|     73|	memset(&se, 0, sizeof(se));
  232|       |
  233|     73|	se.reference = se_num;
  234|     73|	crt->usage = IASECC_UQB_AT_MUTUAL_AUTHENTICATION;
  ------------------
  |  |  127|     73|#define IASECC_UQB_AT_MUTUAL_AUTHENTICATION	0xC0
  ------------------
  235|     73|	crt->tag = IASECC_CRT_TAG_AT;
  ------------------
  |  |  104|     73|#define IASECC_CRT_TAG_AT	0xA4
  ------------------
  236|       |
  237|     73|	rv = iasecc_se_get_info(card, &se);
  238|     73|	LOG_TEST_RET(ctx, rv, "Get SE info error");
  ------------------
  |  |  174|     73|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     73|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     73|	int _ret = (r); \
  |  |  |  |  168|     73|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 63, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  169|     63|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     63|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     63|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     63|		return _ret; \
  |  |  |  |  172|     63|	} \
  |  |  |  |  173|     73|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  239|       |
  240|     10|	rv = iasecc_se_get_crt(card, &se, crt);
  241|     10|	sc_file_free(se.df);
  242|     10|	LOG_TEST_RET(ctx, rv, "Cannot get authentication CRT");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  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|  21.6k|{
   37|  21.6k|	if (card == NULL || apdu == NULL) {
  ------------------
  |  Branch (37:6): [True: 0, False: 21.6k]
  |  Branch (37:22): [True: 0, False: 21.6k]
  ------------------
   38|      0|		return;
   39|      0|	}
   40|       |
   41|  21.6k|	if (apdu->lc > sc_get_max_send_size(card)) {
  ------------------
  |  Branch (41:6): [True: 119, False: 21.5k]
  ------------------
   42|       |		/* The lower layers will automatically do chaining */
   43|    119|		apdu->flags |= SC_APDU_FLAGS_CHAINING;
  ------------------
  |  |  306|    119|#define SC_APDU_FLAGS_CHAINING		0x00000001UL
  ------------------
   44|    119|	}
   45|       |
   46|  21.6k|	if (apdu->le > sc_get_max_recv_size(card)) {
  ------------------
  |  Branch (46:6): [True: 591, False: 21.0k]
  ------------------
   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|    591|		apdu->le = sc_get_max_recv_size(card);
   50|    591|	}
   51|  21.6k|}
encode_do_data:
  177|  3.49k|{
  178|  3.49k|	unsigned char offset_buffer[2];
  179|  3.49k|	size_t offset_buffer_len = sizeof offset_buffer;
  180|  3.49k|	struct sc_asn1_entry asn1_do_data[sizeof c_asn1_do_data / sizeof *c_asn1_do_data];
  181|  3.49k|	sc_copy_asn1_entry(c_asn1_do_data, asn1_do_data);
  182|       |
  183|  3.49k|	if (idx > 0xFFFF)
  ------------------
  |  Branch (183:6): [True: 0, False: 3.49k]
  ------------------
  184|  3.49k|		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|  3.49k|	offset_buffer[0] = (u8) (idx >> 8);
  186|  3.49k|	offset_buffer[1] = (u8) (idx & 0x00FF);
  187|  3.49k|	sc_format_asn1_entry(asn1_do_data + 0, offset_buffer, &offset_buffer_len, 1);
  188|       |
  189|  3.49k|	if (data && data_len) {
  ------------------
  |  Branch (189:6): [True: 0, False: 3.49k]
  |  Branch (189:14): [True: 0, False: 0]
  ------------------
  190|      0|		sc_format_asn1_entry(asn1_do_data + 1, (void *) &data, &data_len, 1);
  191|  3.49k|	} else {
  192|  3.49k|		sc_format_asn1_entry(asn1_do_data + 1, NULL, NULL, 0);
  193|  3.49k|	}
  194|       |
  195|  3.49k|	LOG_TEST_RET(ctx,
  ------------------
  |  |  174|  3.49k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  3.49k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  3.49k|	int _ret = (r); \
  |  |  |  |  168|  3.49k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 3.49k]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#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.49k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3.49k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  196|  3.49k|			sc_asn1_encode(ctx, asn1_do_data, out, outlen),
  197|  3.49k|			"sc_asn1_encode() failed");
  198|       |
  199|  3.49k|	return SC_SUCCESS;
  ------------------
  |  |   28|  3.49k|#define SC_SUCCESS				0
  ------------------
  200|  3.49k|}
decode_do_data:
  205|  2.28k|{
  206|  2.28k|	struct sc_asn1_entry asn1_do_data[sizeof c_asn1_do_data / sizeof *c_asn1_do_data];
  207|  2.28k|	sc_copy_asn1_entry(c_asn1_do_data, asn1_do_data);
  208|       |
  209|  2.28k|	sc_format_asn1_entry(asn1_do_data + 0, NULL, NULL, 0);
  210|  2.28k|	sc_format_asn1_entry(asn1_do_data + 1, out, outlen, 0);
  211|       |
  212|  2.28k|	LOG_TEST_RET(ctx,
  ------------------
  |  |  174|  2.28k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.28k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.28k|	int _ret = (r); \
  |  |  |  |  168|  2.28k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 77, False: 2.20k]
  |  |  |  |  ------------------
  |  |  |  |  169|     77|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     77|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     77|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     77|		return _ret; \
  |  |  |  |  172|     77|	} \
  |  |  |  |  173|  2.28k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.20k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  213|  2.20k|			sc_asn1_decode(ctx, asn1_do_data, encoded_data, encoded_data_len, NULL, NULL),
  214|  2.20k|			"sc_asn1_decode() failed");
  215|       |
  216|  2.20k|	if (!(asn1_do_data[1].flags & SC_ASN1_PRESENT))
  ------------------
  |  |  147|  2.20k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (216:6): [True: 1.89k, False: 315]
  ------------------
  217|  1.89k|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|  1.89k|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  218|       |
  219|    315|	return SC_SUCCESS;
  ------------------
  |  |   28|    315|#define SC_SUCCESS				0
  ------------------
  220|  2.20k|}
iso7816_build_pin_apdu:
 1183|  1.90k|{
 1184|  1.90k|	int r, len = 0, pad = 0, use_pin_pad = 0, ins, p1 = 0;
 1185|  1.90k|	int cse = SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|  1.90k|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1186|       |
 1187|  1.90k|	switch (data->pin_type) {
 1188|  1.89k|	case SC_AC_CHV:
  ------------------
  |  |  151|  1.89k|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (1188:2): [True: 1.89k, False: 6]
  ------------------
 1189|       |		/* fall through */
 1190|  1.89k|	case SC_AC_SESSION:
  ------------------
  |  |  159|  1.89k|#define SC_AC_SESSION			0x00000100 /* Session PIN */
  ------------------
  |  Branch (1190:2): [True: 0, False: 1.90k]
  ------------------
 1191|  1.89k|	case SC_AC_CONTEXT_SPECIFIC:
  ------------------
  |  |  160|  1.89k|#define SC_AC_CONTEXT_SPECIFIC		0x00000200 /* Context specific login */
  ------------------
  |  Branch (1191:2): [True: 0, False: 1.90k]
  ------------------
 1192|  1.89k|		break;
 1193|      6|	default:
  ------------------
  |  Branch (1193:2): [True: 6, False: 1.89k]
  ------------------
 1194|      6|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      6|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1195|  1.90k|	}
 1196|       |
 1197|  1.89k|	if (data->flags & SC_PIN_CMD_NEED_PADDING)
  ------------------
  |  |  422|  1.89k|#define SC_PIN_CMD_NEED_PADDING		0x0002
  ------------------
  |  Branch (1197:6): [True: 484, False: 1.41k]
  ------------------
 1198|    484|		pad = 1;
 1199|  1.89k|	if (data->flags & SC_PIN_CMD_USE_PINPAD)
  ------------------
  |  |  421|  1.89k|#define SC_PIN_CMD_USE_PINPAD		0x0001
  ------------------
  |  Branch (1199:6): [True: 0, False: 1.89k]
  ------------------
 1200|      0|		use_pin_pad = 1;
 1201|       |
 1202|  1.89k|	data->pin1.offset = 5;
 1203|       |
 1204|  1.89k|	switch (data->cmd) {
 1205|      8|	case SC_PIN_CMD_VERIFY:
  ------------------
  |  |  415|      8|#define SC_PIN_CMD_VERIFY	0
  ------------------
  |  Branch (1205:2): [True: 8, False: 1.89k]
  ------------------
 1206|      8|		ins = 0x20;
 1207|       |		/* detect overloaded APDU with SC_PIN_CMD_GET_INFO */
 1208|      8|		if (data->pin1.len == 0 && !use_pin_pad)
  ------------------
  |  Branch (1208:7): [True: 0, False: 8]
  |  Branch (1208:30): [True: 0, False: 0]
  ------------------
 1209|      0|			return SC_ERROR_INVALID_PIN_LENGTH;
  ------------------
  |  |   77|      0|#define SC_ERROR_INVALID_PIN_LENGTH		-1304
  ------------------
 1210|      8|		if ((r = sc_build_pin(buf, buf_len, &data->pin1, pad)) < 0)
  ------------------
  |  Branch (1210:7): [True: 0, False: 8]
  ------------------
 1211|      0|			return r;
 1212|      8|		len = r;
 1213|      8|		break;
 1214|    155|	case SC_PIN_CMD_CHANGE:
  ------------------
  |  |  416|    155|#define SC_PIN_CMD_CHANGE	1
  ------------------
  |  Branch (1214:2): [True: 155, False: 1.74k]
  ------------------
 1215|    155|		ins = 0x24;
 1216|    155|		if (data->pin1.len != 0 || (use_pin_pad && !( data->flags & SC_PIN_CMD_IMPLICIT_CHANGE))) {
  ------------------
  |  |  423|      0|#define SC_PIN_CMD_IMPLICIT_CHANGE	0x0004
  ------------------
  |  Branch (1216:7): [True: 0, False: 155]
  |  Branch (1216:31): [True: 0, False: 155]
  |  Branch (1216:46): [True: 0, False: 0]
  ------------------
 1217|      0|			if ((r = sc_build_pin(buf, buf_len, &data->pin1, pad)) < 0)
  ------------------
  |  Branch (1217:8): [True: 0, False: 0]
  ------------------
 1218|      0|				return r;
 1219|      0|			len += r;
 1220|      0|		}
 1221|    155|		else {
 1222|       |			/* implicit test */
 1223|    155|			p1 = 1;
 1224|    155|		}
 1225|       |
 1226|    155|		data->pin2.offset = data->pin1.offset + len;
 1227|    155|		if ((r = sc_build_pin(buf+len, buf_len-len, &data->pin2, pad)) < 0)
  ------------------
  |  Branch (1227:7): [True: 0, False: 155]
  ------------------
 1228|      0|			return r;
 1229|       |		/* Special case - where provided the old PIN on the command line
 1230|       |		 * but expect the new one to be entered on the keypad.
 1231|       |		 */
 1232|    155|		if (data->pin1.len && data->pin2.len == 0) {
  ------------------
  |  Branch (1232:7): [True: 0, False: 155]
  |  Branch (1232:25): [True: 0, False: 0]
  ------------------
 1233|      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__
  |  |  ------------------
  ------------------
 1234|      0|			data->flags |= SC_PIN_CMD_IMPLICIT_CHANGE;
  ------------------
  |  |  423|      0|#define SC_PIN_CMD_IMPLICIT_CHANGE	0x0004
  ------------------
 1235|      0|		};
 1236|    155|		len += r;
 1237|    155|		break;
 1238|      0|	case SC_PIN_CMD_UNBLOCK:
  ------------------
  |  |  417|      0|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (1238:2): [True: 0, False: 1.89k]
  ------------------
 1239|      0|		ins = 0x2C;
 1240|      0|		if (data->pin1.len != 0 || (use_pin_pad && !( data->flags & SC_PIN_CMD_IMPLICIT_CHANGE))) {
  ------------------
  |  |  423|      0|#define SC_PIN_CMD_IMPLICIT_CHANGE	0x0004
  ------------------
  |  Branch (1240:7): [True: 0, False: 0]
  |  Branch (1240:31): [True: 0, False: 0]
  |  Branch (1240:46): [True: 0, False: 0]
  ------------------
 1241|      0|			if ((r = sc_build_pin(buf, buf_len, &data->pin1, pad)) < 0)
  ------------------
  |  Branch (1241:8): [True: 0, False: 0]
  ------------------
 1242|      0|				return r;
 1243|      0|			len += r;
 1244|      0|		} else {
 1245|      0|			p1 |= 0x02;
 1246|      0|		}
 1247|       |
 1248|      0|		if (data->pin2.len != 0 || use_pin_pad) {
  ------------------
  |  Branch (1248:7): [True: 0, False: 0]
  |  Branch (1248:30): [True: 0, False: 0]
  ------------------
 1249|      0|			data->pin2.offset = data->pin1.offset + len;
 1250|      0|			if ((r = sc_build_pin(buf+len, buf_len-len, &data->pin2, pad)) < 0)
  ------------------
  |  Branch (1250:8): [True: 0, False: 0]
  ------------------
 1251|      0|				return r;
 1252|      0|			len += r;
 1253|      0|		} else {
 1254|      0|			p1 |= 0x01;
 1255|      0|		}
 1256|      0|		if (p1 == 0x03) {
  ------------------
  |  Branch (1256:7): [True: 0, False: 0]
  ------------------
 1257|       |			/* No data to send or to receive */
 1258|      0|			cse = SC_APDU_CASE_1;
  ------------------
  |  |  291|      0|#define SC_APDU_CASE_1			0x01
  ------------------
 1259|      0|		}
 1260|      0|		break;
 1261|  1.73k|	case SC_PIN_CMD_GET_INFO:
  ------------------
  |  |  418|  1.73k|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (1261:2): [True: 1.73k, False: 163]
  ------------------
 1262|  1.73k|		ins = 0x20;
 1263|       |		/* No data to send or to receive */
 1264|  1.73k|		cse = SC_APDU_CASE_1;
  ------------------
  |  |  291|  1.73k|#define SC_APDU_CASE_1			0x01
  ------------------
 1265|  1.73k|		break;
 1266|      0|	default:
  ------------------
  |  Branch (1266:2): [True: 0, False: 1.89k]
  ------------------
 1267|      0|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1268|  1.89k|	}
 1269|       |
 1270|  1.89k|	sc_format_apdu(card, apdu, cse, ins, p1, data->pin_reference);
 1271|  1.89k|	apdu->lc = len;
 1272|  1.89k|	apdu->datalen = len;
 1273|  1.89k|	apdu->data = buf;
 1274|  1.89k|	apdu->resplen = 0;
 1275|       |
 1276|  1.89k|	return 0;
 1277|  1.89k|}
iso7816_select_aid:
 1395|  10.7k|{
 1396|  10.7k|	struct sc_context *ctx = card->ctx;
 1397|  10.7k|	struct sc_apdu apdu;
 1398|  10.7k|	int rv;
 1399|       |
 1400|  10.7k|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  10.7k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  10.7k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  10.7k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 10.7k]
  |  |  ------------------
  ------------------
 1401|       |
 1402|  10.7k|	sc_format_apdu(card, &apdu, resp == NULL ? SC_APDU_CASE_3_SHORT : SC_APDU_CASE_4_SHORT, 0xA4, 0x04, resp == NULL ? 0x0C : 0x00);
  ------------------
  |  |  293|  6.36k|#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|  4.40k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  |  Branch (1402:30): [True: 6.36k, False: 4.40k]
  |  Branch (1402:102): [True: 6.36k, False: 4.40k]
  ------------------
 1403|  10.7k|	apdu.lc = reqlen;
 1404|  10.7k|	apdu.data = req;
 1405|  10.7k|	apdu.datalen = reqlen;
 1406|  10.7k|	apdu.resp = resp;
 1407|  10.7k|	apdu.resplen = resp == NULL ? 0 : *resplen;
  ------------------
  |  Branch (1407:17): [True: 6.36k, False: 4.40k]
  ------------------
 1408|  10.7k|	apdu.le = resp == NULL ? 0 : 256;
  ------------------
  |  Branch (1408:12): [True: 6.36k, False: 4.40k]
  ------------------
 1409|       |
 1410|  10.7k|	rv = sc_transmit_apdu(card, &apdu);
 1411|  10.7k|	if (resplen)
  ------------------
  |  Branch (1411:6): [True: 4.40k, False: 6.36k]
  ------------------
 1412|  4.40k|		*resplen = apdu.resplen;
 1413|  10.7k|	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|  10.7k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  10.7k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  10.7k|	int _ret = (r); \
  |  |  |  |  168|  10.7k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 89, False: 10.6k]
  |  |  |  |  ------------------
  |  |  |  |  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|  10.7k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 10.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1414|       |
 1415|  10.6k|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1416|  10.6k|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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|  7.65k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 7.65k, False: 3.02k]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1417|  10.6k|}
sc_get_iso7816_driver:
 1485|   521k|{
 1486|   521k|	return &iso_driver;
 1487|   521k|}
iso7816.c:no_match:
 1431|  9.15k|{
 1432|  9.15k|	return 0;
 1433|  9.15k|}
iso7816.c:iso7816_update_binary:
  404|  1.39k|{
  405|  1.39k|	struct sc_apdu apdu;
  406|  1.39k|	int r;
  407|       |
  408|  1.39k|	if (idx > 0x7fff) {
  ------------------
  |  Branch (408:6): [True: 1, False: 1.39k]
  ------------------
  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|  1.39k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3, 0xD6, (idx >> 8) & 0x7F, idx & 0xFF);
  ------------------
  |  |  302|  1.39k|#define SC_APDU_CASE_3			0x23
  ------------------
  414|  1.39k|	apdu.lc = count;
  415|  1.39k|	apdu.datalen = count;
  416|  1.39k|	apdu.data = buf;
  417|       |
  418|  1.39k|	iso7816_fixup_transceive_length(card, &apdu);
  419|  1.39k|	r = sc_transmit_apdu(card, &apdu);
  420|  1.39k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  1.39k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.39k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.39k|	int _ret = (r); \
  |  |  |  |  168|  1.39k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 1.38k]
  |  |  |  |  ------------------
  |  |  |  |  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.39k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.38k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  421|  1.38k|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  422|  1.38k|	LOG_TEST_RET(card->ctx, r, "Card returned error");
  ------------------
  |  |  174|  1.38k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.38k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.38k|	int _ret = (r); \
  |  |  |  |  168|  1.38k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 113, False: 1.27k]
  |  |  |  |  ------------------
  |  |  |  |  169|    113|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    113|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    113|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    113|		return _ret; \
  |  |  |  |  172|    113|	} \
  |  |  |  |  173|  1.38k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.27k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  423|       |
  424|  1.27k|	LOG_FUNC_RETURN(card->ctx, (int)count);
  ------------------
  |  |  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: 0, False: 1.27k]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define 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.27k|	} else { \
  |  |  |  |  159|  1.27k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  1.27k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  1.27k|	} \
  |  |  |  |  162|  1.27k|	return _ret; \
  |  |  |  |  163|  1.27k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  425|  1.27k|}
iso7816.c:iso7816_read_record:
  225|  8.21k|{
  226|  8.21k|	struct sc_apdu apdu;
  227|  8.21k|	int r;
  228|       |	/* XXX maybe use some bigger buffer */
  229|  8.21k|	unsigned char resp[SC_MAX_APDU_RESP_SIZE];
  230|  8.21k|	unsigned char *encoded_data = NULL, *decoded_data = NULL;
  231|  8.21k|	size_t encoded_data_len = 0, decoded_data_len = 0;
  232|       |
  233|  8.21k|	if (rec_nr > 0xFF)
  ------------------
  |  Branch (233:6): [True: 2, False: 8.20k]
  ------------------
  234|  8.21k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  235|       |
  236|  8.20k|	if (idx == 0) {
  ------------------
  |  Branch (236:6): [True: 4.71k, False: 3.49k]
  ------------------
  237|  4.71k|		sc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0xB2, rec_nr, 0);
  ------------------
  |  |  301|  4.71k|#define SC_APDU_CASE_2			0x22
  ------------------
  238|  4.71k|		apdu.le = count;
  239|  4.71k|		apdu.resplen = count;
  240|  4.71k|		apdu.resp = buf;
  241|  4.71k|	} else {
  242|  3.49k|		r = encode_do_data(card->ctx, idx, NULL, 0, &encoded_data, &encoded_data_len);
  243|  3.49k|		LOG_TEST_GOTO_ERR(card->ctx, r, "Could not encode data objects");
  ------------------
  |  |  184|  3.49k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  3.49k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  3.49k|	int _ret = (r); \
  |  |  |  |  178|  3.49k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 3.49k]
  |  |  |  |  ------------------
  |  |  |  |  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.49k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 3.49k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  244|       |
  245|  3.49k|		sc_format_apdu(card, &apdu, SC_APDU_CASE_4, 0xB3, rec_nr, 0);
  ------------------
  |  |  303|  3.49k|#define SC_APDU_CASE_4			0x24
  ------------------
  246|  3.49k|		apdu.lc = encoded_data_len;
  247|  3.49k|		apdu.datalen = encoded_data_len;
  248|  3.49k|		apdu.data = encoded_data;
  249|  3.49k|		apdu.le = sizeof resp;
  250|  3.49k|		apdu.resplen = sizeof resp;
  251|  3.49k|		apdu.resp = resp;
  252|  3.49k|	}
  253|  8.20k|	apdu.p2 = (flags & SC_RECORD_EF_ID_MASK) << 3;
  ------------------
  |  | 1293|  8.20k|#define SC_RECORD_EF_ID_MASK		0x0001FUL
  ------------------
  254|  8.20k|	if (flags & SC_RECORD_BY_REC_NR)
  ------------------
  |  | 1298|  8.20k|#define SC_RECORD_BY_REC_NR		0x00100UL
  ------------------
  |  Branch (254:6): [True: 8.20k, False: 0]
  ------------------
  255|  8.20k|		apdu.p2 |= 0x04;
  256|       |
  257|  8.20k|	iso7816_fixup_transceive_length(card, &apdu);
  258|  8.20k|	r = sc_transmit_apdu(card, &apdu);
  259|  8.20k|	LOG_TEST_GOTO_ERR(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  184|  8.20k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  8.20k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  8.20k|	int _ret = (r); \
  |  |  |  |  178|  8.20k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 112, False: 8.09k]
  |  |  |  |  ------------------
  |  |  |  |  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|  8.20k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 8.09k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  260|  8.09k|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  261|  8.09k|	LOG_TEST_GOTO_ERR(card->ctx, r, "Card returned error");
  ------------------
  |  |  184|  8.09k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  8.09k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  8.09k|	int _ret = (r); \
  |  |  |  |  178|  8.09k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 1.75k, False: 6.34k]
  |  |  |  |  ------------------
  |  |  |  |  179|  1.75k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.75k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|  1.75k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|  1.75k|		goto err; \
  |  |  |  |  182|  1.75k|	} \
  |  |  |  |  183|  8.09k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 6.34k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  262|       |
  263|  6.34k|	if (idx == 0) {
  ------------------
  |  Branch (263:6): [True: 4.06k, False: 2.28k]
  ------------------
  264|  4.06k|		r = (int)apdu.resplen;
  265|  4.06k|	} else {
  266|  2.28k|		r = decode_do_data(card->ctx, apdu.resp, apdu.resplen,
  267|  2.28k|				&decoded_data, &decoded_data_len);
  268|  2.28k|		LOG_TEST_GOTO_ERR(card->ctx, r, "Could not decode data objects");
  ------------------
  |  |  184|  2.28k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  2.28k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  2.28k|	int _ret = (r); \
  |  |  |  |  178|  2.28k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 1.96k, False: 315]
  |  |  |  |  ------------------
  |  |  |  |  179|  1.96k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  1.96k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|  1.96k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|  1.96k|		goto err; \
  |  |  |  |  182|  1.96k|	} \
  |  |  |  |  183|  2.28k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 315]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  269|    315|		if (decoded_data_len <= count) {
  ------------------
  |  Branch (269:7): [True: 288, False: 27]
  ------------------
  270|    288|			count = decoded_data_len;
  271|    288|		}
  272|    315|		memcpy(buf, decoded_data, count);
  273|    315|		r = (int)count;
  274|    315|	}
  275|       |
  276|  8.20k|err:
  277|  8.20k|	free(encoded_data);
  278|  8.20k|	free(decoded_data);
  279|  8.20k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  8.20k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  8.20k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  8.20k|	int _ret = r; \
  |  |  |  |  155|  8.20k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4.42k, False: 3.78k]
  |  |  |  |  ------------------
  |  |  |  |  156|  4.42k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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.83k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 3.83k, False: 593]
  |  |  |  |  ------------------
  |  |  |  |  157|  4.42k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  4.42k|	} else { \
  |  |  |  |  159|  3.78k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  3.78k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  3.78k|	} \
  |  |  |  |  162|  8.20k|	return _ret; \
  |  |  |  |  163|  8.20k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  280|  8.20k|}
iso7816.c:iso7816_select_file:
  629|  98.3k|{
  630|  98.3k|	struct sc_context *ctx;
  631|  98.3k|	struct sc_apdu apdu;
  632|  98.3k|	unsigned char buf[SC_MAX_APDU_BUFFER_SIZE];
  633|  98.3k|	unsigned char pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf;
  634|  98.3k|	int r, pathtype;
  635|  98.3k|	size_t pathlen;
  636|  98.3k|	int select_mf = 0;
  637|  98.3k|	struct sc_file *file = NULL;
  638|  98.3k|	const u8 *buffer;
  639|  98.3k|	size_t buffer_len;
  640|  98.3k|	unsigned int cla, tag;
  641|       |
  642|  98.3k|	if (card == NULL || in_path == NULL) {
  ------------------
  |  Branch (642:6): [True: 0, False: 98.3k]
  |  Branch (642:22): [True: 0, False: 98.3k]
  ------------------
  643|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  644|      0|	}
  645|  98.3k|	ctx = card->ctx;
  646|  98.3k|	memcpy(path, in_path->value, in_path->len);
  647|  98.3k|	pathlen = in_path->len;
  648|  98.3k|	pathtype = in_path->type;
  649|       |
  650|  98.3k|	if (in_path->aid.len) {
  ------------------
  |  Branch (650:6): [True: 1.88k, False: 96.4k]
  ------------------
  651|  1.88k|		if (!pathlen) {
  ------------------
  |  Branch (651:7): [True: 1.12k, False: 758]
  ------------------
  652|  1.12k|			memcpy(path, in_path->aid.value, in_path->aid.len);
  653|  1.12k|			pathlen = in_path->aid.len;
  654|  1.12k|			pathtype = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|  1.12k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  655|  1.12k|		} else {
  656|       |			/* First, select the application */
  657|    758|			sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xA4, 4, 0);
  ------------------
  |  |  293|    758|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  658|    758|			apdu.data = in_path->aid.value;
  659|    758|			apdu.datalen = in_path->aid.len;
  660|    758|			apdu.lc = in_path->aid.len;
  661|       |
  662|    758|			r = sc_transmit_apdu(card, &apdu);
  663|    758|			LOG_TEST_RET(ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    758|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    758|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    758|	int _ret = (r); \
  |  |  |  |  168|    758|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 11, False: 747]
  |  |  |  |  ------------------
  |  |  |  |  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|    758|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 747]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  664|    747|			r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  665|    747|			if (r)
  ------------------
  |  Branch (665:8): [True: 163, False: 584]
  ------------------
  666|    747|				LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    163|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    163|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    163|	int _ret = r; \
  |  |  |  |  155|    163|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 163, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    163|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    163|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 163, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    163|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    163|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    163|	return _ret; \
  |  |  |  |  163|    163|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  667|       |
  668|    584|			if (pathtype == SC_PATH_TYPE_PATH
  ------------------
  |  |  119|  1.16k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (668:8): [True: 73, False: 511]
  ------------------
  669|    511|					|| pathtype == SC_PATH_TYPE_DF_NAME)
  ------------------
  |  |  118|    511|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (669:9): [True: 511, False: 0]
  ------------------
  670|    584|				pathtype = SC_PATH_TYPE_FROM_CURRENT;
  ------------------
  |  |  122|    584|#define SC_PATH_TYPE_FROM_CURRENT	4
  ------------------
  671|    584|		}
  672|  1.88k|	}
  673|       |
  674|  98.1k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0, 0);
  ------------------
  |  |  294|  98.1k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  675|       |
  676|  98.1k|	switch (pathtype) {
  677|  12.5k|	case SC_PATH_TYPE_FILE_ID:
  ------------------
  |  |  117|  12.5k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (677:2): [True: 12.5k, False: 85.6k]
  ------------------
  678|  12.5k|		apdu.p1 = 0;
  679|  12.5k|		if (pathlen != 2)
  ------------------
  |  Branch (679:7): [True: 502, False: 12.0k]
  ------------------
  680|    502|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|    502|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  681|  12.0k|		break;
  682|  25.1k|	case SC_PATH_TYPE_DF_NAME:
  ------------------
  |  |  118|  25.1k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (682:2): [True: 25.1k, False: 73.0k]
  ------------------
  683|  25.1k|		apdu.p1 = 4;
  684|  25.1k|		break;
  685|  59.4k|	case SC_PATH_TYPE_PATH:
  ------------------
  |  |  119|  59.4k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (685:2): [True: 59.4k, False: 38.6k]
  ------------------
  686|  59.4k|		apdu.p1 = 8;
  687|  59.4k|		if (pathlen >= 2 && memcmp(path, "\x3F\x00", 2) == 0) {
  ------------------
  |  Branch (687:7): [True: 58.2k, False: 1.28k]
  |  Branch (687:23): [True: 45.2k, False: 12.9k]
  ------------------
  688|  45.2k|			if (pathlen == 2) {	/* only 3F00 supplied */
  ------------------
  |  Branch (688:8): [True: 5.21k, False: 40.0k]
  ------------------
  689|  5.21k|				select_mf = 1;
  690|  5.21k|				apdu.p1 = 0;
  691|  5.21k|				break;
  692|  5.21k|			}
  693|  40.0k|			path += 2;
  694|  40.0k|			pathlen -= 2;
  695|  40.0k|		}
  696|  54.2k|		break;
  697|  54.2k|	case SC_PATH_TYPE_FROM_CURRENT:
  ------------------
  |  |  122|    584|#define SC_PATH_TYPE_FROM_CURRENT	4
  ------------------
  |  Branch (697:2): [True: 584, False: 97.6k]
  ------------------
  698|    584|		apdu.p1 = 9;
  699|    584|		break;
  700|    422|	case SC_PATH_TYPE_PARENT:
  ------------------
  |  |  123|    422|#define SC_PATH_TYPE_PARENT		5
  ------------------
  |  Branch (700:2): [True: 422, False: 97.7k]
  ------------------
  701|    422|		apdu.p1 = 3;
  702|    422|		pathlen = 0;
  703|    422|		apdu.cse = SC_APDU_CASE_2_SHORT;
  ------------------
  |  |  292|    422|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  704|    422|		break;
  705|      0|	default:
  ------------------
  |  Branch (705:2): [True: 0, False: 98.1k]
  ------------------
  706|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  707|  98.1k|	}
  708|  97.6k|	apdu.lc = pathlen;
  709|  97.6k|	apdu.data = path;
  710|  97.6k|	apdu.datalen = pathlen;
  711|       |
  712|  97.6k|	if (file_out != NULL) {
  ------------------
  |  Branch (712:6): [True: 72.3k, False: 25.3k]
  ------------------
  713|  72.3k|		apdu.p2 = 0;		/* first record, return FCI */
  714|  72.3k|		apdu.resp = buf;
  715|  72.3k|		apdu.resplen = sizeof(buf);
  716|  72.3k|		apdu.le = sc_get_max_recv_size(card) < 256 ? sc_get_max_recv_size(card) : 256;
  ------------------
  |  Branch (716:13): [True: 6.69k, False: 65.6k]
  ------------------
  717|  72.3k|	}
  718|  25.3k|	else {
  719|  25.3k|		apdu.p2 = 0x0C;		/* first record, return nothing */
  720|  25.3k|		apdu.cse = (apdu.lc == 0) ? SC_APDU_CASE_1 : SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  291|     34|#define SC_APDU_CASE_1			0x01
  ------------------
              		apdu.cse = (apdu.lc == 0) ? SC_APDU_CASE_1 : SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|  50.6k|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  |  Branch (720:14): [True: 34, False: 25.3k]
  ------------------
  721|  25.3k|	}
  722|       |
  723|  97.6k|	r = sc_transmit_apdu(card, &apdu);
  724|  97.6k|	LOG_TEST_RET(ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  97.6k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  97.6k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  97.6k|	int _ret = (r); \
  |  |  |  |  168|  97.6k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.70k, False: 95.9k]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.70k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.70k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.70k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.70k|		return _ret; \
  |  |  |  |  172|  1.70k|	} \
  |  |  |  |  173|  97.6k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 95.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  725|  95.9k|	if (file_out == NULL) {
  ------------------
  |  Branch (725:6): [True: 25.3k, False: 70.6k]
  ------------------
  726|       |		/* For some cards 'SELECT' can be only with request to return FCI/FCP. */
  727|  25.3k|		r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  728|  25.3k|		if (apdu.sw1 == 0x6A && apdu.sw2 == 0x86)   {
  ------------------
  |  Branch (728:7): [True: 1.48k, False: 23.8k]
  |  Branch (728:27): [True: 350, False: 1.13k]
  ------------------
  729|    350|			apdu.p2 = 0x00;
  730|    350|			if (sc_transmit_apdu(card, &apdu) == SC_SUCCESS)
  ------------------
  |  |   28|    350|#define SC_SUCCESS				0
  ------------------
  |  Branch (730:8): [True: 344, False: 6]
  ------------------
  731|    344|				r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  732|    350|		}
  733|  25.3k|		if (apdu.sw1 == 0x61)
  ------------------
  |  Branch (733:7): [True: 0, False: 25.3k]
  ------------------
  734|  25.3k|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  735|  25.3k|		LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  25.3k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  25.3k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  25.3k|	int _ret = r; \
  |  |  |  |  155|  25.3k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 25.3k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  25.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|  15.6k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 15.6k, False: 9.68k]
  |  |  |  |  ------------------
  |  |  |  |  157|  25.3k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  25.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|  25.3k|	return _ret; \
  |  |  |  |  163|  25.3k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  736|  25.3k|	}
  737|       |
  738|  70.6k|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  739|  70.6k|	if (r)
  ------------------
  |  Branch (739:6): [True: 50.1k, False: 20.4k]
  ------------------
  740|  70.6k|		LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  50.1k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  50.1k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  50.1k|	int _ret = r; \
  |  |  |  |  155|  50.1k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 50.1k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  50.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|  50.1k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 50.1k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  50.1k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  50.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|  50.1k|	return _ret; \
  |  |  |  |  163|  50.1k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  741|       |
  742|  20.4k|	if (file_out && (apdu.resplen == 0))   {
  ------------------
  |  Branch (742:6): [True: 20.4k, False: 0]
  |  Branch (742:18): [True: 4.58k, False: 15.8k]
  ------------------
  743|       |		/* For some cards 'SELECT' MF or DF_NAME do not return FCI. */
  744|  4.58k|		if (select_mf || pathtype == SC_PATH_TYPE_DF_NAME)   {
  ------------------
  |  |  118|  4.08k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (744:7): [True: 500, False: 4.08k]
  |  Branch (744:20): [True: 2.15k, False: 1.92k]
  ------------------
  745|  2.65k|			file = sc_file_new();
  746|  2.65k|			if (file == NULL)
  ------------------
  |  Branch (746:8): [True: 0, False: 2.65k]
  ------------------
  747|  2.65k|				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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  748|  2.65k|			file->path = *in_path;
  749|       |
  750|  2.65k|			*file_out = file;
  751|  2.65k|			LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  2.65k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.65k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.65k|	int _ret = r; \
  |  |  |  |  155|  2.65k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.65k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.65k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 2.65k]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.65k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.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|  2.65k|	return _ret; \
  |  |  |  |  163|  2.65k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  752|  2.65k|		}
  753|  4.58k|	}
  754|       |
  755|  17.7k|	if (apdu.resplen < 2)
  ------------------
  |  Branch (755:6): [True: 2.45k, False: 15.3k]
  ------------------
  756|  17.7k|		LOG_FUNC_RETURN(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  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|  2.45k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.45k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  757|  15.3k|	switch (apdu.resp[0]) {
  758|  13.7k|	case ISO7816_TAG_FCI:
  ------------------
  |  |   15|  13.7k|#define ISO7816_TAG_FCI			0x6F
  ------------------
  |  Branch (758:2): [True: 13.7k, False: 1.63k]
  ------------------
  759|  13.8k|	case ISO7816_TAG_FCP:
  ------------------
  |  |   17|  13.8k|#define ISO7816_TAG_FCP			0x62
  ------------------
  |  Branch (759:2): [True: 134, False: 15.2k]
  ------------------
  760|  13.8k|		file = sc_file_new();
  761|  13.8k|		if (file == NULL)
  ------------------
  |  Branch (761:7): [True: 0, False: 13.8k]
  ------------------
  762|  13.8k|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  763|  13.8k|		file->path = *in_path;
  764|  13.8k|		if (card->ops->process_fci == NULL) {
  ------------------
  |  Branch (764:7): [True: 0, False: 13.8k]
  ------------------
  765|      0|			sc_file_free(file);
  766|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  767|      0|		}
  768|  13.8k|		buffer = apdu.resp;
  769|  13.8k|		r = sc_asn1_read_tag(&buffer, apdu.resplen, &cla, &tag, &buffer_len);
  770|  13.8k|		if (r == SC_SUCCESS)
  ------------------
  |  |   28|  13.8k|#define SC_SUCCESS				0
  ------------------
  |  Branch (770:7): [True: 13.2k, False: 570]
  ------------------
  771|  13.2k|			card->ops->process_fci(card, file, buffer, buffer_len);
  772|  13.8k|		*file_out = file;
  773|  13.8k|		break;
  774|    334|	case 0x00: /* proprietary coding */
  ------------------
  |  Branch (774:2): [True: 334, False: 15.0k]
  ------------------
  775|    334|		LOG_FUNC_RETURN(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|    334|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    334|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    334|	int _ret = r; \
  |  |  |  |  155|    334|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 334, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    334|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    334|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    334|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    334|	return _ret; \
  |  |  |  |  163|    334|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  776|  1.16k|	default:
  ------------------
  |  Branch (776:2): [True: 1.16k, False: 14.1k]
  ------------------
  777|  1.16k|		LOG_FUNC_RETURN(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|  1.16k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.16k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.16k|	int _ret = r; \
  |  |  |  |  155|  1.16k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.16k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.16k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  1.16k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.16k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.16k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.16k|	} else { \
  |  |  |  |  159|      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.16k|	return _ret; \
  |  |  |  |  163|  1.16k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  778|  15.3k|	}
  779|       |
  780|  13.8k|	return SC_SUCCESS;
  ------------------
  |  |   28|  13.8k|#define SC_SUCCESS				0
  ------------------
  781|  15.3k|}
iso7816.c:iso7816_get_response:
  904|  12.2k|{
  905|  12.2k|	struct sc_apdu apdu = {0};
  906|  12.2k|	int r;
  907|  12.2k|	size_t rlen;
  908|       |
  909|       |	/* request at most max_recv_size bytes */
  910|  12.2k|	if (*count > sc_get_max_recv_size(card))
  ------------------
  |  Branch (910:6): [True: 686, False: 11.5k]
  ------------------
  911|    686|		rlen = sc_get_max_recv_size(card);
  912|  11.5k|	else
  913|  11.5k|		rlen = *count;
  914|       |
  915|  12.2k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0xC0, 0x00, 0x00);
  ------------------
  |  |  301|  12.2k|#define SC_APDU_CASE_2			0x22
  ------------------
  916|  12.2k|	apdu.le      = rlen;
  917|  12.2k|	apdu.resplen = rlen;
  918|  12.2k|	apdu.resp    = buf;
  919|       |	/* don't call GET RESPONSE recursively */
  920|  12.2k|	apdu.flags  |= SC_APDU_FLAGS_NO_GET_RESP;
  ------------------
  |  |  308|  12.2k|#define SC_APDU_FLAGS_NO_GET_RESP	0x00000002UL
  ------------------
  921|       |
  922|  12.2k|	r = sc_transmit_apdu(card, &apdu);
  923|  12.2k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  12.2k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  12.2k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  12.2k|	int _ret = (r); \
  |  |  |  |  168|  12.2k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 321, False: 11.9k]
  |  |  |  |  ------------------
  |  |  |  |  169|    321|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    321|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    321|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    321|		return _ret; \
  |  |  |  |  172|    321|	} \
  |  |  |  |  173|  12.2k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 11.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  924|       |
  925|  11.9k|	*count = apdu.resplen;
  926|       |
  927|  11.9k|	if (apdu.resplen == 0) {
  ------------------
  |  Branch (927:6): [True: 4.05k, False: 7.88k]
  ------------------
  928|  4.05k|		LOG_FUNC_RETURN(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  164|  4.05k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  4.05k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  4.05k|	int _ret = r; \
  |  |  |  |  155|  4.05k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4.05k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  4.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.22k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.22k, False: 2.83k]
  |  |  |  |  ------------------
  |  |  |  |  157|  4.05k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  4.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|  4.05k|	return _ret; \
  |  |  |  |  163|  4.05k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  929|  4.05k|	}
  930|  7.88k|	if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00)
  ------------------
  |  Branch (930:6): [True: 2.47k, False: 5.40k]
  |  Branch (930:26): [True: 2.35k, False: 118]
  ------------------
  931|  2.35k|		r = 0;					/* no more data to read */
  932|  5.52k|	else if (apdu.sw1 == 0x61)
  ------------------
  |  Branch (932:11): [True: 4.33k, False: 1.19k]
  ------------------
  933|  4.33k|		r = apdu.sw2 == 0 ? 256 : apdu.sw2;	/* more data to read    */
  ------------------
  |  Branch (933:7): [True: 1.06k, False: 3.26k]
  ------------------
  934|  1.19k|	else if (apdu.sw1 == 0x62 && apdu.sw2 == 0x82)
  ------------------
  |  Branch (934:11): [True: 215, False: 977]
  |  Branch (934:31): [True: 138, False: 77]
  ------------------
  935|    138|		r = 0; /* Le not reached but file/record ended */
  936|  1.05k|	else
  937|  1.05k|		r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  938|       |
  939|  7.88k|	return r;
  940|  11.9k|}
iso7816.c:iso7816_get_challenge:
  786|     26|{
  787|     26|	int r;
  788|     26|	struct sc_apdu apdu;
  789|       |
  790|     26|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0x84, 0x00, 0x00);
  ------------------
  |  |  301|     26|#define SC_APDU_CASE_2			0x22
  ------------------
  791|     26|	apdu.le = len;
  792|     26|	apdu.resp = rnd;
  793|     26|	apdu.resplen = len;
  794|       |
  795|     26|	r = sc_transmit_apdu(card, &apdu);
  796|     26|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     26|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     26|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     26|	int _ret = (r); \
  |  |  |  |  168|     26|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 25]
  |  |  |  |  ------------------
  |  |  |  |  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|     26|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 25]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  797|       |
  798|     25|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  799|     25|	LOG_TEST_RET(card->ctx, r, "GET CHALLENGE 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: 5, False: 20]
  |  |  |  |  ------------------
  |  |  |  |  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|     25|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  800|       |
  801|     20|	if (len < apdu.resplen) {
  ------------------
  |  Branch (801:6): [True: 0, False: 20]
  ------------------
  802|      0|		return (int) len;
  803|      0|	}
  804|       |
  805|     20|	return (int) apdu.resplen;
  806|     20|}
iso7816.c:iso7816_create_file:
  875|    384|{
  876|    384|	int r;
  877|    384|	size_t len;
  878|    384|	u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
  879|    384|	struct sc_apdu apdu;
  880|       |
  881|    384|	len = SC_MAX_APDU_BUFFER_SIZE;
  ------------------
  |  |   34|    384|#define SC_MAX_APDU_BUFFER_SIZE		261 /* takes account of: CLA INS P1 P2 Lc [255 byte of data] Le */
  ------------------
  882|       |
  883|    384|	if (card->ops->construct_fci == NULL)
  ------------------
  |  Branch (883:6): [True: 0, False: 384]
  ------------------
  884|    384|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  885|    384|	r = card->ops->construct_fci(card, file, sbuf, &len);
  886|    384|	LOG_TEST_RET(card->ctx, r, "construct_fci() failed");
  ------------------
  |  |  174|    384|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    384|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    384|	int _ret = (r); \
  |  |  |  |  168|    384|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 16, False: 368]
  |  |  |  |  ------------------
  |  |  |  |  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|    384|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 368]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  887|       |
  888|    368|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE0, 0x00, 0x00);
  ------------------
  |  |  293|    368|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  889|    368|	apdu.lc = len;
  890|    368|	apdu.datalen = len;
  891|    368|	apdu.data = sbuf;
  892|       |
  893|    368|	r = sc_transmit_apdu(card, &apdu);
  894|    368|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  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: 1, False: 367]
  |  |  |  |  ------------------
  |  |  |  |  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|    368|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 367]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  895|    367|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  896|    367|	LOG_TEST_RET(card->ctx, r, "Card returned error");
  ------------------
  |  |  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: 207, False: 160]
  |  |  |  |  ------------------
  |  |  |  |  169|    207|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    207|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    207|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    207|		return _ret; \
  |  |  |  |  172|    207|	} \
  |  |  |  |  173|    367|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 160]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  897|       |
  898|    160|	return r;
  899|    367|}
iso7816.c:iso7816_delete_file:
  945|    110|{
  946|    110|	int r;
  947|    110|	u8 sbuf[2];
  948|    110|	struct sc_apdu apdu;
  949|       |
  950|    110|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  951|    110|	if (path->type != SC_PATH_TYPE_FILE_ID || (path->len != 0 && path->len != 2)) {
  ------------------
  |  |  117|    220|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (951:6): [True: 0, False: 110]
  |  Branch (951:45): [True: 56, False: 54]
  |  Branch (951:63): [True: 0, False: 56]
  ------------------
  952|      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__
  |  |  ------------------
  ------------------
  953|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  954|      0|	}
  955|       |
  956|    110|	if (path->len == 2) {
  ------------------
  |  Branch (956:6): [True: 56, False: 54]
  ------------------
  957|     56|		sbuf[0] = path->value[0];
  958|     56|		sbuf[1] = path->value[1];
  959|     56|		sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE4, 0x00, 0x00);
  ------------------
  |  |  293|     56|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  960|     56|		apdu.lc = 2;
  961|     56|		apdu.datalen = 2;
  962|     56|		apdu.data = sbuf;
  963|     56|	}
  964|     54|	else   {
  965|       |		/* No file ID given: means currently selected file */
  966|     54|		sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0xE4, 0x00, 0x00);
  ------------------
  |  |  291|     54|#define SC_APDU_CASE_1			0x01
  ------------------
  967|     54|	}
  968|       |
  969|    110|	r = sc_transmit_apdu(card, &apdu);
  970|    110|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  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: 3, False: 107]
  |  |  |  |  ------------------
  |  |  |  |  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|    110|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 107]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  971|    107|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  972|    107|	LOG_TEST_RET(card->ctx, r, "Card returned error");
  ------------------
  |  |  174|    107|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    107|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    107|	int _ret = (r); \
  |  |  |  |  168|    107|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 54, False: 53]
  |  |  |  |  ------------------
  |  |  |  |  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|    107|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 53]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  973|       |
  974|     53|	return r;
  975|    107|}
iso7816.c:iso7816_check_sw:
  111|   458k|{
  112|   458k|	const int err_count = sizeof(iso7816_errors)/sizeof(iso7816_errors[0]);
  113|   458k|	int i;
  114|       |
  115|       |	/* Handle special cases here */
  116|   458k|	if (sw1 == 0x6C) {
  ------------------
  |  Branch (116:6): [True: 132, False: 458k]
  ------------------
  117|    132|		sc_log(card->ctx, "Wrong length; correct length is %d", sw2);
  ------------------
  |  |   71|    132|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  118|    132|		return SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|    132|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
  119|    132|	}
  120|   458k|	if (sw1 == 0x90 && sw2 == 0x00)
  ------------------
  |  Branch (120:6): [True: 248k, False: 209k]
  |  Branch (120:21): [True: 245k, False: 3.04k]
  ------------------
  121|   245k|		return SC_SUCCESS;
  ------------------
  |  |   28|   245k|#define SC_SUCCESS				0
  ------------------
  122|   212k|	if (sw1 == 0x63U && (sw2 & ~0x0fU) == 0xc0U) {
  ------------------
  |  Branch (122:6): [True: 321, False: 212k]
  |  Branch (122:22): [True: 97, False: 224]
  ------------------
  123|     97|		sc_log(card->ctx, "PIN not verified (remaining tries: %d)", (sw2 & 0x0f));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  124|     97|		return SC_ERROR_PIN_CODE_INCORRECT;
  ------------------
  |  |   64|     97|#define SC_ERROR_PIN_CODE_INCORRECT		-1214
  ------------------
  125|     97|	}
  126|  8.65M|	for (i = 0; i < err_count; i++)   {
  ------------------
  |  Branch (126:14): [True: 8.63M, False: 16.4k]
  ------------------
  127|  8.63M|		if (iso7816_errors[i].SWs == ((sw1 << 8) | sw2)) {
  ------------------
  |  Branch (127:7): [True: 196k, False: 8.44M]
  ------------------
  128|   196k|			sc_log(card->ctx, "%s", iso7816_errors[i].errorstr);
  ------------------
  |  |   71|   196k|#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|   196k|			return iso7816_errors[i].errorno;
  130|   196k|		}
  131|  8.63M|	}
  132|       |
  133|  16.4k|	sc_log(card->ctx, "Unknown SWs; SW1=%02X, SW2=%02X", sw1, sw2);
  ------------------
  |  |   71|  16.4k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  134|  16.4k|	return SC_ERROR_CARD_CMD_FAILED;
  ------------------
  |  |   50|  16.4k|#define SC_ERROR_CARD_CMD_FAILED		-1200
  ------------------
  135|   212k|}
iso7816.c:iso7816_process_fci:
  431|  12.0k|{
  432|  12.0k|	struct sc_context *ctx = card->ctx;
  433|  12.0k|	const unsigned char *p, *end;
  434|  12.0k|	unsigned int cla = 0, tag = 0;
  435|  12.0k|	size_t length;
  436|       |
  437|  12.0k|	file->status = SC_FILE_STATUS_UNKNOWN;
  ------------------
  |  |  254|  12.0k|#define SC_FILE_STATUS_UNKNOWN		0xff /* if tag 0x8A is missing, there is no information about LCSB */
  ------------------
  438|       |
  439|  12.0k|	for (p = buf, length = buflen, end = buf + buflen;
  440|  50.9k|			p < end;
  ------------------
  |  Branch (440:4): [True: 45.9k, False: 5.03k]
  ------------------
  441|  45.9k|			p += length, length = end - p) {
  442|       |
  443|  45.9k|		if (SC_SUCCESS != sc_asn1_read_tag(&p, length, &cla, &tag, &length)
  ------------------
  |  |   28|  45.9k|#define SC_SUCCESS				0
  ------------------
  |  Branch (443:7): [True: 4.39k, False: 41.5k]
  ------------------
  444|  41.5k|				|| p == NULL) {
  ------------------
  |  Branch (444:8): [True: 2.60k, False: 38.9k]
  ------------------
  445|  6.99k|			break;
  446|  6.99k|		}
  447|  38.9k|		switch (cla | tag) {
  ------------------
  |  Branch (447:11): [True: 34.7k, False: 4.14k]
  ------------------
  448|  3.42k|			case 0x81:
  ------------------
  |  Branch (448:4): [True: 3.42k, False: 35.4k]
  ------------------
  449|  3.42k|				if (file->size != 0) {
  ------------------
  |  Branch (449:9): [True: 91, False: 3.33k]
  ------------------
  450|       |					/* don't overwrite existing file size excluding structural information */
  451|     91|					break;
  452|     91|				}
  453|       |				/* fall through */
  454|  7.38k|			case 0x80:
  ------------------
  |  Branch (454:4): [True: 4.04k, False: 34.8k]
  ------------------
  455|       |				/* determine the file size */
  456|  7.38k|				file->size = 0;
  457|  7.38k|				if (p && length <= sizeof(size_t)) {
  ------------------
  |  Branch (457:9): [True: 7.38k, False: 0]
  |  Branch (457:14): [True: 7.17k, False: 212]
  ------------------
  458|  7.17k|					size_t size = 0, i;
  459|  22.0k|					for (i = 0; i < length; i++) {
  ------------------
  |  Branch (459:18): [True: 14.8k, False: 7.17k]
  ------------------
  460|  14.8k|						size <<= 8;
  461|  14.8k|						size |= p[i];
  462|  14.8k|					}
  463|  7.17k|					if (size > MAX_FILE_SIZE) {
  ------------------
  |  |  220|  7.17k|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (463:10): [True: 315, False: 6.85k]
  ------------------
  464|    315|						file->size = MAX_FILE_SIZE;
  ------------------
  |  |  220|    315|#define MAX_FILE_SIZE 65535
  ------------------
  465|    315|						sc_log(ctx, "  file size truncated, encoded length: %zu", size);
  ------------------
  |  |   71|    315|#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|  6.85k|					} else {
  467|  6.85k|						file->size = size;
  468|  6.85k|					}
  469|  7.17k|				}
  470|       |
  471|  7.38k|				sc_log(ctx, "  bytes in file: %zu", file->size);
  ------------------
  |  |   71|  7.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__
  |  |  ------------------
  ------------------
  472|  7.38k|				break;
  473|       |
  474|  7.03k|			case 0x82:
  ------------------
  |  Branch (474:4): [True: 7.03k, False: 31.8k]
  ------------------
  475|  7.03k|				if (length > 0) {
  ------------------
  |  Branch (475:9): [True: 6.88k, False: 152]
  ------------------
  476|  6.88k|					unsigned char byte = p[0];
  477|  6.88k|					const char *type;
  478|       |
  479|  6.88k|					file->shareable = byte & 0x40 ? 1 : 0;
  ------------------
  |  Branch (479:24): [True: 842, False: 6.04k]
  ------------------
  480|  6.88k|					sc_log(ctx, "  shareable: %s", (byte & 0x40) ? "yes" : "no");
  ------------------
  |  |   71|  13.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: 842, False: 6.04k]
  |  |  ------------------
  ------------------
  481|  6.88k|					file->ef_structure = byte & 0x07;
  482|  6.88k|					switch ((byte >> 3) & 7) {
  483|  3.03k|						case 0:
  ------------------
  |  Branch (483:7): [True: 3.03k, False: 3.84k]
  ------------------
  484|  3.03k|							type = "working EF";
  485|  3.03k|							file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|  3.03k|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  486|  3.03k|							break;
  487|     82|						case 1:
  ------------------
  |  Branch (487:7): [True: 82, False: 6.80k]
  ------------------
  488|     82|							type = "internal EF";
  489|     82|							file->type = SC_FILE_TYPE_INTERNAL_EF;
  ------------------
  |  |  215|     82|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  490|     82|							break;
  491|  1.93k|						case 7:
  ------------------
  |  Branch (491:7): [True: 1.93k, False: 4.94k]
  ------------------
  492|  1.93k|							type = "DF";
  493|  1.93k|							file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|  1.93k|#define SC_FILE_TYPE_DF			0x04
  ------------------
  494|  1.93k|							break;
  495|  1.82k|						default:
  ------------------
  |  Branch (495:7): [True: 1.82k, False: 5.05k]
  ------------------
  496|  1.82k|							file->type = SC_FILE_TYPE_UNKNOWN;
  ------------------
  |  |  213|  1.82k|#define SC_FILE_TYPE_UNKNOWN		0x00
  ------------------
  497|  1.82k|							type = "unknown";
  498|  1.82k|							break;
  499|  6.88k|					}
  500|  6.88k|					sc_log(ctx, "  type: %s", type);
  ------------------
  |  |   71|  6.88k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  501|  6.88k|					sc_log(ctx, "  EF structure: %d", byte & 0x07);
  ------------------
  |  |   71|  6.88k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  502|  6.88k|					sc_log(ctx, "  tag 0x82: 0x%02x", byte);
  ------------------
  |  |   71|  6.88k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  503|       |
  504|       |					/* if possible, get additional information for non-DFs */
  505|  6.88k|					if (file->type != SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|  6.88k|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (505:10): [True: 4.94k, False: 1.93k]
  ------------------
  506|       |						/* max. record length for fixed- & variable-sized records */
  507|  4.94k|						if (length > 2 && byte & 0x06) {
  ------------------
  |  Branch (507:11): [True: 260, False: 4.68k]
  |  Branch (507:25): [True: 75, False: 185]
  ------------------
  508|     75|							file->record_length = (length > 3)
  ------------------
  |  Branch (508:30): [True: 48, False: 27]
  ------------------
  509|     75|								? bebytes2ushort(p+2)
  510|     75|								: p[2];
  511|     75|							sc_log(ctx, "  record length: %zu", file->record_length);
  ------------------
  |  |   71|     75|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  512|     75|						}
  513|       |
  514|       |						/* number of records */
  515|  4.94k|						if (length > 4) {
  ------------------
  |  Branch (515:11): [True: 176, False: 4.77k]
  ------------------
  516|    176|							file->record_count = (length > 5)
  ------------------
  |  Branch (516:29): [True: 146, False: 30]
  ------------------
  517|    176|								? bebytes2ushort(p+4)
  518|    176|								: p[4];
  519|    176|							sc_log(ctx, "  records: %zu", file->record_count);
  ------------------
  |  |   71|    176|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  520|    176|						}
  521|  4.94k|					}
  522|       |
  523|  6.88k|					if (SC_SUCCESS != sc_file_set_type_attr(file, p, length))
  ------------------
  |  |   28|  6.88k|#define SC_SUCCESS				0
  ------------------
  |  Branch (523:10): [True: 0, False: 6.88k]
  ------------------
  524|      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__
  |  |  ------------------
  ------------------
  525|  6.88k|				}
  526|  7.03k|				break;
  527|       |
  528|  7.03k|			case 0x83:
  ------------------
  |  Branch (528:4): [True: 5.78k, False: 33.1k]
  ------------------
  529|  5.78k|				if (length == 2) {
  ------------------
  |  Branch (529:9): [True: 5.62k, False: 158]
  ------------------
  530|  5.62k|					file->id = (p[0] << 8) | p[1];
  531|  5.62k|					sc_log(ctx, "  file identifier: 0x%02X%02X", p[0], p[1]);
  ------------------
  |  |   71|  5.62k|#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|  5.62k|				}
  533|  5.78k|				break;
  534|       |
  535|  1.43k|			case 0x84:
  ------------------
  |  Branch (535:4): [True: 1.43k, False: 37.4k]
  ------------------
  536|  1.43k|				if (length > 0 && length <= 16) {
  ------------------
  |  Branch (536:9): [True: 1.34k, False: 99]
  |  Branch (536:23): [True: 1.32k, False: 12]
  ------------------
  537|  1.32k|					memcpy(file->name, p, length);
  538|  1.32k|					file->namelen = length;
  539|       |
  540|  1.32k|					sc_log_hex(ctx, "  File name:", file->name, file->namelen);
  ------------------
  |  |  129|  1.32k|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|  1.32k|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  541|  1.32k|					if (!file->type)
  ------------------
  |  Branch (541:10): [True: 420, False: 908]
  ------------------
  542|    420|						file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|    420|#define SC_FILE_TYPE_DF			0x04
  ------------------
  543|  1.32k|				}
  544|  1.43k|				break;
  545|       |
  546|  3.72k|			case 0x85:
  ------------------
  |  Branch (546:4): [True: 3.72k, False: 35.1k]
  ------------------
  547|  3.85k|			case 0xA5:
  ------------------
  |  Branch (547:4): [True: 129, False: 38.7k]
  ------------------
  548|  3.85k|				if (SC_SUCCESS != sc_file_set_prop_attr(file, p, length)) {
  ------------------
  |  |   28|  3.85k|#define SC_SUCCESS				0
  ------------------
  |  Branch (548:9): [True: 0, False: 3.85k]
  ------------------
  549|      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__
  |  |  ------------------
  ------------------
  550|      0|				}
  551|  3.85k|				break;
  552|       |
  553|  4.86k|			case 0x86:
  ------------------
  |  Branch (553:4): [True: 4.86k, False: 34.0k]
  ------------------
  554|  4.86k|				if (SC_SUCCESS != sc_file_set_sec_attr(file, p, length)) {
  ------------------
  |  |   28|  4.86k|#define SC_SUCCESS				0
  ------------------
  |  Branch (554:9): [True: 0, False: 4.86k]
  ------------------
  555|      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__
  |  |  ------------------
  ------------------
  556|      0|				}
  557|  4.86k|				break;
  558|       |
  559|    108|			case 0x88:
  ------------------
  |  Branch (559:4): [True: 108, False: 38.8k]
  ------------------
  560|    108|				if (length == 1) {
  ------------------
  |  Branch (560:9): [True: 54, False: 54]
  ------------------
  561|     54|					file->sid = *p;
  562|     54|					sc_log(ctx, "  short file identifier: 0x%02X", *p);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  563|     54|				}
  564|    108|				break;
  565|       |
  566|  3.87k|			case 0x8A:
  ------------------
  |  Branch (566:4): [True: 3.87k, False: 35.0k]
  ------------------
  567|  3.87k|				if (length == 1) {
  ------------------
  |  Branch (567:9): [True: 3.80k, False: 76]
  ------------------
  568|  3.80k|					switch (p[0]) {
  569|     32|						case 0:
  ------------------
  |  Branch (569:7): [True: 32, False: 3.76k]
  ------------------
  570|     32|							file->status =SC_FILE_STATUS_NO_INFO;
  ------------------
  |  |  243|     32|#define SC_FILE_STATUS_NO_INFO		0x04 /* ISO7816-4: No information given, (0) */
  ------------------
  571|     32|							break;
  572|  3.20k|						case 1:
  ------------------
  |  Branch (572:7): [True: 3.20k, False: 598]
  ------------------
  573|  3.20k|							file->status = SC_FILE_STATUS_CREATION;
  ------------------
  |  |  240|  3.20k|#define SC_FILE_STATUS_CREATION		0x02 /* ISO7816-4: Creation state, (1) */
  ------------------
  574|  3.20k|							break;
  575|     11|						case 3:
  ------------------
  |  Branch (575:7): [True: 11, False: 3.78k]
  ------------------
  576|     11|							file->status = SC_FILE_STATUS_INITIALISATION;
  ------------------
  |  |  242|     11|#define SC_FILE_STATUS_INITIALISATION	0x03 /* ISO7816-4: Initialisation state, (3) */
  ------------------
  577|     11|							break;
  578|     50|						case 4:
  ------------------
  |  Branch (578:7): [True: 50, False: 3.75k]
  ------------------
  579|     71|						case 6:
  ------------------
  |  Branch (579:7): [True: 21, False: 3.77k]
  ------------------
  580|     71|							file->status = SC_FILE_STATUS_INVALIDATED;
  ------------------
  |  |  237|     71|#define SC_FILE_STATUS_INVALIDATED	0x01 /* ISO7816-4: Operational state (deactivated) (4, 6) */
  ------------------
  581|     71|							break;
  582|    126|						case 5:
  ------------------
  |  Branch (582:7): [True: 126, False: 3.67k]
  ------------------
  583|    150|						case 7:
  ------------------
  |  Branch (583:7): [True: 24, False: 3.77k]
  ------------------
  584|    150|							file->status = SC_FILE_STATUS_ACTIVATED;
  ------------------
  |  |  236|    150|#define SC_FILE_STATUS_ACTIVATED	0x00 /* ISO7816-4: Operational state (activated)   (5, 7) */
  ------------------
  585|    150|							break;
  586|     14|						case 12:
  ------------------
  |  Branch (586:7): [True: 14, False: 3.78k]
  ------------------
  587|     43|						case 13:
  ------------------
  |  Branch (587:7): [True: 29, False: 3.77k]
  ------------------
  588|     84|						case 14:
  ------------------
  |  Branch (588:7): [True: 41, False: 3.75k]
  ------------------
  589|    115|						case 15:
  ------------------
  |  Branch (589:7): [True: 31, False: 3.76k]
  ------------------
  590|    115|							file->status = SC_FILE_STATUS_TERMINATION;
  ------------------
  |  |  244|    115|#define SC_FILE_STATUS_TERMINATION	0x0c /* ISO7816-4: Termination state (12,13,14,15) */
  ------------------
  591|    115|							break;
  592|      7|						case 2:
  ------------------
  |  Branch (592:7): [True: 7, False: 3.79k]
  ------------------
  593|      7|							file->status = SC_FILE_STATUS_RFU_2;
  ------------------
  |  |  248|      7|#define SC_FILE_STATUS_RFU_2		0x07 /* ISO7816-4: (0x02) */
  ------------------
  594|      7|							break;
  595|     15|						case 8:
  ------------------
  |  Branch (595:7): [True: 15, False: 3.78k]
  ------------------
  596|     15|							file->status = SC_FILE_STATUS_RFU_8;
  ------------------
  |  |  249|     15|#define SC_FILE_STATUS_RFU_8		0x08 /* ISO7816-4: (0x08) */
  ------------------
  597|     15|							break;
  598|     12|						case 9:
  ------------------
  |  Branch (598:7): [True: 12, False: 3.78k]
  ------------------
  599|     12|							file->status = SC_FILE_STATUS_RFU_9;
  ------------------
  |  |  250|     12|#define SC_FILE_STATUS_RFU_9		0x09 /* ISO7816-4: (0x09) */
  ------------------
  600|     12|							break;
  601|     10|						case 10:
  ------------------
  |  Branch (601:7): [True: 10, False: 3.79k]
  ------------------
  602|     10|							file->status = SC_FILE_STATUS_RFU_10;
  ------------------
  |  |  251|     10|#define SC_FILE_STATUS_RFU_10		0x0a /* ISO7816-4: (0x0a) */
  ------------------
  603|     10|							break;
  604|     13|						case 11:
  ------------------
  |  Branch (604:7): [True: 13, False: 3.78k]
  ------------------
  605|     13|							file->status = SC_FILE_STATUS_RFU_11;
  ------------------
  |  |  252|     13|#define SC_FILE_STATUS_RFU_11		0x0b /* ISO7816-4: (0x0b) */
  ------------------
  606|     13|							break;
  607|    162|						default:
  ------------------
  |  Branch (607:7): [True: 162, False: 3.63k]
  ------------------
  608|    162|							file->status = SC_FILE_STATUS_PROPRIETARY;
  ------------------
  |  |  245|    162|#define SC_FILE_STATUS_PROPRIETARY	0xf0 /* ISO7816-4: codes > 15 */
  ------------------
  609|  3.80k|					}
  610|  3.80k|				}
  611|  3.87k|				break;
  612|       |
  613|  3.87k|			case 0x62:
  ------------------
  |  Branch (613:4): [True: 26, False: 38.8k]
  ------------------
  614|    132|			case 0x64:
  ------------------
  |  Branch (614:4): [True: 106, False: 38.8k]
  ------------------
  615|    348|			case 0x6F:
  ------------------
  |  Branch (615:4): [True: 216, False: 38.7k]
  ------------------
  616|       |				/* allow nested FCP/FMD/FCI templates */
  617|    348|				iso7816_process_fci(card, file, p, length);
  618|  38.9k|		}
  619|  38.9k|	}
  620|       |
  621|  12.0k|	file->magic = SC_FILE_MAGIC;
  ------------------
  |  |   57|  12.0k|#define SC_FILE_MAGIC			0x14426950
  ------------------
  622|       |
  623|  12.0k|	return SC_SUCCESS;
  ------------------
  |  |   28|  12.0k|#define SC_SUCCESS				0
  ------------------
  624|  12.0k|}
iso7816.c:iso7816_construct_fci:
  812|    244|{
  813|    244|	u8 *p = out;
  814|    244|	u8 buf[64];
  815|       |
  816|    244|	if (*outlen < 2)
  ------------------
  |  Branch (816:6): [True: 0, False: 244]
  ------------------
  817|      0|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  818|    244|	*p++ = 0x6F;
  819|    244|	p++;
  820|       |
  821|    244|	buf[0] = (file->size >> 8) & 0xFF;
  822|    244|	buf[1] = file->size & 0xFF;
  823|    244|	sc_asn1_put_tag(0x81, buf, 2, p, *outlen - (p - out), &p);
  824|       |
  825|    244|	if (file->type_attr_len) {
  ------------------
  |  Branch (825:6): [True: 57, False: 187]
  ------------------
  826|     57|		if (sizeof(buf) < file->type_attr_len)
  ------------------
  |  Branch (826:7): [True: 0, False: 57]
  ------------------
  827|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  828|     57|		memcpy(buf, file->type_attr, file->type_attr_len);
  829|     57|		sc_asn1_put_tag(0x82, buf, file->type_attr_len,
  830|     57|				p, *outlen - (p - out), &p);
  831|    187|	} else {
  832|    187|		buf[0] = file->shareable ? 0x40 : 0;
  ------------------
  |  Branch (832:12): [True: 0, False: 187]
  ------------------
  833|    187|		switch (file->type) {
  834|      0|		case SC_FILE_TYPE_INTERNAL_EF:
  ------------------
  |  |  215|      0|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (834:3): [True: 0, False: 187]
  ------------------
  835|      0|			buf[0] |= 0x08;
  836|       |			/* fall through */
  837|     55|		case SC_FILE_TYPE_WORKING_EF:
  ------------------
  |  |  216|     55|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (837:3): [True: 55, False: 132]
  ------------------
  838|     55|			buf[0] |= file->ef_structure & 7;
  839|     55|			break;
  840|    131|		case SC_FILE_TYPE_DF:
  ------------------
  |  |  214|    131|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (840:3): [True: 131, False: 56]
  ------------------
  841|    131|			buf[0] |= 0x38;
  842|    131|			break;
  843|      1|		default:
  ------------------
  |  Branch (843:3): [True: 1, False: 186]
  ------------------
  844|      1|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      1|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  845|    187|		}
  846|    186|		sc_asn1_put_tag(0x82, buf, 1, p, *outlen - (p - out), &p);
  847|    186|	}
  848|    243|	buf[0] = (file->id >> 8) & 0xFF;
  849|    243|	buf[1] = file->id & 0xFF;
  850|    243|	sc_asn1_put_tag(0x83, buf, 2, p, *outlen - (p - out), &p);
  851|       |	/* 0x84 = DF name */
  852|    243|	if (file->prop_attr_len) {
  ------------------
  |  Branch (852:6): [True: 109, False: 134]
  ------------------
  853|    109|		if (sizeof(buf) < file->prop_attr_len)
  ------------------
  |  Branch (853:7): [True: 0, False: 109]
  ------------------
  854|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  855|    109|		memcpy(buf, file->prop_attr, file->prop_attr_len);
  856|    109|		sc_asn1_put_tag(0x85, buf, file->prop_attr_len,
  857|    109|				p, *outlen - (p - out), &p);
  858|    109|	}
  859|    243|	if (file->sec_attr_len) {
  ------------------
  |  Branch (859:6): [True: 225, False: 18]
  ------------------
  860|    225|		if (sizeof(buf) < file->sec_attr_len)
  ------------------
  |  Branch (860:7): [True: 0, False: 225]
  ------------------
  861|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  862|    225|		memcpy(buf, file->sec_attr, file->sec_attr_len);
  863|    225|		sc_asn1_put_tag(0x86, buf, file->sec_attr_len,
  864|    225|				p, *outlen - (p - out), &p);
  865|    225|	}
  866|    243|	out[1] = p - out - 2;
  867|       |
  868|    243|	*outlen = p - out;
  869|    243|	return 0;
  870|    243|}
iso7816.c:iso7816_pin_cmd:
 1282|  2.52k|{
 1283|  2.52k|	struct sc_apdu local_apdu, *apdu;
 1284|  2.52k|	int r;
 1285|  2.52k|	u8  sbuf[SC_MAX_APDU_BUFFER_SIZE];
 1286|       |
 1287|  2.52k|	data->pin1.tries_left = -1;
 1288|       |
 1289|       |	/* Many cards do support PIN status queries, but some cards don't and
 1290|       |	 * mistakenly count the command as a failed PIN attempt, so for now we
 1291|       |	 * allow cards with this flag.  In future this may be reduced to a
 1292|       |	 * blocklist, subject to testing more cards. */
 1293|  2.52k|	if (data->cmd == SC_PIN_CMD_GET_INFO &&
  ------------------
  |  |  418|  5.04k|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (1293:6): [True: 2.33k, False: 185]
  ------------------
 1294|  2.33k|	    !(card->caps & SC_CARD_CAP_ISO7816_PIN_INFO)) {
  ------------------
  |  |  553|  2.33k|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
  |  Branch (1294:6): [True: 604, False: 1.73k]
  ------------------
 1295|    604|		sc_log(card->ctx, "Card does not support PIN status queries");
  ------------------
  |  |   71|    604|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1296|    604|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    604|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1297|    604|	}
 1298|       |
 1299|       |	/* See if we've been called from another card driver, which is
 1300|       |	 * passing an APDU to us (this allows to write card drivers
 1301|       |	 * whose PIN functions behave "mostly like ISO" except in some
 1302|       |	 * special circumstances.
 1303|       |	 */
 1304|  1.92k|	if (data->apdu == NULL) {
  ------------------
  |  Branch (1304:6): [True: 1.90k, False: 16]
  ------------------
 1305|  1.90k|		r = iso7816_build_pin_apdu(card, &local_apdu, data, sbuf, sizeof(sbuf));
 1306|  1.90k|		if (r < 0)
  ------------------
  |  Branch (1306:7): [True: 6, False: 1.89k]
  ------------------
 1307|      6|			return r;
 1308|  1.89k|		data->apdu = &local_apdu;
 1309|  1.89k|	}
 1310|  1.91k|	apdu = data->apdu;
 1311|       |
 1312|  1.91k|	if (!(data->flags & SC_PIN_CMD_USE_PINPAD) || data->cmd == SC_PIN_CMD_GET_INFO) {
  ------------------
  |  |  421|  1.91k|#define SC_PIN_CMD_USE_PINPAD		0x0001
  ------------------
              	if (!(data->flags & SC_PIN_CMD_USE_PINPAD) || data->cmd == SC_PIN_CMD_GET_INFO) {
  ------------------
  |  |  418|      0|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (1312:6): [True: 1.91k, False: 0]
  |  Branch (1312:48): [True: 0, False: 0]
  ------------------
 1313|       |		/* Transmit the APDU to the card */
 1314|  1.91k|		r = sc_transmit_apdu(card, apdu);
 1315|       |
 1316|       |		/* Clear the buffer - it may contain pins */
 1317|  1.91k|		sc_mem_clear(sbuf, sizeof(sbuf));
 1318|  1.91k|	}
 1319|      0|	else {
 1320|       |		/* Call the reader driver to collect
 1321|       |		 * the PIN and pass on the APDU to the card */
 1322|      0|		if (data->pin1.offset == 0) {
  ------------------
  |  Branch (1322:7): [True: 0, False: 0]
  ------------------
 1323|      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__
  |  |  ------------------
  ------------------
 1324|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1325|      0|		}
 1326|      0|		if (card->reader && card->reader->ops && card->reader->ops->perform_verify) {
  ------------------
  |  Branch (1326:7): [True: 0, False: 0]
  |  Branch (1326:23): [True: 0, False: 0]
  |  Branch (1326:44): [True: 0, False: 0]
  ------------------
 1327|      0|			r = card->reader->ops->perform_verify(card->reader, data);
 1328|       |			/* sw1/sw2 filled in by reader driver */
 1329|      0|		}
 1330|      0|		else {
 1331|      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__
  |  |  ------------------
  ------------------
 1332|      0|					"PIN entry through reader key pad");
 1333|      0|			r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1334|      0|		}
 1335|      0|	}
 1336|       |
 1337|       |	/* Don't pass references to local variables up to the caller. */
 1338|  1.91k|	if (data->apdu == &local_apdu)
  ------------------
  |  Branch (1338:6): [True: 1.89k, False: 16]
  ------------------
 1339|  1.89k|		data->apdu = NULL;
 1340|       |
 1341|  1.91k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  1.91k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.91k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.91k|	int _ret = (r); \
  |  |  |  |  168|  1.91k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 32, False: 1.88k]
  |  |  |  |  ------------------
  |  |  |  |  169|     32|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     32|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     32|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     32|		return _ret; \
  |  |  |  |  172|     32|	} \
  |  |  |  |  173|  1.91k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.88k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1342|  1.88k|	r = sc_check_sw(card, apdu->sw1, apdu->sw2);
 1343|       |
 1344|  1.88k|	if (r == SC_SUCCESS) {
  ------------------
  |  |   28|  1.88k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1344:6): [True: 989, False: 893]
  ------------------
 1345|    989|		data->pin1.logged_in = SC_PIN_STATE_LOGGED_IN;
  ------------------
  |  |  432|    989|#define SC_PIN_STATE_LOGGED_IN  2
  ------------------
 1346|    989|	} else if (r == SC_ERROR_PIN_CODE_INCORRECT) {
  ------------------
  |  |   64|    893|#define SC_ERROR_PIN_CODE_INCORRECT		-1214
  ------------------
  |  Branch (1346:13): [True: 2, False: 891]
  ------------------
 1347|      2|		data->pin1.tries_left = apdu->sw2 & 0xF;
 1348|      2|		data->pin1.logged_in = SC_PIN_STATE_LOGGED_OUT;
  ------------------
  |  |  431|      2|#define SC_PIN_STATE_LOGGED_OUT 1
  ------------------
 1349|      2|		if (data->cmd == SC_PIN_CMD_GET_INFO)
  ------------------
  |  |  418|      2|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (1349:7): [True: 1, False: 1]
  ------------------
 1350|      1|			r = SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
 1351|    891|	} else if (r == SC_ERROR_AUTH_METHOD_BLOCKED) {
  ------------------
  |  |   62|    891|#define SC_ERROR_AUTH_METHOD_BLOCKED		-1212
  ------------------
  |  Branch (1351:13): [True: 2, False: 889]
  ------------------
 1352|      2|		data->pin1.tries_left = 0;
 1353|      2|		data->pin1.logged_in = SC_PIN_STATE_LOGGED_OUT;
  ------------------
  |  |  431|      2|#define SC_PIN_STATE_LOGGED_OUT 1
  ------------------
 1354|      2|		if (data->cmd == SC_PIN_CMD_GET_INFO)
  ------------------
  |  |  418|      2|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (1354:7): [True: 1, False: 1]
  ------------------
 1355|      1|			r = SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
 1356|      2|	}
 1357|       |
 1358|  1.88k|	return r;
 1359|  1.91k|}
iso7816.c:iso7816_get_data:
 1363|    640|{
 1364|    640|	int                             r, cse;
 1365|    640|	struct sc_apdu                  apdu;
 1366|       |
 1367|    640|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    640|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    640|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    640|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 640]
  |  |  ------------------
  ------------------
 1368|       |
 1369|    640|	if (buf && len)
  ------------------
  |  Branch (1369:6): [True: 640, False: 0]
  |  Branch (1369:13): [True: 640, False: 0]
  ------------------
 1370|    640|		cse = SC_APDU_CASE_2;
  ------------------
  |  |  301|    640|#define SC_APDU_CASE_2			0x22
  ------------------
 1371|      0|	else
 1372|      0|		cse = SC_APDU_CASE_1;
  ------------------
  |  |  291|      0|#define SC_APDU_CASE_1			0x01
  ------------------
 1373|       |
 1374|    640|	sc_format_apdu(card, &apdu, cse, 0xCA, (tag >> 8) & 0xff, tag & 0xff);
 1375|    640|	apdu.le = len;
 1376|    640|	apdu.resp = buf;
 1377|    640|	apdu.resplen = len;
 1378|    640|	r = sc_transmit_apdu(card, &apdu);
 1379|    640|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    640|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    640|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    640|	int _ret = (r); \
  |  |  |  |  168|    640|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 4, False: 636]
  |  |  |  |  ------------------
  |  |  |  |  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|    640|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 636]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1380|       |
 1381|    636|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1382|    636|	LOG_TEST_RET(card->ctx, r, "GET_DATA returned error");
  ------------------
  |  |  174|    636|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    636|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    636|	int _ret = (r); \
  |  |  |  |  168|    636|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 403, False: 233]
  |  |  |  |  ------------------
  |  |  |  |  169|    403|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    403|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    403|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    403|		return _ret; \
  |  |  |  |  172|    403|	} \
  |  |  |  |  173|    636|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 233]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1383|       |
 1384|    233|	if (apdu.resplen > len)
  ------------------
  |  Branch (1384:6): [True: 0, False: 233]
  ------------------
 1385|      0|		r = SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|      0|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
 1386|    233|	else
 1387|    233|		r = (int)apdu.resplen;
 1388|       |
 1389|    233|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    233|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    233|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    233|	int _ret = r; \
  |  |  |  |  155|    233|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 131, False: 102]
  |  |  |  |  ------------------
  |  |  |  |  156|    131|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 131]
  |  |  |  |  ------------------
  |  |  |  |  157|    131|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    131|	} else { \
  |  |  |  |  159|    102|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    102|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    102|	} \
  |  |  |  |  162|    233|	return _ret; \
  |  |  |  |  163|    233|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1390|    233|}
iso7816.c:iso7816_read_binary:
  140|  12.0k|{
  141|  12.0k|	struct sc_context *ctx = card->ctx;
  142|  12.0k|	struct sc_apdu apdu;
  143|  12.0k|	int r;
  144|       |
  145|  12.0k|	if (idx > 0x7FFF) {
  ------------------
  |  Branch (145:6): [True: 3, False: 12.0k]
  ------------------
  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|  12.0k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0xB0, (idx >> 8) & 0x7F, idx & 0xFF);
  ------------------
  |  |  301|  12.0k|#define SC_APDU_CASE_2			0x22
  ------------------
  151|  12.0k|	apdu.le = count;
  152|  12.0k|	apdu.resplen = count;
  153|  12.0k|	apdu.resp = buf;
  154|       |
  155|  12.0k|	iso7816_fixup_transceive_length(card, &apdu);
  156|  12.0k|	r = sc_transmit_apdu(card, &apdu);
  157|  12.0k|	LOG_TEST_RET(ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  12.0k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  12.0k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  12.0k|	int _ret = (r); \
  |  |  |  |  168|  12.0k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 778, False: 11.2k]
  |  |  |  |  ------------------
  |  |  |  |  169|    778|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    778|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    778|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    778|		return _ret; \
  |  |  |  |  172|    778|	} \
  |  |  |  |  173|  12.0k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 11.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  158|       |
  159|  11.2k|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  160|  11.2k|	if (r == SC_ERROR_FILE_END_REACHED || r == SC_ERROR_INCORRECT_PARAMETERS)
  ------------------
  |  |   69|  22.5k|#define SC_ERROR_FILE_END_REACHED		-1219
  ------------------
              	if (r == SC_ERROR_FILE_END_REACHED || r == SC_ERROR_INCORRECT_PARAMETERS)
  ------------------
  |  |   55|  10.5k|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
  |  Branch (160:6): [True: 743, False: 10.5k]
  |  Branch (160:40): [True: 300, False: 10.2k]
  ------------------
  161|  11.2k|		LOG_FUNC_RETURN(ctx, (int)apdu.resplen);
  ------------------
  |  |  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: 256, False: 787]
  |  |  |  |  ------------------
  |  |  |  |  156|    256|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 256]
  |  |  |  |  ------------------
  |  |  |  |  157|    256|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    787|	} else { \
  |  |  |  |  159|    787|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    787|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    787|	} \
  |  |  |  |  162|  1.04k|	return _ret; \
  |  |  |  |  163|  1.04k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  162|  10.2k|	LOG_TEST_RET(ctx, r, "Check SW error");
  ------------------
  |  |  174|  10.2k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  10.2k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  10.2k|	int _ret = (r); \
  |  |  |  |  168|  10.2k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2.45k, False: 7.78k]
  |  |  |  |  ------------------
  |  |  |  |  169|  2.45k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  2.45k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  2.45k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  2.45k|		return _ret; \
  |  |  |  |  172|  2.45k|	} \
  |  |  |  |  173|  10.2k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 7.78k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  163|       |
  164|  7.78k|	LOG_FUNC_RETURN(ctx, (int)apdu.resplen);
  ------------------
  |  |  164|  7.78k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  7.78k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  7.78k|	int _ret = r; \
  |  |  |  |  155|  7.78k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 450, False: 7.33k]
  |  |  |  |  ------------------
  |  |  |  |  156|    450|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 450]
  |  |  |  |  ------------------
  |  |  |  |  157|    450|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  7.33k|	} else { \
  |  |  |  |  159|  7.33k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  7.33k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  7.33k|	} \
  |  |  |  |  162|  7.78k|	return _ret; \
  |  |  |  |  163|  7.78k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  165|  7.78k|}

sc_do_log:
   58|  15.1M|{
   59|  15.1M|	va_list ap;
   60|       |
   61|  15.1M|	va_start(ap, format);
   62|  15.1M|	sc_do_log_va(ctx, level, file, line, func, 0, format, ap);
   63|       |	va_end(ap);
   64|  15.1M|}
sc_do_log_color:
   67|  3.72M|{
   68|  3.72M|	va_list ap;
   69|       |
   70|  3.72M|	va_start(ap, format);
   71|  3.72M|	sc_do_log_va(ctx, level, file, line, func, color, format, ap);
   72|       |	va_end(ap);
   73|  3.72M|}
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|   436k|{
  344|   436k|	size_t blen;
  345|   436k|	char *buf;
  346|   436k|	const char *truncated = "";
  347|       |
  348|   436k|	if (len > SC_MAX_EXT_APDU_BUFFER_SIZE) {
  ------------------
  |  |   37|   436k|#define SC_MAX_EXT_APDU_BUFFER_SIZE	65538
  ------------------
  |  Branch (348:6): [True: 0, False: 436k]
  ------------------
  349|      0|		len = SC_MAX_EXT_APDU_BUFFER_SIZE;
  ------------------
  |  |   37|      0|#define SC_MAX_EXT_APDU_BUFFER_SIZE	65538
  ------------------
  350|      0|		truncated = "truncated to ";
  351|      0|	}
  352|   436k|	blen = len * 5 + 128;
  353|       |
  354|   436k|	buf = malloc(blen);
  355|   436k|	if (buf == NULL)
  ------------------
  |  Branch (355:6): [True: 0, False: 436k]
  ------------------
  356|      0|		return;
  357|       |
  358|   436k|	sc_hex_dump(data, len, buf, blen);
  359|       |
  360|   436k|	if (label)
  ------------------
  |  Branch (360:6): [True: 436k, False: 0]
  ------------------
  361|   436k|		sc_do_log(ctx, type, file, line, func, "\n%s (%s%zu byte%s):\n%s",
  362|   436k|				label, truncated, len, len == 1 ? "" : "s", buf);
  ------------------
  |  Branch (362:28): [True: 999, False: 435k]
  ------------------
  363|      0|	else
  364|      0|		sc_do_log(ctx, type, file, line, func, "%s%zu byte%s:\n%s",
  365|      0|				truncated, len, len == 1 ? "" : "s", buf);
  ------------------
  |  Branch (365:21): [True: 0, False: 0]
  ------------------
  366|       |
  367|   436k|	free(buf);
  368|   436k|}
sc_hex_dump:
  371|   436k|{
  372|   436k|	char *p = buf;
  373|   436k|	size_t p_len = len;
  374|   436k|	int lines = 0;
  375|       |
  376|   436k|	if (buf == NULL || (in == NULL && count != 0)) {
  ------------------
  |  Branch (376:6): [True: 0, False: 436k]
  |  Branch (376:22): [True: 279, False: 436k]
  |  Branch (376:36): [True: 0, False: 279]
  ------------------
  377|      0|		return;
  378|      0|	}
  379|   436k|	buf[0] = 0;
  380|   436k|	if ((count * 5) > len)
  ------------------
  |  Branch (380:6): [True: 0, False: 436k]
  ------------------
  381|      0|		return;
  382|  2.20M|	while (count) {
  ------------------
  |  Branch (382:9): [True: 1.77M, False: 436k]
  ------------------
  383|  1.77M|		char ascbuf[17];
  384|  1.77M|		size_t i;
  385|       |
  386|  26.4M|		for (i = 0; i < count && i < 16; i++) {
  ------------------
  |  Branch (386:15): [True: 26.1M, False: 361k]
  |  Branch (386:28): [True: 24.6M, False: 1.40M]
  ------------------
  387|  24.6M|			sprintf(p, "%02X ", *in);
  388|  24.6M|			if (isprint(*in))
  ------------------
  |  Branch (388:8): [True: 12.7M, False: 11.9M]
  ------------------
  389|  12.7M|				ascbuf[i] = *in;
  390|  11.9M|			else
  391|  11.9M|				ascbuf[i] = '.';
  392|  24.6M|			p += 3;
  393|  24.6M|			p_len -= 3;
  394|  24.6M|			in++;
  395|  24.6M|		}
  396|  1.77M|		count -= i;
  397|  1.77M|		ascbuf[i] = 0;
  398|  4.03M|		for (; i < 16 && lines; i++) {
  ------------------
  |  Branch (398:10): [True: 2.37M, False: 1.65M]
  |  Branch (398:20): [True: 2.26M, False: 116k]
  ------------------
  399|  2.26M|			strlcat(p, "   ", p_len);
  400|  2.26M|			p += 3;
  401|  2.26M|			p_len -= 3;
  402|  2.26M|		}
  403|  1.77M|		snprintf(p, p_len, "%s\n", ascbuf);
  404|  1.77M|		p += strlen(ascbuf) + 1;
  405|  1.77M|		p_len -= strlen(ascbuf) - 1;
  406|  1.77M|		lines++;
  407|  1.77M|	}
  408|   436k|}
sc_dump_hex:
  412|   128k|{
  413|   128k|	static char dump_buf[0x1000];
  414|   128k|	size_t ii, size = sizeof(dump_buf) - 0x10;
  415|   128k|	size_t offs = 0;
  416|       |
  417|   128k|	memset(dump_buf, 0, sizeof(dump_buf));
  418|   128k|	if (in == NULL)
  ------------------
  |  Branch (418:6): [True: 0, False: 128k]
  ------------------
  419|      0|		return dump_buf;
  420|       |
  421|   266k|	for (ii=0; ii<count; ii++) {
  ------------------
  |  Branch (421:13): [True: 137k, False: 128k]
  ------------------
  422|   137k|		if (ii && !(ii%16))   {
  ------------------
  |  Branch (422:7): [True: 121k, False: 16.2k]
  |  Branch (422:13): [True: 1.06k, False: 120k]
  ------------------
  423|  1.06k|			if (!(ii%48))
  ------------------
  |  Branch (423:8): [True: 264, False: 798]
  ------------------
  424|    264|				snprintf(dump_buf + offs, size - offs, "\n");
  425|    798|			else
  426|    798|				snprintf(dump_buf + offs, size - offs, " ");
  427|  1.06k|			offs = strlen(dump_buf);
  428|  1.06k|		}
  429|       |
  430|   137k|		snprintf(dump_buf + offs, size - offs, "%02X", *(in + ii));
  431|   137k|		offs += 2;
  432|       |
  433|   137k|		if (offs > size)
  ------------------
  |  Branch (433:7): [True: 2, False: 137k]
  ------------------
  434|      2|			break;
  435|   137k|	}
  436|       |
  437|   128k|	if (ii<count)
  ------------------
  |  Branch (437:6): [True: 2, False: 128k]
  ------------------
  438|      2|		snprintf(dump_buf + offs, sizeof(dump_buf) - offs, "....\n");
  439|       |
  440|   128k|	return dump_buf;
  441|   128k|}
sc_dump_oid:
  445|  3.61k|{
  446|  3.61k|	static char dump_buf[SC_MAX_OBJECT_ID_OCTETS * 20];
  447|  3.61k|        size_t ii;
  448|       |
  449|  3.61k|	memset(dump_buf, 0, sizeof(dump_buf));
  450|  3.61k|	if (oid)
  ------------------
  |  Branch (450:6): [True: 3.61k, False: 0]
  ------------------
  451|  24.0k|		for (ii=0; ii<SC_MAX_OBJECT_ID_OCTETS && oid->value[ii] != -1; ii++)
  ------------------
  |  |   46|  48.1k|#define SC_MAX_OBJECT_ID_OCTETS		16
  ------------------
  |  Branch (451:14): [True: 24.0k, False: 0]
  |  Branch (451:44): [True: 20.4k, False: 3.61k]
  ------------------
  452|  20.4k|			snprintf(dump_buf + strlen(dump_buf), sizeof(dump_buf) - strlen(dump_buf), "%s%i", (ii ? "." : ""), oid->value[ii]);
  ------------------
  |  Branch (452:88): [True: 16.8k, False: 3.61k]
  ------------------
  453|       |
  454|  3.61k|	return dump_buf;
  455|  3.61k|}
log.c:sc_do_log_va:
  124|  18.8M|{
  125|       |#ifdef _WIN32
  126|       |	SYSTEMTIME st;
  127|       |#else
  128|  18.8M|	struct tm *tm;
  129|  18.8M|	struct timeval tv;
  130|  18.8M|	char time_string[40];
  131|  18.8M|#endif
  132|       |
  133|  18.8M|	if (!ctx || ctx->debug < level)
  ------------------
  |  Branch (133:6): [True: 0, False: 18.8M]
  |  Branch (133:14): [True: 18.8M, False: 0]
  ------------------
  134|  18.8M|		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|  3.74k|mscfs_t *mscfs_new(void) {
   46|  3.74k|	mscfs_t *fs = malloc(sizeof(mscfs_t));
   47|  3.74k|	if (!fs)
  ------------------
  |  Branch (47:6): [True: 0, False: 3.74k]
  ------------------
   48|      0|		return NULL;
   49|  3.74k|	memset(fs, 0, sizeof(mscfs_t));
   50|  3.74k|	memcpy(fs->currentPath, "\x3F\x00", 2);
   51|  3.74k|	return fs;
   52|  3.74k|}
mscfs_free:
   54|  3.74k|void mscfs_free(mscfs_t *fs) {
   55|  3.74k|	mscfs_clear_cache(fs);
   56|  3.74k|	free(fs);
   57|  3.74k|}
mscfs_clear_cache:
   59|  9.44k|void mscfs_clear_cache(mscfs_t* fs) {
   60|  9.44k|	if(!fs->cache.array) {
  ------------------
  |  Branch (60:5): [True: 8.65k, False: 789]
  ------------------
   61|  8.65k|		return;
   62|  8.65k|	}
   63|    789|	free(fs->cache.array);
   64|       |	fs->cache.array = NULL;
   65|    789|	fs->cache.totalSize = 0;
   66|    789|	fs->cache.size = 0;
   67|    789|}
mscfs_push_file:
   83|   175k|{
   84|   175k|	mscfs_cache_t *cache = &fs->cache;
   85|   175k|	if (cache->size >= MAX_FILES)
  ------------------
  |  |   81|   175k|#define MAX_FILES 10000
  ------------------
  |  Branch (85:6): [True: 2, False: 175k]
  ------------------
   86|      2|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      2|#define SC_ERROR_INTERNAL			-1400
  ------------------
   87|   175k|	if(!cache->array || cache->size == cache->totalSize) {
  ------------------
  |  Branch (87:5): [True: 789, False: 175k]
  |  Branch (87:22): [True: 1.31k, False: 173k]
  ------------------
   88|  2.10k|		int length = cache->totalSize + MSCFS_CACHE_INCREMENT;
  ------------------
  |  |   35|  2.10k|#define MSCFS_CACHE_INCREMENT 128
  ------------------
   89|  2.10k|		mscfs_file_t *oldArray;
   90|  2.10k|		cache->totalSize = length;
   91|  2.10k|		oldArray = cache->array;
   92|  2.10k|		cache->array = malloc(sizeof(mscfs_file_t) * length);
   93|  2.10k|		if(!cache->array)
  ------------------
  |  Branch (93:6): [True: 0, False: 2.10k]
  ------------------
   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|  2.10k|		if(oldArray) {
  ------------------
  |  Branch (95:6): [True: 1.31k, False: 789]
  ------------------
   96|  1.31k|			memcpy(cache->array, oldArray, sizeof(mscfs_file_t) * cache->size);
   97|  1.31k|			free(oldArray);
   98|  1.31k|		}
   99|  2.10k|	}
  100|   175k|	cache->array[cache->size] = *file;
  101|   175k|	cache->size++;
  102|   175k|	return SC_SUCCESS;
  ------------------
  |  |   28|   175k|#define SC_SUCCESS				0
  ------------------
  103|   175k|}
mscfs_update_cache:
  105|  5.40k|int mscfs_update_cache(mscfs_t* fs) {
  106|  5.40k|	mscfs_file_t file;
  107|  5.40k|	int r;
  108|  5.40k|	mscfs_clear_cache(fs);
  109|  5.40k|	r = fs->listFile(&file, 1, fs->udata);
  110|  5.40k|	if(r == 0)
  ------------------
  |  Branch (110:5): [True: 67, False: 5.33k]
  ------------------
  111|     67|		return 0;
  112|  5.33k|	else if(r < 0)
  ------------------
  |  Branch (112:10): [True: 4.51k, False: 823]
  ------------------
  113|  4.51k|		return r;
  114|   175k|	while(1) {
  ------------------
  |  Branch (114:8): [True: 175k, Folded]
  ------------------
  115|   175k|		if(!mscfs_is_ignored(fs, file.objectId)) {
  ------------------
  |  Branch (115:6): [True: 175k, False: 58]
  ------------------
  116|       |			/* Check if its a directory in the root */
  117|   175k|			u8* oid = file.objectId.id;
  118|   175k|			if(oid[2] == 0 && oid[3] == 0) {
  ------------------
  |  Branch (118:7): [True: 156k, False: 18.9k]
  |  Branch (118:22): [True: 150k, False: 6.25k]
  ------------------
  119|   150k|				oid[2] = oid[0];
  120|   150k|				oid[3] = oid[1];
  121|   150k|				oid[0] = 0x3F;
  122|   150k|				oid[1] = 0x00;
  123|   150k|				file.ef = 0;
  124|   150k|			} else  {
  125|  25.2k|				file.ef = 1; /* File is a working elementary file */
  126|  25.2k|			}
  127|       |
  128|   175k|			r = mscfs_push_file(fs, &file);
  129|   175k|			if (r != SC_SUCCESS)
  ------------------
  |  |   28|   175k|#define SC_SUCCESS				0
  ------------------
  |  Branch (129:8): [True: 2, False: 175k]
  ------------------
  130|      2|				return r;
  131|   175k|		}
  132|   175k|		r = fs->listFile(&file, 0, fs->udata);
  133|   175k|		if(r == 0)
  ------------------
  |  Branch (133:6): [True: 113, False: 175k]
  ------------------
  134|    113|			break;
  135|   175k|		else if(r < 0)
  ------------------
  |  Branch (135:11): [True: 708, False: 175k]
  ------------------
  136|    708|			return r;
  137|   175k|	}
  138|    113|	return fs->cache.size;
  139|    823|}
mscfs_check_cache:
  142|   143k|{
  143|   143k|	int r = SC_SUCCESS;
  ------------------
  |  |   28|   143k|#define SC_SUCCESS				0
  ------------------
  144|   143k|	if(!fs->cache.array) {
  ------------------
  |  Branch (144:5): [True: 5.40k, False: 138k]
  ------------------
  145|  5.40k|		r = mscfs_update_cache(fs);
  146|  5.40k|	}
  147|   143k|	return r;
  148|   143k|}
mscfs_lookup_path:
  151|  5.43k|{
  152|  5.43k|	u8* oid = objectId->id;
  153|  5.43k|	if ((pathlen & 1) != 0) /* not divisible by 2 */
  ------------------
  |  Branch (153:6): [True: 571, False: 4.85k]
  ------------------
  154|    571|		return MSCFS_INVALID_ARGS;
  ------------------
  |  |   33|    571|#define MSCFS_INVALID_ARGS 	SC_ERROR_INVALID_ARGUMENTS
  |  |  ------------------
  |  |  |  |   73|    571|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  |  |  ------------------
  ------------------
  155|  4.85k|	if(isDirectory) {
  ------------------
  |  Branch (155:5): [True: 0, False: 4.85k]
  ------------------
  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|  4.85k|	oid[0] = fs->currentPath[0];
  167|  4.85k|	oid[1] = fs->currentPath[1];
  168|       |	/* Chop off the root in the path */
  169|  4.85k|	if(pathlen > 2 && memcmp(path, "\x3F\x00", 2) == 0) {
  ------------------
  |  Branch (169:5): [True: 3.61k, False: 1.24k]
  |  Branch (169:20): [True: 3.43k, False: 177]
  ------------------
  170|  3.43k|		path += 2;
  171|  3.43k|		pathlen -= 2;
  172|  3.43k|		oid[0] = 0x3F;
  173|  3.43k|		oid[1] = 0x00;
  174|  3.43k|	}
  175|       |	/* Limit to a single directory */
  176|  4.85k|	if(pathlen > 4)
  ------------------
  |  Branch (176:5): [True: 13, False: 4.84k]
  ------------------
  177|     13|		return MSCFS_INVALID_ARGS;
  ------------------
  |  |   33|     13|#define MSCFS_INVALID_ARGS 	SC_ERROR_INVALID_ARGUMENTS
  |  |  ------------------
  |  |  |  |   73|     13|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  |  |  ------------------
  ------------------
  178|       |	/* Reset to root */
  179|  4.84k|	if(pathlen == 2 && 0 == memcmp(path, "\x3F\x00", 2)) {
  ------------------
  |  Branch (179:5): [True: 2.85k, False: 1.98k]
  |  Branch (179:21): [True: 884, False: 1.97k]
  ------------------
  180|    884|		oid[0] = oid[2] = path[0];
  181|    884|		oid[1] = oid[3] = path[1];
  182|  3.96k|	} else if(pathlen == 2) { /* Path preserved for current-path */
  ------------------
  |  Branch (182:12): [True: 1.97k, False: 1.98k]
  ------------------
  183|  1.97k|		oid[2] = path[0];
  184|  1.97k|		oid[3] = path[1];
  185|  1.98k|	} else if(pathlen == 4) {
  ------------------
  |  Branch (185:12): [True: 1.78k, False: 204]
  ------------------
  186|  1.78k|		oid[0] = path[0];
  187|  1.78k|		oid[1] = path[1];
  188|  1.78k|		oid[2] = path[2];
  189|  1.78k|		oid[3] = path[3];
  190|  1.78k|	}
  191|       |
  192|  4.84k|	return 0;
  193|  4.85k|}
mscfs_lookup_local:
  196|      3|{
  197|      3|	u8* oid = objectId->id;
  198|      3|	oid[0] = fs->currentPath[0];
  199|      3|	oid[1] = fs->currentPath[1];
  200|      3|	oid[2] = (id >> 8) & 0xFF;
  201|      3|	oid[3] = id & 0xFF;
  202|      3|	return 0;
  203|      3|}
mscfs_check_selection:
  207|  3.97k|{
  208|  3.97k|	if(fs->currentPath[0] == 0 && fs->currentPath[1] == 0)
  ------------------
  |  Branch (208:5): [True: 3.48k, False: 488]
  |  Branch (208:32): [True: 0, False: 3.48k]
  ------------------
  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|  3.97k|	if(requiredItem == 1 && fs->currentFile[0] == 0 && fs->currentFile[1] == 0)
  ------------------
  |  Branch (210:5): [True: 0, False: 3.97k]
  |  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|  3.97k|	return 0;
  213|  3.97k|}
mscfs_loadFileInfo:
  216|  5.43k|{
  217|  5.43k|	msc_id fullPath = {{0, 0, 0, 0}};
  218|  5.43k|	int x, rc;
  219|  5.43k|	if (fs == NULL || path == NULL || file_data == NULL)
  ------------------
  |  Branch (219:6): [True: 0, False: 5.43k]
  |  Branch (219:20): [True: 0, False: 5.43k]
  |  Branch (219:36): [True: 0, False: 5.43k]
  ------------------
  220|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  221|  5.43k|	rc = mscfs_lookup_path(fs, path, pathlen, &fullPath, 0);
  222|  5.43k|	if (rc != SC_SUCCESS) {
  ------------------
  |  |   28|  5.43k|#define SC_SUCCESS				0
  ------------------
  |  Branch (222:6): [True: 584, False: 4.84k]
  ------------------
  223|    584|		return rc;
  224|    584|	}
  225|       |
  226|       |	/* Obtain file information while checking if it exists */
  227|  4.84k|	rc = mscfs_check_cache(fs);
  228|  4.84k|	if (rc < 0)
  ------------------
  |  Branch (228:6): [True: 42, False: 4.80k]
  ------------------
  229|     42|		return rc;
  230|  4.80k|	if(idx) *idx = -1;
  ------------------
  |  Branch (230:5): [True: 4.54k, False: 258]
  ------------------
  231|   550k|	for(x = 0; x < fs->cache.size; x++) {
  ------------------
  |  Branch (231:13): [True: 548k, False: 2.22k]
  ------------------
  232|   548k|		*file_data = &fs->cache.array[x];
  233|   548k|		if (*file_data) {
  ------------------
  |  Branch (233:7): [True: 548k, False: 0]
  ------------------
  234|   548k|			msc_id objectId;
  235|   548k|			objectId = (*file_data)->objectId;
  236|   548k|			if(0 == memcmp(objectId.id, fullPath.id, 4)) {
  ------------------
  |  Branch (236:7): [True: 2.58k, False: 545k]
  ------------------
  237|  2.58k|				if (idx)
  ------------------
  |  Branch (237:9): [True: 2.39k, False: 191]
  ------------------
  238|  2.39k|					*idx = x;
  239|  2.58k|				break;
  240|  2.58k|			}
  241|   545k|			*file_data = NULL;
  242|   545k|		}
  243|   548k|	}
  244|  4.80k|	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: 2.22k, False: 2.58k]
  |  Branch (244:28): [True: 52, False: 2.17k]
  |  Branch (244:79): [True: 824, False: 1.34k]
  |  Branch (244:131): [True: 212, False: 1.13k]
  ------------------
  245|  1.08k|		static mscfs_file_t ROOT_FILE;
  246|  1.08k|		ROOT_FILE.ef = 0;
  247|  1.08k|		ROOT_FILE.size = 0;
  248|       |		/* Faked Root ID */
  249|  1.08k|		ROOT_FILE.objectId = rootId;
  250|       |
  251|  1.08k|		ROOT_FILE.read = 0;
  252|  1.08k|		ROOT_FILE.write = 0x02; /* User Pin access */
  253|  1.08k|		ROOT_FILE.delete = 0x02;
  254|       |
  255|  1.08k|		*file_data = &ROOT_FILE;
  256|  1.08k|		if(idx) *idx = -2;
  ------------------
  |  Branch (256:6): [True: 1.08k, False: 0]
  ------------------
  257|  3.71k|	} else if(*file_data == NULL) {
  ------------------
  |  Branch (257:12): [True: 1.13k, False: 2.58k]
  ------------------
  258|  1.13k|		return MSCFS_FILE_NOT_FOUND;
  ------------------
  |  |   34|  1.13k|#define MSCFS_FILE_NOT_FOUND 	SC_ERROR_FILE_NOT_FOUND
  |  |  ------------------
  |  |  |  |   51|  1.13k|#define SC_ERROR_FILE_NOT_FOUND			-1201
  |  |  ------------------
  ------------------
  259|  1.13k|	}
  260|       |
  261|  3.66k|	return 0;
  262|  4.80k|}
muscle-filesystem.c:mscfs_is_ignored:
   70|   175k|{
   71|   175k|	int ignored = 0;
   72|   175k|	const u8** ptr = ignoredFiles;
   73|   527k|	while(ptr && *ptr && !ignored) {
  ------------------
  |  Branch (73:8): [True: 527k, False: 0]
  |  Branch (73:15): [True: 351k, False: 175k]
  |  Branch (73:23): [True: 351k, False: 55]
  ------------------
   74|   351k|		if(0 == memcmp(objectId.id, *ptr, 4))
  ------------------
  |  Branch (74:6): [True: 58, False: 351k]
  ------------------
   75|     58|			ignored = 1;
   76|   351k|		ptr++;
   77|   351k|	}
   78|   175k|	return ignored;
   79|   175k|}

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

sc_asn1_encode_algorithm_id:
  547|     14|{
  548|     14|	struct sc_asn1_pkcs15_algorithm_info *alg_info;
  549|     14|	struct sc_algorithm_id temp_id;
  550|     14|	struct sc_asn1_entry asn1_alg_id[3];
  551|     14|	u8 *obj = NULL;
  552|     14|	size_t obj_len = 0;
  553|     14|	int r;
  554|     14|	u8 *tmp;
  555|       |
  556|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  557|     14|        sc_log(ctx, "type of algorithm to encode: %lu", id->algorithm);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  558|     14|	alg_info = sc_asn1_get_algorithm_info(id);
  559|     14|	if (alg_info == NULL) {
  ------------------
  |  Branch (559:6): [True: 0, False: 14]
  ------------------
  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|     14|	if (!sc_valid_oid(&id->oid)) {
  ------------------
  |  Branch (565:6): [True: 14, False: 0]
  ------------------
  566|     14|		temp_id = *id;
  567|     14|		temp_id.oid = alg_info->oid;
  568|     14|		id = &temp_id;
  569|     14|	}
  570|       |
  571|     14|        sc_log(ctx, "encode algo %s", sc_dump_oid(&(id->oid)));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  572|     14|	sc_copy_asn1_entry(c_asn1_alg_id, asn1_alg_id);
  573|     14|	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|     14|	if (id->algorithm != SC_ALGORITHM_EDDSA &&
  ------------------
  |  |   72|     28|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (579:6): [True: 14, False: 0]
  ------------------
  580|     14|	    id->algorithm != SC_ALGORITHM_XEDDSA &&
  ------------------
  |  |   73|     28|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (580:6): [True: 14, False: 0]
  ------------------
  581|     14|	    (!id->params || !alg_info->encode))
  ------------------
  |  Branch (581:7): [True: 6, False: 8]
  |  Branch (581:22): [True: 0, False: 8]
  ------------------
  582|      6|		asn1_alg_id[1].flags |= SC_ASN1_PRESENT;
  ------------------
  |  |  147|      6|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  583|       |
  584|     14|	r = _sc_asn1_encode(ctx, asn1_alg_id, buf, len, depth + 1);
  585|     14|	LOG_TEST_RET(ctx, r, "ASN.1 encode of algorithm 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  586|       |
  587|       |	/* Encode any parameters */
  588|     14|	if (id->params && alg_info->encode) {
  ------------------
  |  Branch (588:6): [True: 8, False: 6]
  |  Branch (588:20): [True: 8, False: 0]
  ------------------
  589|      8|		r = alg_info->encode(ctx, id->params, &obj, &obj_len, depth+1);
  590|      8|		if (r < 0) {
  ------------------
  |  Branch (590:7): [True: 0, False: 8]
  ------------------
  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|      8|	}
  596|       |
  597|     14|	if (obj_len) {
  ------------------
  |  Branch (597:6): [True: 8, False: 6]
  ------------------
  598|      8|		tmp = (u8 *) realloc(*buf, *len + obj_len);
  599|      8|		if (!tmp) {
  ------------------
  |  Branch (599:7): [True: 0, False: 8]
  ------------------
  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|      8|		*buf = tmp;
  606|      8|		memcpy(*buf + *len, obj, obj_len);
  607|      8|		*len += obj_len;
  608|      8|		free(obj);
  609|      8|	}
  610|       |
  611|     14|	sc_log(ctx, "return encoded algorithm ID: %s", sc_dump_hex(*buf, *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__
  |  |  ------------------
  ------------------
  612|     14|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     14|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     14|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     14|	int _ret = r; \
  |  |  |  |  155|     14|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 14, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     14|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 14]
  |  |  |  |  ------------------
  |  |  |  |  157|     14|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     14|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     14|	return _ret; \
  |  |  |  |  163|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  613|     14|}
sc_asn1_clear_algorithm_id:
  617|     66|{
  618|     66|	struct sc_asn1_pkcs15_algorithm_info *aip;
  619|       |
  620|     66|	if (id->params && (aip = sc_asn1_get_algorithm_info(id)) && aip->free) {
  ------------------
  |  Branch (620:6): [True: 8, False: 58]
  |  Branch (620:20): [True: 8, False: 0]
  |  Branch (620:62): [True: 8, False: 0]
  ------------------
  621|      8|		aip->free(id->params);
  622|       |		id->params = NULL;
  623|      8|	}
  624|     66|}
pkcs15-algo.c:sc_asn1_get_algorithm_info:
  486|     22|{
  487|     22|	struct sc_asn1_pkcs15_algorithm_info *aip = NULL;
  488|       |
  489|    238|	for (aip = algorithm_table; aip->id >= 0; aip++)   {
  ------------------
  |  Branch (489:30): [True: 238, False: 0]
  ------------------
  490|    238|		if ((int) id->algorithm < 0 && sc_compare_oid(&id->oid, &aip->oid))
  ------------------
  |  Branch (490:7): [True: 0, False: 238]
  |  Branch (490:34): [True: 0, False: 0]
  ------------------
  491|      0|			return aip;
  492|       |
  493|    238|		if (aip->id == (int)id->algorithm)
  ------------------
  |  Branch (493:7): [True: 22, False: 216]
  ------------------
  494|     22|			return aip;
  495|    238|	}
  496|       |
  497|      0|	return NULL;
  498|     22|}
pkcs15-algo.c:asn1_encode_ec_params:
  314|      8|{
  315|      8|	 struct sc_ec_parameters *ecp = (struct sc_ec_parameters *) params;
  316|       |
  317|       |	/* Only handle named curves. They may be absent too */
  318|      8|	sc_debug(ctx, SC_LOG_DEBUG_ASN1, "asn1_encode_ec_params() called");
  ------------------
  |  |   70|      8|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  319|      8|	*buf = NULL;
  320|      8|	*buflen = 0;
  321|      8|	if (ecp && ecp->type == 1 && ecp->der.value) { /* named curve */
  ------------------
  |  Branch (321:6): [True: 8, False: 0]
  |  Branch (321:13): [True: 8, False: 0]
  |  Branch (321:31): [True: 8, False: 0]
  ------------------
  322|      8|		*buf = malloc(ecp->der.len);
  323|      8|		if (*buf == NULL)
  ------------------
  |  Branch (323:7): [True: 0, False: 8]
  ------------------
  324|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  325|       |
  326|      8|		memcpy(*buf, ecp->der.value, ecp->der.len);
  327|      8|		*buflen = ecp->der.len;
  328|      8|	}
  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|      8|	return 0;
  334|      8|}
pkcs15-algo.c:asn1_free_ec_params:
  338|      8|{
  339|      8|	struct sc_ec_parameters *ecp = (struct sc_ec_parameters *) params;
  340|       |
  341|      8|	if (ecp) {
  ------------------
  |  Branch (341:6): [True: 8, False: 0]
  ------------------
  342|      8|		if (ecp->der.value)
  ------------------
  |  Branch (342:7): [True: 8, False: 0]
  ------------------
  343|      8|			free(ecp->der.value);
  344|      8|		if (ecp->named_curve)
  ------------------
  |  Branch (344:7): [True: 0, False: 8]
  ------------------
  345|      0|			free(ecp->named_curve);
  346|      8|		free(ecp);
  347|      8|	}
  348|      8|}

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

sc_pkcs15_read_cached_file:
  113|  4.22k|{
  114|  4.22k|	char fname[PATH_MAX];
  115|  4.22k|	int rv;
  116|  4.22k|	FILE *f;
  117|  4.22k|	size_t count;
  118|  4.22k|	struct stat stbuf;
  119|  4.22k|	u8 *data = NULL;
  120|       |
  121|  4.22k|	if (path->len < 2)
  ------------------
  |  Branch (121:6): [True: 201, False: 4.02k]
  ------------------
  122|    201|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|    201|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  123|       |
  124|       |	/* Accept full path or FILE-ID path with AID */
  125|  4.02k|	if ((path->type != SC_PATH_TYPE_PATH) && (path->type != SC_PATH_TYPE_FILE_ID || path->aid.len == 0))
  ------------------
  |  |  119|  4.02k|#define SC_PATH_TYPE_PATH		2
  ------------------
              	if ((path->type != SC_PATH_TYPE_PATH) && (path->type != SC_PATH_TYPE_FILE_ID || path->aid.len == 0))
  ------------------
  |  |  117|  3.74k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (125:6): [True: 1.87k, False: 2.15k]
  |  Branch (125:44): [True: 0, False: 1.87k]
  |  Branch (125:82): [True: 1.87k, False: 0]
  ------------------
  126|  1.87k|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|  1.87k|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  127|       |
  128|  2.15k|	sc_log(p15card->card->ctx, "try to read cache for %s", sc_print_path(path));
  ------------------
  |  |   71|  2.15k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  129|  2.15k|	rv = generate_cache_filename(p15card, path, fname, sizeof(fname));
  130|  2.15k|	if (rv != SC_SUCCESS)
  ------------------
  |  |   28|  2.15k|#define SC_SUCCESS				0
  ------------------
  |  Branch (130:6): [True: 2.13k, False: 15]
  ------------------
  131|  2.13k|		return rv;
  132|     15|	sc_log(p15card->card->ctx, "read cached file %s", fname);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  133|       |
  134|     15|	f = fopen(fname, "rb");
  135|     15|	if (!f)
  ------------------
  |  Branch (135:6): [True: 14, False: 1]
  ------------------
  136|     14|		return SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|     14|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  137|      1|	if (fstat(fileno(f), &stbuf))   {
  ------------------
  |  Branch (137:6): [True: 0, False: 1]
  ------------------
  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|      1|	if (path->count < 0) {
  ------------------
  |  Branch (142:6): [True: 1, False: 0]
  ------------------
  143|      1|		count = stbuf.st_size;
  144|      1|	}
  145|      0|	else {
  146|      0|		count = path->count;
  147|      0|		if (path->index + count > (size_t)stbuf.st_size)   {
  ------------------
  |  Branch (147:7): [True: 0, False: 0]
  ------------------
  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|      0|		if (0 != fseek(f, (long)path->index, SEEK_SET)) {
  ------------------
  |  Branch (152:7): [True: 0, False: 0]
  ------------------
  153|      0|			rv = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  154|      0|			goto err;
  155|      0|		}
  156|      0|	}
  157|       |
  158|      1|	if (*buf == NULL) {
  ------------------
  |  Branch (158:6): [True: 0, False: 1]
  ------------------
  159|      0|		data = malloc((size_t)stbuf.st_size);
  160|      0|		if (data == NULL)   {
  ------------------
  |  Branch (160:7): [True: 0, False: 0]
  ------------------
  161|      0|			rv = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  162|      0|			goto err;
  163|      0|		}
  164|      0|	}
  165|      1|	else {
  166|      1|		if (count > *bufsize) {
  ------------------
  |  Branch (166:7): [True: 0, False: 1]
  ------------------
  167|      0|			rv =  SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  168|      0|			goto err;
  169|      0|		}
  170|      1|		data = *buf;
  171|      1|	}
  172|       |
  173|      1|	if (count != fread(data, 1, count, f)) {
  ------------------
  |  Branch (173:6): [True: 0, False: 1]
  ------------------
  174|      0|		rv = SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  175|      0|		goto err;
  176|      0|	}
  177|      1|	*buf = data;
  178|      1|	*bufsize = count;
  179|       |
  180|      1|	rv = SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
  181|       |
  182|      1|err:
  183|      1|	if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
  |  Branch (183:6): [True: 0, False: 1]
  ------------------
  184|      0|		if (data != *buf) {
  ------------------
  |  Branch (184:7): [True: 0, False: 0]
  ------------------
  185|      0|			free(data);
  186|      0|		}
  187|      0|	}
  188|       |
  189|      1|	fclose(f);
  190|      1|	return rv;
  191|      1|}
sc_pkcs15_cache_file:
  196|    239|{
  197|    239|	char fname[PATH_MAX];
  198|    239|	int r;
  199|    239|	long len;
  200|    239|	FILE *f;
  201|    239|	size_t c;
  202|       |
  203|    239|	r = generate_cache_filename(p15card, path, fname, sizeof(fname));
  204|    239|	if (r != 0)
  ------------------
  |  Branch (204:6): [True: 232, False: 7]
  ------------------
  205|    232|		return r;
  206|       |
  207|      7|	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|      7|	if (f == NULL && errno == ENOENT) {
  ------------------
  |  Branch (211:6): [True: 0, False: 7]
  |  Branch (211:19): [True: 0, False: 0]
  ------------------
  212|      0|		if ((r = sc_make_cache_dir(p15card->card->ctx)) < 0)
  ------------------
  |  Branch (212:7): [True: 0, False: 0]
  ------------------
  213|      0|			return r;
  214|      0|		f = fopen(fname, "ab");
  215|      0|	}
  216|      7|	if (f == NULL)
  ------------------
  |  Branch (216:6): [True: 0, False: 7]
  ------------------
  217|      0|		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|      7|	len = ftell(f);
  222|      7|	if (len > path->index) {
  ------------------
  |  Branch (222:6): [True: 3, False: 4]
  ------------------
  223|       |		/* override previous cache records on this location */
  224|      3|		r = fseek(f, path->index, SEEK_SET);
  225|      3|		if (r != 0) {
  ------------------
  |  Branch (225:7): [True: 0, False: 3]
  ------------------
  226|      0|			fclose(f);
  227|      0|			return 0;
  228|      0|		}
  229|      4|	} else if (path->index > len) {
  ------------------
  |  Branch (229:13): [True: 0, False: 4]
  ------------------
  230|       |		/* We miss some bytes so we will not cache this chunk */
  231|      0|		fclose(f);
  232|      0|		return 0;
  233|      0|	}
  234|       |
  235|      7|	c = fwrite(buf, 1, bufsize, f);
  236|      7|	fclose(f);
  237|      7|	if (c != bufsize) {
  ------------------
  |  Branch (237:6): [True: 0, False: 7]
  ------------------
  238|      0|		sc_log(p15card->card->ctx, "fwrite() wrote only %zu bytes", c);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  239|      0|		unlink(fname);
  240|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  241|      0|	}
  242|      7|	return 0;
  243|      7|}
pkcs15-cache.c:generate_cache_filename:
   44|  2.39k|{
   45|  2.39k|	char dir[PATH_MAX];
   46|  2.39k|	char *last_update = NULL;
   47|  2.39k|	int  r;
   48|  2.39k|	unsigned u;
   49|  2.39k|	size_t change_counter;
   50|       |
   51|  2.39k|	if (p15card->tokeninfo->serial_number == NULL
  ------------------
  |  Branch (51:6): [True: 2.36k, False: 22]
  ------------------
   52|  2.36k|			&& (p15card->card->uid.len == 0
  ------------------
  |  Branch (52:8): [True: 2.36k, 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|  2.36k|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|  2.36k|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   55|       |
   56|     22|	if (path->len > SC_MAX_PATH_SIZE)
  ------------------
  |  |   47|     22|#define SC_MAX_PATH_SIZE		16
  ------------------
  |  Branch (56:6): [True: 0, False: 22]
  ------------------
   57|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
   58|     22|	r = sc_get_cache_dir(p15card->card->ctx, dir, sizeof(dir));
   59|     22|	if (r)
  ------------------
  |  Branch (59:6): [True: 0, False: 22]
  ------------------
   60|      0|		return r;
   61|     22|	snprintf(dir + strlen(dir), sizeof(dir) - strlen(dir), "/");
   62|       |
   63|     22|	last_update = sc_pkcs15_get_lastupdate(p15card);
   64|     22|	if (!last_update)
  ------------------
  |  Branch (64:6): [True: 21, False: 1]
  ------------------
   65|     21|		last_update = "NODATE";
   66|       |
   67|     22|	if (p15card->tokeninfo->serial_number) {
  ------------------
  |  Branch (67:6): [True: 22, False: 0]
  ------------------
   68|     22|		snprintf(dir + strlen(dir), sizeof(dir) - strlen(dir),
   69|     22|				"%s_%s", p15card->tokeninfo->serial_number,
   70|     22|				last_update);
   71|     22|	} 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|     22|	if (SC_SUCCESS == sc_card_ctl(p15card->card, SC_CARDCTL_GET_CHANGE_COUNTER, &change_counter))
  ------------------
  |  |   28|     22|#define SC_SUCCESS				0
  ------------------
  |  Branch (78:6): [True: 9, False: 13]
  ------------------
   79|      9|		snprintf(dir + strlen(dir), sizeof(dir) - strlen(dir), "_%zu", change_counter);
   80|       |
   81|     22|	if (path->aid.len &&
  ------------------
  |  Branch (81:6): [True: 0, False: 22]
  ------------------
   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|     22|	else if (path->type != SC_PATH_TYPE_PATH)  {
  ------------------
  |  |  119|     22|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (88:11): [True: 0, False: 22]
  ------------------
   89|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   90|      0|	}
   91|       |
   92|     22|	if (path->len)   {
  ------------------
  |  Branch (92:6): [True: 22, False: 0]
  ------------------
   93|     22|		size_t offs = 0;
   94|       |
   95|     22|		if (path->len > 2 && memcmp(path->value, "\x3F\x00", 2) == 0)
  ------------------
  |  Branch (95:7): [True: 22, False: 0]
  |  Branch (95:24): [True: 22, False: 0]
  ------------------
   96|     22|			offs = 2;
   97|     22|		snprintf(dir + strlen(dir), sizeof(dir) - strlen(dir), "_");
   98|     90|		for (u = 0; u < path->len - offs; u++)
  ------------------
  |  Branch (98:15): [True: 68, False: 22]
  ------------------
   99|     68|			snprintf(dir + strlen(dir), sizeof(dir) - strlen(dir),
  100|     68|					"%02X",  path->value[u + offs]);
  101|     22|	}
  102|       |
  103|     22|	if (!buf)
  ------------------
  |  Branch (103:6): [True: 0, False: 22]
  ------------------
  104|      0|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  105|     22|	strlcpy(buf, dir, bufsize);
  ------------------
  |  |   43|     22|#define strlcpy _strlcpy
  ------------------
  106|       |
  107|     22|	return SC_SUCCESS;
  ------------------
  |  |   28|     22|#define SC_SUCCESS				0
  ------------------
  108|     22|}

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

sc_pkcs15emu_cedulauy_init_ex:
  196|  9.17k|{
  197|  9.17k|	if (p15card->card->type != SC_CARD_TYPE_CEDULAUY)
  ------------------
  |  Branch (197:6): [True: 9.17k, False: 0]
  ------------------
  198|  9.17k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  9.17k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  199|       |
  200|      0|	return sc_pkcs15emu_cedulauy_init(p15card);
  201|  9.17k|}

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

sc_pkcs15emu_coolkey_init_ex:
  732|  9.15k|{
  733|  9.15k|	sc_card_t      *card = p15card->card;
  734|  9.15k|	sc_context_t    *ctx = card->ctx;
  735|  9.15k|	int rv;
  736|       |
  737|  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  738|       |
  739|  9.15k|	rv = coolkey_detect_card(p15card);
  740|  9.15k|	if (rv)
  ------------------
  |  Branch (740:6): [True: 9.15k, False: 0]
  ------------------
  741|  9.15k|		LOG_FUNC_RETURN(ctx, SC_ERROR_WRONG_CARD);
  ------------------
  |  |  164|  9.15k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  9.15k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  9.15k|	int _ret = r; \
  |  |  |  |  155|  9.15k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 9.15k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  9.15k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  9.15k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 9.15k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  9.15k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  9.15k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|  9.15k|	return _ret; \
  |  |  |  |  163|  9.15k|} 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|  9.15k|{
   61|  9.15k|	sc_card_t *card = p15card->card;
   62|       |
   63|  9.15k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
   64|  9.15k|	if (card->type < SC_CARD_TYPE_COOLKEY_GENERIC
  ------------------
  |  Branch (64:6): [True: 8.97k, False: 174]
  ------------------
   65|    174|		|| card->type >= SC_CARD_TYPE_COOLKEY_GENERIC+1000)
  ------------------
  |  Branch (65:6): [True: 174, False: 0]
  ------------------
   66|  9.15k|		return SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|  9.15k|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
   67|      0|	return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
   68|  9.15k|}

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

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

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

sc_pkcs15emu_dtrust_init_ex:
  125|  6.08k|{
  126|  6.08k|	if (dtrust_pkcs15emu_detect_card(p15card))
  ------------------
  |  Branch (126:6): [True: 6.08k, False: 0]
  ------------------
  127|  6.08k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  6.08k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  128|       |
  129|      0|	return sc_pkcs15emu_dtrust_init(p15card, aid);
  130|  6.08k|}
pkcs15-dtrust.c:dtrust_pkcs15emu_detect_card:
   82|  6.08k|{
   83|  6.08k|	if (p15card->card->type < SC_CARD_TYPE_DTRUST_V4_1_STD)
  ------------------
  |  Branch (83:6): [True: 6.08k, False: 0]
  ------------------
   84|  6.08k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  6.08k|#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|  6.08k|{
   36|  6.08k|	struct sc_card *card = p15card->card;
   37|  6.08k|	struct eoi_privdata *privdata = (struct eoi_privdata *)card->drv_data;
   38|  6.08k|	struct sc_pkcs15_search_key sk;
   39|  6.08k|	struct sc_pkcs15_object *objs[MAX_OBJECTS];
   40|  6.08k|	int i, j, len;
   41|       |
   42|  6.08k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  6.08k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  6.08k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  6.08k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  6.08k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 6.08k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   43|       |
   44|  6.08k|	if (card->type != SC_CARD_TYPE_EOI && card->type != SC_CARD_TYPE_EOI_CONTACTLESS)
  ------------------
  |  Branch (44:6): [True: 6.08k, False: 0]
  |  Branch (44:40): [True: 6.08k, False: 0]
  ------------------
   45|  6.08k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_WRONG_CARD);
  ------------------
  |  |  164|  6.08k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  6.08k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  6.08k|	int _ret = r; \
  |  |  |  |  155|  6.08k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 6.08k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  6.08k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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.08k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 6.08k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  6.08k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  6.08k|	} else { \
  |  |  |  |  159|      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.08k|	return _ret; \
  |  |  |  |  163|  6.08k|} 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 established).
   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; j < MAX_OBJECTS && privdata->prkey_mappings[j][1] != 0; j++) {
  ------------------
  |  |   24|      0|#define MAX_OBJECTS 8
  ------------------
  |  Branch (122:14): [True: 0, False: 0]
  |  Branch (122:33): [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 && j < MAX_OBJECTS) {
  ------------------
  |  |   24|      0|#define MAX_OBJECTS 8
  ------------------
  |  Branch (130:7): [True: 0, False: 0]
  |  Branch (130:21): [True: 0, False: 0]
  ------------------
  131|      0|			privdata->prkey_mappings[j][0] = prkey_info->key_reference;
  132|      0|			privdata->prkey_mappings[j++][1] = 0xA0 + (i + 1);
  133|      0|		}
  134|      0|	}
  135|       |
  136|      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|  9.24k|{
   80|  9.24k|	SC_FUNC_CALLED(p15card->card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  9.24k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  9.24k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  9.24k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 9.24k]
  |  |  ------------------
  ------------------
   81|       |
   82|  9.24k|	if (entersafe_detect_card(p15card))
  ------------------
  |  Branch (82:6): [True: 8.95k, False: 295]
  ------------------
   83|  8.95k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  8.95k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
   84|    295|	return sc_pkcs15emu_entersafe_init(p15card);
   85|  9.24k|}
pkcs15-esinit.c:entersafe_detect_card:
   33|  9.24k|{
   34|  9.24k|	sc_card_t *card = p15card->card;
   35|       |
   36|  9.24k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  9.24k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  9.24k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  9.24k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 9.24k]
  |  |  ------------------
  ------------------
   37|       |
   38|       |	/* check if we have the correct card OS */
   39|  9.24k|	if (strcmp(card->name, "entersafe"))
  ------------------
  |  Branch (39:6): [True: 8.95k, False: 295]
  ------------------
   40|  8.95k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  8.95k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
   41|       |
   42|    295|    return SC_SUCCESS;
  ------------------
  |  |   28|    295|#define SC_SUCCESS				0
  ------------------
   43|  9.24k|}
pkcs15-esinit.c:sc_pkcs15emu_entersafe_init:
   46|    295|{
   47|    295|	int    r;
   48|    295|	char   buf[256];
   49|    295|	sc_card_t *card = p15card->card;
   50|    295|	sc_serial_number_t serial;
   51|       |
   52|    295|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    295|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    295|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    295|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 295]
  |  |  ------------------
  ------------------
   53|       |
   54|       |	/* get serial number */
   55|    295|	r = sc_card_ctl(card, SC_CARDCTL_GET_SERIALNR, &serial);
   56|    295|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|    295|#define SC_SUCCESS				0
  ------------------
  |  Branch (56:6): [True: 254, False: 41]
  ------------------
   57|    254|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|    254|#define SC_ERROR_INTERNAL			-1400
  ------------------
   58|     41|	r = sc_bin_to_hex(serial.value, serial.len, buf, sizeof(buf), 0);
   59|     41|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|     41|#define SC_SUCCESS				0
  ------------------
  |  Branch (59:6): [True: 0, False: 41]
  ------------------
   60|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
   61|       |
   62|     41|	set_string(&p15card->tokeninfo->serial_number, buf);
   63|     41|	if (!p15card->tokeninfo->serial_number)
  ------------------
  |  Branch (63:6): [True: 0, False: 41]
  ------------------
   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|     41|	set_string(&p15card->tokeninfo->manufacturer_id, MANU_ID);
  ------------------
  |  |   30|     41|#define MANU_ID		"entersafe"
  ------------------
   68|     41|	if (!p15card->tokeninfo->manufacturer_id) {
  ------------------
  |  Branch (68:6): [True: 0, False: 41]
  ------------------
   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|     41|	return SC_SUCCESS;
  ------------------
  |  |   28|     41|#define SC_SUCCESS				0
  ------------------
   75|     41|}

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

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

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

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

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

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

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

sc_pkcs15emu_jpki_init_ex:
  248|  9.15k|{
  249|  9.15k|	if (p15card->card->type != SC_CARD_TYPE_JPKI_BASE)
  ------------------
  |  Branch (249:6): [True: 9.15k, False: 0]
  ------------------
  250|  9.15k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  9.15k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  251|      0|	return sc_pkcs15emu_jpki_init(p15card);
  252|  9.15k|}

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

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

sc_pkcs15emu_openpgp_init_ex:
  695|  9.25k|{
  696|  9.25k|	if (openpgp_detect_card(p15card))
  ------------------
  |  Branch (696:6): [True: 8.58k, False: 671]
  ------------------
  697|  8.58k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  8.58k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  698|    671|	return sc_pkcs15emu_openpgp_init(p15card);
  699|  9.25k|}
pkcs15-openpgp.c:openpgp_detect_card:
  683|  9.25k|{
  684|  9.25k|	if (p15card->card->type == SC_CARD_TYPE_OPENPGP_BASE
  ------------------
  |  Branch (684:6): [True: 588, False: 8.66k]
  ------------------
  685|  8.66k|			|| p15card->card->type == SC_CARD_TYPE_OPENPGP_V1
  ------------------
  |  Branch (685:7): [True: 5, False: 8.65k]
  ------------------
  686|  8.65k|			|| p15card->card->type == SC_CARD_TYPE_OPENPGP_V2
  ------------------
  |  Branch (686:7): [True: 17, False: 8.64k]
  ------------------
  687|  8.64k|			|| p15card->card->type == SC_CARD_TYPE_OPENPGP_GNUK
  ------------------
  |  Branch (687:7): [True: 25, False: 8.61k]
  ------------------
  688|  8.61k|			|| p15card->card->type == SC_CARD_TYPE_OPENPGP_V3)
  ------------------
  |  Branch (688:7): [True: 36, False: 8.58k]
  ------------------
  689|    671|		return SC_SUCCESS;
  ------------------
  |  |   28|    671|#define SC_SUCCESS				0
  ------------------
  690|  8.58k|	else
  691|  8.58k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  8.58k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  692|  9.25k|}
pkcs15-openpgp.c:sc_pkcs15emu_openpgp_init:
  182|    671|{
  183|    671|	sc_card_t	*card = p15card->card;
  184|    671|	sc_context_t	*ctx = card->ctx;
  185|    671|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|    671|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
  186|    671|	char		string[256];
  187|    671|	u8		c4data[10];
  188|    671|	u8		c5data[100];
  189|    671|	int		r, i;
  190|    671|	const pgp_pin_cfg_t *pin_cfg = (card->type == SC_CARD_TYPE_OPENPGP_V1)
  ------------------
  |  Branch (190:33): [True: 5, False: 666]
  ------------------
  191|    671|	                               ? pin_cfg_v1 : pin_cfg_v2;
  192|    671|	sc_path_t path;
  193|    671|	sc_file_t *file = NULL;
  194|       |
  195|    671|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    671|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    671|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    671|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    671|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 671]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  196|       |
  197|    671|	set_string(&p15card->tokeninfo->label, "OpenPGP card");
  198|    671|	set_string(&p15card->tokeninfo->manufacturer_id, "OpenPGP project");
  199|       |
  200|       |	/* card->serialnr = 2 byte manufacturer_id + 4 byte serial_number */
  201|    671|	if (card->serialnr.len > 0) {
  ------------------
  |  Branch (201:6): [True: 625, False: 46]
  ------------------
  202|    625|		unsigned short manuf_id = bebytes2ushort(card->serialnr.value);
  203|    625|		int j;
  204|       |
  205|    625|		sc_bin_to_hex(card->serialnr.value, card->serialnr.len, string, sizeof(string), 0);
  206|    625|		set_string(&p15card->tokeninfo->serial_number, string);
  207|       |
  208|  15.3k|		for (j = 0; manuf_map[j].name != NULL; j++) {
  ------------------
  |  Branch (208:15): [True: 14.8k, False: 438]
  ------------------
  209|  14.8k|			if (manuf_id == manuf_map[j].id) {
  ------------------
  |  Branch (209:8): [True: 187, False: 14.7k]
  ------------------
  210|    187|				set_string(&p15card->tokeninfo->manufacturer_id, manuf_map[j].name);
  211|    187|				break;
  212|    187|			}
  213|  14.8k|		}
  214|    625|	}
  215|       |
  216|    671|	p15card->tokeninfo->flags = SC_PKCS15_TOKEN_PRN_GENERATION | SC_PKCS15_TOKEN_EID_COMPLIANT;
  ------------------
  |  |  597|    671|#define SC_PKCS15_TOKEN_PRN_GENERATION			0x04
  ------------------
              	p15card->tokeninfo->flags = SC_PKCS15_TOKEN_PRN_GENERATION | SC_PKCS15_TOKEN_EID_COMPLIANT;
  ------------------
  |  |  598|    671|#define SC_PKCS15_TOKEN_EID_COMPLIANT			0x08
  ------------------
  217|       |
  218|       |	/* Extract preferred language */
  219|    671|	r = read_file(card, "0065:5f2d", string, sizeof(string)-1);
  220|    671|	if (r < 0)
  ------------------
  |  Branch (220:6): [True: 454, False: 217]
  ------------------
  221|    454|		goto failed;
  222|    217|	string[r] = '\0';
  223|    217|	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|    217|	sc_log(ctx, "Reading PW status bytes");
  ------------------
  |  |   71|    217|#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|    217|	if ((r = read_file(card, "006E:0073:00C4", c4data, sizeof(c4data))) < 0)
  ------------------
  |  Branch (232:6): [True: 149, False: 68]
  ------------------
  233|    149|		goto failed;
  234|     68|	if (r != 7) {
  ------------------
  |  Branch (234:6): [True: 56, False: 12]
  ------------------
  235|     56|		sc_log(ctx, "CHV status bytes have unexpected length (expected 7, got %d)\n", r);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  236|     56|		r = SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|     56|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  237|     56|		goto failed;
  238|     56|	}
  239|       |
  240|       |	/* Add PIN codes */
  241|     48|	for (i = 0; i < 3; i++) {
  ------------------
  |  Branch (241:14): [True: 36, False: 12]
  ------------------
  242|     36|		sc_pkcs15_auth_info_t pin_info;
  243|     36|		sc_pkcs15_object_t   pin_obj;
  244|       |
  245|     36|		memset(&pin_info, 0, sizeof(pin_info));
  246|     36|		memset(&pin_obj,  0, sizeof(pin_obj));
  247|       |
  248|     36|		pin_info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|     36|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  249|     36|		pin_info.auth_id.len      = 1;
  250|     36|		pin_info.auth_id.value[0] = pin_cfg[i].reference;
  251|     36|		pin_info.attrs.pin.reference     = pin_cfg[i].reference;
  252|     36|		pin_info.attrs.pin.flags         = pin_cfg[i].flags;
  253|     36|		pin_info.attrs.pin.type          = SC_PKCS15_PIN_TYPE_UTF8;
  ------------------
  |  |   90|     36|#define SC_PKCS15_PIN_TYPE_UTF8				2
  ------------------
  254|     36|		pin_info.attrs.pin.min_length    = pin_cfg[i].min_length;
  255|     36|		pin_info.attrs.pin.stored_length = c4data[1 + pin_cfg[i].do_index];
  256|     36|		pin_info.attrs.pin.max_length    = c4data[1 + pin_cfg[i].do_index];
  257|     36|		pin_info.attrs.pin.pad_char      = '\0';
  258|     36|		pin_info.tries_left = c4data[4 + pin_cfg[i].do_index];
  259|     36|		pin_info.logged_in = SC_PIN_STATE_UNKNOWN;
  ------------------
  |  |  430|     36|#define SC_PIN_STATE_UNKNOWN	0
  ------------------
  260|       |
  261|     36|		sc_format_path("3F00", &pin_info.path);
  262|       |
  263|     36|		strlcpy(pin_obj.label, pin_cfg[i].label, sizeof(pin_obj.label));
  ------------------
  |  |   43|     36|#define strlcpy _strlcpy
  ------------------
  264|     36|		pin_obj.flags = SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   51|     36|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  ------------------
              		pin_obj.flags = SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|     36|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  265|     36|		if (i < 2) {
  ------------------
  |  Branch (265:7): [True: 24, False: 12]
  ------------------
  266|     24|			pin_obj.auth_id.len = 1;
  267|     24|			pin_obj.auth_id.value[0] = 3;
  268|     24|		}
  269|       |
  270|     36|		r = sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info);
  271|     36|		if (r < 0) {
  ------------------
  |  Branch (271:7): [True: 0, False: 36]
  ------------------
  272|      0|			r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  273|      0|			goto failed;
  274|      0|		}
  275|     36|	}
  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|     12|	sc_log(ctx, "Reading Fingerprints");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  283|     12|	if ((r = read_file(card, "006E:0073:00C5", c5data, sizeof(c5data))) < 0)
  ------------------
  |  Branch (283:6): [True: 7, False: 5]
  ------------------
  284|      7|		goto failed;
  285|      5|	if (r < 60) {
  ------------------
  |  Branch (285:6): [True: 5, False: 0]
  ------------------
  286|      5|		sc_log(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__
  |  |  ------------------
  ------------------
  287|      5|			"finger print bytes have unexpected length (expected 60, got %d)\n", r);
  288|      5|		r = SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      5|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  289|      5|		goto failed;
  290|      5|	}
  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 ||
  ------------------
  |  |  871|      0|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (334:8): [True: 0, False: 0]
  ------------------
  335|      0|				cxdata[0] == SC_OPENPGP_KEYALGO_ECDSA ||
  ------------------
  |  |  872|      0|#define	SC_OPENPGP_KEYALGO_ECDSA	0x13
  ------------------
  |  Branch (335:5): [True: 0, False: 0]
  ------------------
  336|      0|				cxdata[0] == SC_OPENPGP_KEYALGO_EDDSA) {
  ------------------
  |  |  873|      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 ||
  ------------------
  |  |  880|      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)
  ------------------
  |  |  881|      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:
  ------------------
  |  |  871|      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:
  ------------------
  |  |  872|      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:
  ------------------
  |  |  873|      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:
  ------------------
  |  |  873|      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:
  ------------------
  |  |  871|      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:
  ------------------
  |  |  872|      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:
  ------------------
  |  |  870|      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 ||
  ------------------
  |  |  871|      0|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (465:8): [True: 0, False: 0]
  ------------------
  466|      0|				cxdata[0] == SC_OPENPGP_KEYALGO_ECDSA ||
  ------------------
  |  |  872|      0|#define	SC_OPENPGP_KEYALGO_ECDSA	0x13
  ------------------
  |  Branch (466:5): [True: 0, False: 0]
  ------------------
  467|      0|				cxdata[0] == SC_OPENPGP_KEYALGO_EDDSA) {
  ------------------
  |  |  873|      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 ||
  ------------------
  |  |  880|      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)
  ------------------
  |  |  881|      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:
  ------------------
  |  |  871|      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:
  ------------------
  |  |  872|      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:
  ------------------
  |  |  873|      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:
  ------------------
  |  |  873|      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:
  ------------------
  |  |  871|      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:
  ------------------
  |  |  872|      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:
  ------------------
  |  |  870|      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|    671|failed:
  621|    671|	if (r < 0) {
  ------------------
  |  Branch (621:6): [True: 671, False: 0]
  ------------------
  622|    671|		sc_log(card->ctx,
  ------------------
  |  |   71|    671|#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|    671|				"Failed to initialize OpenPGP emulation: %s\n",
  624|    671|				sc_strerror(r));
  625|    671|		sc_pkcs15_card_clear(p15card);
  626|    671|	}
  627|    671|	sc_file_free(file);
  628|    671|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    671|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    671|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    671|	int _ret = r; \
  |  |  |  |  155|    671|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 671, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    671|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    671|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 671, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    671|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    671|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    671|	return _ret; \
  |  |  |  |  163|    671|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  629|    671|}
pkcs15-openpgp.c:read_file:
  163|    900|{
  164|    900|	sc_path_t	path;
  165|    900|	sc_file_t	*file;
  166|    900|	int		r;
  167|       |
  168|    900|	sc_format_path(path_name, &path);
  169|    900|	if ((r = sc_select_file(card, &path, &file)) < 0)
  ------------------
  |  Branch (169:6): [True: 610, False: 290]
  ------------------
  170|    610|		return r;
  171|       |
  172|    290|	if (file->size < len)
  ------------------
  |  Branch (172:6): [True: 281, False: 9]
  ------------------
  173|    281|		len = file->size;
  174|       |
  175|    290|	sc_file_free(file);
  176|       |
  177|    290|	return sc_read_binary(card, 0, (u8 *) buf, len, 0);
  178|    900|}

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

sc_pkcs15emu_piv_init_ex:
 1301|  9.24k|{
 1302|  9.24k|	sc_card_t   *card = p15card->card;
 1303|  9.24k|	sc_context_t    *ctx = card->ctx;
 1304|       |
 1305|  9.24k|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  9.24k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  9.24k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  9.24k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 9.24k]
  |  |  ------------------
  ------------------
 1306|       |
 1307|  9.24k|	if (piv_detect_card(p15card))
  ------------------
  |  Branch (1307:6): [True: 9.24k, False: 0]
  ------------------
 1308|  9.24k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  9.24k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
 1309|      0|	return sc_pkcs15emu_piv_init(p15card);
 1310|  9.24k|}
pkcs15-piv.c:piv_detect_card:
  237|  9.24k|{
  238|  9.24k|	sc_card_t *card = p15card->card;
  239|       |
  240|  9.24k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  9.24k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  9.24k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  9.24k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 9.24k]
  |  |  ------------------
  ------------------
  241|  9.24k|	if (card->type < SC_CARD_TYPE_PIV_II_BASE
  ------------------
  |  Branch (241:6): [True: 4.60k, False: 4.63k]
  ------------------
  242|  4.63k|		|| card->type >= SC_CARD_TYPE_PIV_II_BASE + 1000)
  ------------------
  |  Branch (242:6): [True: 4.63k, False: 0]
  ------------------
  243|  9.24k|		return SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|  9.24k|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  244|      0|	return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  245|  9.24k|}

sc_pkcs15_decode_prkdf_entry:
  157|     13|{
  158|     13|	sc_context_t *ctx = p15card->card->ctx;
  159|     13|	struct sc_pkcs15_prkey_info info;
  160|     13|	int r, i, gostr3410_params[3];
  161|     13|	struct sc_pkcs15_keyinfo_gostparams *keyinfo_gostparams;
  162|     13|	size_t usage_len = sizeof(info.usage);
  163|     13|	size_t af_len = sizeof(info.access_flags);
  164|     13|	struct sc_asn1_entry asn1_com_key_attr[C_ASN1_COM_KEY_ATTR_SIZE];
  165|     13|	struct sc_asn1_entry asn1_com_prkey_attr[C_ASN1_COM_PRKEY_ATTR_SIZE];
  166|     13|	struct sc_asn1_entry asn1_rsakey_attr[C_ASN1_RSAKEY_ATTR_SIZE];
  167|     13|	struct sc_asn1_entry asn1_prk_rsa_attr[C_ASN1_PRK_RSA_ATTR_SIZE];
  168|     13|	struct sc_asn1_entry asn1_gostr3410key_attr[C_ASN1_GOSTR3410KEY_ATTR_SIZE];
  169|     13|	struct sc_asn1_entry asn1_prk_gostr3410_attr[C_ASN1_PRK_GOSTR3410_ATTR_SIZE];
  170|     13|	struct sc_asn1_entry asn1_ecckey_attr[C_ASN1_ECCKEY_ATTR];
  171|     13|	struct sc_asn1_entry asn1_prk_ecc_attr[C_ASN1_PRK_ECC_ATTR];
  172|     13|	struct sc_asn1_entry asn1_prkey[C_ASN1_PRKEY_SIZE];
  173|     13|	struct sc_asn1_entry asn1_supported_algorithms[C_ASN1_SUPPORTED_ALGORITHMS_SIZE];
  174|     13|	struct sc_asn1_pkcs15_object rsa_prkey_obj = {obj, asn1_com_key_attr, asn1_com_prkey_attr, asn1_prk_rsa_attr};
  175|     13|	struct sc_asn1_pkcs15_object gostr3410_prkey_obj = {obj, asn1_com_key_attr, asn1_com_prkey_attr, asn1_prk_gostr3410_attr};
  176|     13|	struct sc_asn1_pkcs15_object ecc_prkey_obj = { obj, asn1_com_key_attr, asn1_com_prkey_attr, asn1_prk_ecc_attr };
  177|     13|	u8 ec_domain[32];
  178|     13|	size_t ec_domain_len = sizeof(ec_domain);
  179|       |
  180|     13|	sc_copy_asn1_entry(c_asn1_prkey, asn1_prkey);
  181|     13|	sc_copy_asn1_entry(c_asn1_supported_algorithms, asn1_supported_algorithms);
  182|       |
  183|     13|	sc_copy_asn1_entry(c_asn1_prk_rsa_attr, asn1_prk_rsa_attr);
  184|     13|	sc_copy_asn1_entry(c_asn1_rsakey_attr, asn1_rsakey_attr);
  185|     13|	sc_copy_asn1_entry(c_asn1_prk_gostr3410_attr, asn1_prk_gostr3410_attr);
  186|     13|	sc_copy_asn1_entry(c_asn1_gostr3410key_attr, asn1_gostr3410key_attr);
  187|     13|	sc_copy_asn1_entry(c_asn1_prk_ecc_attr, asn1_prk_ecc_attr);
  188|     13|	sc_copy_asn1_entry(c_asn1_ecckey_attr, asn1_ecckey_attr);
  189|       |
  190|     13|	sc_copy_asn1_entry(c_asn1_com_prkey_attr, asn1_com_prkey_attr);
  191|     13|	sc_copy_asn1_entry(c_asn1_com_key_attr, asn1_com_key_attr);
  192|       |
  193|     13|	sc_format_asn1_entry(asn1_prkey + 0, &rsa_prkey_obj, NULL, 0);
  194|     13|	sc_format_asn1_entry(asn1_prkey + 1, &ecc_prkey_obj, NULL, 0);
  195|     13|	sc_format_asn1_entry(asn1_prkey + 2, &gostr3410_prkey_obj, NULL, 0);
  196|       |
  197|     13|	sc_format_asn1_entry(asn1_prk_rsa_attr + 0, asn1_rsakey_attr, NULL, 0);
  198|     13|	sc_format_asn1_entry(asn1_prk_gostr3410_attr + 0, asn1_gostr3410key_attr, NULL, 0);
  199|     13|	sc_format_asn1_entry(asn1_prk_ecc_attr + 0, asn1_ecckey_attr, NULL, 0);
  200|       |
  201|     13|	sc_format_asn1_entry(asn1_rsakey_attr + 0, &info.path, NULL, 0);
  202|     13|	sc_format_asn1_entry(asn1_rsakey_attr + 1, &info.modulus_length, NULL, 0);
  203|       |
  204|     13|	sc_format_asn1_entry(asn1_gostr3410key_attr + 0, &info.path, NULL, 0);
  205|     13|	sc_format_asn1_entry(asn1_gostr3410key_attr + 1, &gostr3410_params[0], NULL, 0);
  206|     13|	sc_format_asn1_entry(asn1_gostr3410key_attr + 2, &gostr3410_params[1], NULL, 0);
  207|     13|	sc_format_asn1_entry(asn1_gostr3410key_attr + 3, &gostr3410_params[2], NULL, 0);
  208|       |
  209|     13|	sc_format_asn1_entry(asn1_ecckey_attr + 0, &info.path, NULL, 0);
  210|     13|	sc_format_asn1_entry(asn1_ecckey_attr + 1, &info.field_length, NULL, 0);
  211|     13|	sc_format_asn1_entry(asn1_ecckey_attr + 3, ec_domain, &ec_domain_len, 0);
  212|       |
  213|     13|	sc_format_asn1_entry(asn1_com_key_attr + 0, &info.id, NULL, 0);
  214|     13|	sc_format_asn1_entry(asn1_com_key_attr + 1, &info.usage, &usage_len, 0);
  215|     13|	sc_format_asn1_entry(asn1_com_key_attr + 2, &info.native, NULL, 0);
  216|     13|	sc_format_asn1_entry(asn1_com_key_attr + 3, &info.access_flags, &af_len, 0);
  217|     13|	sc_format_asn1_entry(asn1_com_key_attr + 4, &info.key_reference, NULL, 0);
  218|       |
  219|    221|	for (i=0; i<SC_MAX_SUPPORTED_ALGORITHMS && (asn1_supported_algorithms + i)->name; i++)
  ------------------
  |  |   61|    442|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (219:12): [True: 208, False: 13]
  |  Branch (219:45): [True: 208, False: 0]
  ------------------
  220|    208|		sc_format_asn1_entry(asn1_supported_algorithms + i, &info.algo_refs[i], NULL, 0);
  221|     13|	sc_format_asn1_entry(asn1_com_key_attr + 5, asn1_supported_algorithms, NULL, 0);
  222|       |
  223|     13|	sc_format_asn1_entry(asn1_com_prkey_attr + 0, &info.subject.value, &info.subject.len, 0);
  224|       |
  225|       |	/* Fill in defaults */
  226|     13|	memset(&info, 0, sizeof(info));
  227|     13|	info.key_reference = -1;
  228|     13|	info.native = 1;
  229|     13|	memset(gostr3410_params, 0, sizeof(gostr3410_params));
  230|       |
  231|     13|	r = sc_asn1_decode_choice(ctx, asn1_prkey, *buf, *buflen, buf, buflen);
  232|     13|	if (r == SC_ERROR_ASN1_END_OF_CONTENTS)
  ------------------
  |  |   84|     13|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (232:6): [True: 1, False: 12]
  ------------------
  233|      1|		goto err;
  234|     12|	LOG_TEST_GOTO_ERR(ctx, r, "PrKey DF ASN.1 decoding failed");
  ------------------
  |  |  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: 11, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  179|     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
  |  |  |  |  ------------------
  |  |  |  |  180|     11|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     11|		goto err; \
  |  |  |  |  182|     11|	} \
  |  |  |  |  183|     12|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  235|      1|	if (asn1_prkey[0].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|      1|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (235:6): [True: 0, False: 1]
  ------------------
  236|      0|		obj->type = SC_PKCS15_TYPE_PRKEY_RSA;
  ------------------
  |  |  419|      0|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  237|      0|	}
  238|      1|	else if (asn1_prkey[1].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|      1|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (238:11): [True: 0, False: 1]
  ------------------
  239|      0|		obj->type = SC_PKCS15_TYPE_PRKEY_EC;
  ------------------
  |  |  421|      0|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  240|      0|#ifdef ENABLE_OPENSSL
  241|      0|		if (!(asn1_ecckey_attr[1].flags & SC_ASN1_PRESENT) && (asn1_ecckey_attr[3].flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  147|      0|#define SC_ASN1_PRESENT			0x00000001
  ------------------
              		if (!(asn1_ecckey_attr[1].flags & SC_ASN1_PRESENT) && (asn1_ecckey_attr[3].flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  147|      0|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (241:7): [True: 0, False: 0]
  |  Branch (241:57): [True: 0, False: 0]
  ------------------
  242|      0|			const unsigned char *p = ec_domain;
  243|      0|			ASN1_OBJECT *object = d2i_ASN1_OBJECT(NULL, &p, ec_domain_len);
  244|      0|			int nid;
  245|      0|			EC_GROUP *group;
  246|      0|			if (!object) {
  ------------------
  |  Branch (246:8): [True: 0, False: 0]
  ------------------
  247|      0|				r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  248|      0|				goto err;
  249|      0|			}
  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|      0|#endif
  272|      0|	}
  273|      1|	else if (asn1_prkey[2].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|      1|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (273:11): [True: 0, False: 1]
  ------------------
  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|      0|		obj->type = SC_PKCS15_TYPE_PRKEY_GOSTR3410;
  ------------------
  |  |  420|      0|#define SC_PKCS15_TYPE_PRKEY_GOSTR3410		0x103
  ------------------
  278|      0|		if (info.modulus_length != 0 || info.params.len != 0) {
  ------------------
  |  Branch (278:7): [True: 0, False: 0]
  |  Branch (278:35): [True: 0, False: 0]
  ------------------
  279|      0|			r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  280|      0|			goto err;
  281|      0|		}
  282|      0|		info.modulus_length = SC_PKCS15_GOSTR3410_KEYSIZE;
  ------------------
  |  |  326|      0|#define SC_PKCS15_GOSTR3410_KEYSIZE             256
  ------------------
  283|      0|		info.params.len = sizeof(struct sc_pkcs15_keyinfo_gostparams);
  284|      0|		info.params.data = malloc(info.params.len);
  285|      0|		if (info.params.data == NULL) {
  ------------------
  |  Branch (285:7): [True: 0, False: 0]
  ------------------
  286|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  287|      0|			goto err;
  288|      0|		}
  289|      0|		keyinfo_gostparams = info.params.data;
  290|      0|		keyinfo_gostparams->gostr3410 = gostr3410_params[0];
  291|      0|		keyinfo_gostparams->gostr3411 = gostr3410_params[1];
  292|      0|		keyinfo_gostparams->gost28147 = gostr3410_params[2];
  293|      0|	}
  294|      1|	else {
  295|      1|		r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      1|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  296|      1|		LOG_TEST_GOTO_ERR(ctx, r, "Neither RSA or GOSTR3410 or ECC key in PrKDF entry.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  297|      1|	}
  298|       |
  299|      0|	if (!p15card->app || !p15card->app->ddo.aid.len) {
  ------------------
  |  Branch (299:6): [True: 0, False: 0]
  |  Branch (299:23): [True: 0, False: 0]
  ------------------
  300|      0|		if (!p15card->file_app) {
  ------------------
  |  Branch (300:7): [True: 0, False: 0]
  ------------------
  301|      0|			r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  302|      0|			goto err;
  303|      0|		}
  304|      0|		r = sc_pkcs15_make_absolute_path(&p15card->file_app->path, &info.path);
  305|      0|		if (r < 0) {
  ------------------
  |  Branch (305:7): [True: 0, False: 0]
  ------------------
  306|      0|			goto err;
  307|      0|		}
  308|      0|	}
  309|      0|	else   {
  310|      0|		info.path.aid = p15card->app->ddo.aid;
  311|      0|	}
  312|      0|	sc_log(ctx, "PrivKey path '%s'", sc_print_path(&info.path));
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  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|      0|	if (info.key_reference < -1)
  ------------------
  |  Branch (316:6): [True: 0, False: 0]
  ------------------
  317|      0|		info.key_reference += 256;
  318|       |
  319|       |	/* Check the auth_id - if not present, try and find it in access rules */
  320|      0|	if ((obj->flags & SC_PKCS15_CO_FLAG_PRIVATE) && (obj->auth_id.len == 0)) {
  ------------------
  |  |   50|      0|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  |  Branch (320:6): [True: 0, False: 0]
  |  Branch (320:50): [True: 0, False: 0]
  ------------------
  321|      0|		sc_log(ctx, "Private key %s has no auth ID - checking AccessControlRules",
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  322|      0|				sc_pkcs15_print_id(&info.id));
  323|       |
  324|       |		/* Search in the access_rules for an appropriate auth ID */
  325|      0|		for (i = 0; i < SC_PKCS15_MAX_ACCESS_RULES; i++) {
  ------------------
  |  |   42|      0|#define SC_PKCS15_MAX_ACCESS_RULES      8
  ------------------
  |  Branch (325:15): [True: 0, False: 0]
  ------------------
  326|       |			/* If access_mode is one of the private key usage modes */
  327|      0|			if (obj->access_rules[i].access_mode &
  ------------------
  |  Branch (327:8): [True: 0, False: 0]
  ------------------
  328|      0|					(SC_PKCS15_ACCESS_RULE_MODE_EXECUTE |
  ------------------
  |  |  337|      0|#define SC_PKCS15_ACCESS_RULE_MODE_EXECUTE      0x04
  ------------------
  329|      0|					 SC_PKCS15_ACCESS_RULE_MODE_PSO_CDS |
  ------------------
  |  |  340|      0|#define SC_PKCS15_ACCESS_RULE_MODE_PSO_CDS      0x20
  ------------------
  330|      0|					 SC_PKCS15_ACCESS_RULE_MODE_PSO_DECRYPT |
  ------------------
  |  |  342|      0|#define SC_PKCS15_ACCESS_RULE_MODE_PSO_DECRYPT  0x80
  ------------------
  331|      0|					 SC_PKCS15_ACCESS_RULE_MODE_INT_AUTH)) {
  ------------------
  |  |  344|      0|#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|      0|		}
  341|       |
  342|       |		/* No auth ID found */
  343|      0|		if (i == SC_PKCS15_MAX_ACCESS_RULES)
  ------------------
  |  |   42|      0|#define SC_PKCS15_MAX_ACCESS_RULES      8
  ------------------
  |  Branch (343:7): [True: 0, False: 0]
  ------------------
  344|      0|			sc_log(ctx, "Warning: No auth ID found");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  345|      0|	}
  346|       |
  347|      0|	obj->data = malloc(sizeof(info));
  348|      0|	if (obj->data == NULL) {
  ------------------
  |  Branch (348:6): [True: 0, False: 0]
  ------------------
  349|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  350|      0|		goto err;
  351|      0|	}
  352|      0|	memcpy(obj->data, &info, sizeof(info));
  353|       |
  354|      0|	sc_log(ctx, "Key Subject %s", sc_dump_hex(info.subject.value, info.subject.len));
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  355|      0|	sc_log(ctx, "Key path %s", sc_print_path(&info.path));
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  356|       |
  357|      0|	r = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  358|       |
  359|     13|err:
  360|     13|	if (r < 0) {
  ------------------
  |  Branch (360:6): [True: 13, False: 0]
  ------------------
  361|       |		/* This might have allocated something. If so, clear it now */
  362|     13|		free(info.subject.value);
  363|     13|		sc_pkcs15_free_key_params(&info.params);
  364|     13|	}
  365|       |
  366|     13|	return r;
  367|      0|}
sc_pkcs15_encode_prkdf_entry:
  371|     74|{
  372|     74|	struct sc_asn1_entry asn1_com_key_attr[C_ASN1_COM_KEY_ATTR_SIZE];
  373|     74|	struct sc_asn1_entry asn1_com_prkey_attr[C_ASN1_COM_PRKEY_ATTR_SIZE];
  374|     74|	struct sc_asn1_entry asn1_rsakey_attr[C_ASN1_RSAKEY_ATTR_SIZE];
  375|     74|	struct sc_asn1_entry asn1_prk_rsa_attr[C_ASN1_PRK_RSA_ATTR_SIZE];
  376|     74|	struct sc_asn1_entry asn1_gostr3410key_attr[C_ASN1_GOSTR3410KEY_ATTR_SIZE];
  377|     74|	struct sc_asn1_entry asn1_prk_gostr3410_attr[C_ASN1_PRK_GOSTR3410_ATTR_SIZE];
  378|     74|	struct sc_asn1_entry asn1_ecckey_attr[C_ASN1_ECCKEY_ATTR];
  379|     74|	struct sc_asn1_entry asn1_prk_ecc_attr[C_ASN1_PRK_ECC_ATTR];
  380|     74|	struct sc_asn1_entry asn1_prkey[C_ASN1_PRKEY_SIZE];
  381|     74|	struct sc_asn1_entry asn1_supported_algorithms[C_ASN1_SUPPORTED_ALGORITHMS_SIZE];
  382|     74|	struct sc_asn1_pkcs15_object rsa_prkey_obj = {
  383|     74|		(struct sc_pkcs15_object *) obj, asn1_com_key_attr,
  384|     74|		asn1_com_prkey_attr, asn1_prk_rsa_attr
  385|     74|	};
  386|     74|	struct sc_asn1_pkcs15_object gostr3410_prkey_obj = {
  387|     74|		(struct sc_pkcs15_object *) obj,
  388|     74|		asn1_com_key_attr, asn1_com_prkey_attr,
  389|     74|		asn1_prk_gostr3410_attr
  390|     74|	};
  391|     74|	struct sc_asn1_pkcs15_object ecc_prkey_obj = {
  392|     74|		(struct sc_pkcs15_object *) obj,
  393|     74|		asn1_com_key_attr, asn1_com_prkey_attr,
  394|     74|		asn1_prk_ecc_attr
  395|     74|	};
  396|     74|	struct sc_pkcs15_prkey_info *prkey = (struct sc_pkcs15_prkey_info *) obj->data;
  397|     74|	struct sc_pkcs15_keyinfo_gostparams *keyinfo_gostparams;
  398|     74|	int r, i;
  399|     74|	size_t af_len, usage_len;
  400|       |
  401|     74|	sc_copy_asn1_entry(c_asn1_prkey, asn1_prkey);
  402|     74|	sc_copy_asn1_entry(c_asn1_supported_algorithms, asn1_supported_algorithms);
  403|       |
  404|     74|	sc_copy_asn1_entry(c_asn1_prk_rsa_attr, asn1_prk_rsa_attr);
  405|     74|	sc_copy_asn1_entry(c_asn1_rsakey_attr, asn1_rsakey_attr);
  406|     74|	sc_copy_asn1_entry(c_asn1_prk_gostr3410_attr, asn1_prk_gostr3410_attr);
  407|     74|	sc_copy_asn1_entry(c_asn1_gostr3410key_attr, asn1_gostr3410key_attr);
  408|     74|	sc_copy_asn1_entry(c_asn1_prk_ecc_attr, asn1_prk_ecc_attr);
  409|     74|	sc_copy_asn1_entry(c_asn1_ecckey_attr, asn1_ecckey_attr);
  410|       |
  411|     74|	sc_copy_asn1_entry(c_asn1_com_prkey_attr, asn1_com_prkey_attr);
  412|     74|	sc_copy_asn1_entry(c_asn1_com_key_attr, asn1_com_key_attr);
  413|       |
  414|     74|	switch (obj->type) {
  415|     50|	case SC_PKCS15_TYPE_PRKEY_RSA:
  ------------------
  |  |  419|     50|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (415:2): [True: 50, False: 24]
  ------------------
  416|     50|		sc_format_asn1_entry(asn1_prkey + 0, &rsa_prkey_obj, NULL, 1);
  417|     50|		sc_format_asn1_entry(asn1_prk_rsa_attr + 0, asn1_rsakey_attr, NULL, 1);
  418|     50|		sc_format_asn1_entry(asn1_rsakey_attr + 0, &prkey->path, NULL, 1);
  419|     50|		sc_format_asn1_entry(asn1_rsakey_attr + 1, &prkey->modulus_length, NULL, 1);
  420|     50|		break;
  421|     24|	case SC_PKCS15_TYPE_PRKEY_EC:
  ------------------
  |  |  421|     24|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  |  Branch (421:2): [True: 24, False: 50]
  ------------------
  422|     24|		sc_format_asn1_entry(asn1_prkey + 1, &ecc_prkey_obj, NULL, 1);
  423|     24|		sc_format_asn1_entry(asn1_prk_ecc_attr + 0, asn1_ecckey_attr, NULL, 1);
  424|     24|		sc_format_asn1_entry(asn1_ecckey_attr + 0, &prkey->path, NULL, 1);
  425|     24|		sc_format_asn1_entry(asn1_ecckey_attr + 1, &prkey->field_length, NULL, 1);
  426|     24|		break;
  427|      0|	case SC_PKCS15_TYPE_PRKEY_GOSTR3410:
  ------------------
  |  |  420|      0|#define SC_PKCS15_TYPE_PRKEY_GOSTR3410		0x103
  ------------------
  |  Branch (427:2): [True: 0, False: 74]
  ------------------
  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: 74]
  ------------------
  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|     74|	}
  443|     74|	sc_format_asn1_entry(asn1_com_key_attr + 0, &prkey->id, NULL, 1);
  444|     74|	usage_len = sizeof(prkey->usage);
  445|     74|	sc_format_asn1_entry(asn1_com_key_attr + 1, &prkey->usage, &usage_len, 1);
  446|     74|	if (prkey->native == 0)
  ------------------
  |  Branch (446:6): [True: 0, False: 74]
  ------------------
  447|      0|		sc_format_asn1_entry(asn1_com_key_attr + 2, &prkey->native, NULL, 1);
  448|     74|	if (prkey->access_flags) {
  ------------------
  |  Branch (448:6): [True: 74, False: 0]
  ------------------
  449|     74|		af_len = sizeof(prkey->access_flags);
  450|     74|		sc_format_asn1_entry(asn1_com_key_attr + 3, &prkey->access_flags, &af_len, 1);
  451|     74|	}
  452|     74|	if (prkey->key_reference >= 0)
  ------------------
  |  Branch (452:6): [True: 74, False: 0]
  ------------------
  453|     74|		sc_format_asn1_entry(asn1_com_key_attr + 4, &prkey->key_reference, NULL, 1);
  454|       |
  455|     74|	for (i=0; i<SC_MAX_SUPPORTED_ALGORITHMS && prkey->algo_refs[i]; i++)   {
  ------------------
  |  |   61|    148|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (455:12): [True: 74, False: 0]
  |  Branch (455:45): [True: 0, False: 74]
  ------------------
  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|     74|	sc_format_asn1_entry(asn1_com_key_attr + 5, asn1_supported_algorithms, NULL, prkey->algo_refs[0] != 0);
  460|       |
  461|     74|	if (prkey->subject.value && prkey->subject.len)
  ------------------
  |  Branch (461:6): [True: 0, False: 74]
  |  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|     74|	else
  464|     74|		memset(asn1_com_prkey_attr, 0, sizeof(asn1_com_prkey_attr));
  465|       |
  466|     74|	r = sc_asn1_encode(ctx, asn1_prkey, buf, buflen);
  467|       |
  468|     74|	sc_log(ctx, "Key path %s", sc_print_path(&prkey->path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  469|     74|	return r;
  470|     74|}
sc_pkcs15_erase_prkey:
  554|  7.95k|{
  555|  7.95k|	if (!key)
  ------------------
  |  Branch (555:6): [True: 0, False: 7.95k]
  ------------------
  556|      0|		return;
  557|  7.95k|	switch (key->algorithm) {
  ------------------
  |  Branch (557:10): [True: 7.95k, False: 0]
  ------------------
  558|  3.97k|	case SC_ALGORITHM_RSA:
  ------------------
  |  |   69|  3.97k|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (558:2): [True: 3.97k, False: 3.97k]
  ------------------
  559|  3.97k|		free(key->u.rsa.modulus.data);
  560|  3.97k|		free(key->u.rsa.exponent.data);
  561|  3.97k|		free(key->u.rsa.d.data);
  562|  3.97k|		free(key->u.rsa.p.data);
  563|  3.97k|		free(key->u.rsa.q.data);
  564|  3.97k|		free(key->u.rsa.iqmp.data);
  565|  3.97k|		free(key->u.rsa.dmp1.data);
  566|  3.97k|		free(key->u.rsa.dmq1.data);
  567|  3.97k|		break;
  568|      0|	case SC_ALGORITHM_GOSTR3410:
  ------------------
  |  |   71|      0|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (568:2): [True: 0, False: 7.95k]
  ------------------
  569|      0|		free(key->u.gostr3410.d.data);
  570|      0|		break;
  571|  3.97k|	case SC_ALGORITHM_EC:
  ------------------
  |  |   70|  3.97k|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (571:2): [True: 3.97k, False: 3.97k]
  ------------------
  572|  3.97k|	case SC_ALGORITHM_EDDSA:
  ------------------
  |  |   72|  3.97k|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (572:2): [True: 0, False: 7.95k]
  ------------------
  573|  3.97k|	case SC_ALGORITHM_XEDDSA:
  ------------------
  |  |   73|  3.97k|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (573:2): [True: 0, False: 7.95k]
  ------------------
  574|       |		/* EC, Edwards and Montgomery use common ec params */
  575|  3.97k|		sc_clear_ec_params(&key->u.ec.params);
  576|  3.97k|		free(key->u.ec.privateD.data);
  577|  3.97k|		free(key->u.ec.ecpointQ.value);
  578|  3.97k|		break;
  579|  7.95k|	}
  580|  7.95k|	sc_mem_clear(key, sizeof(*key));
  581|  7.95k|}
sc_pkcs15_free_prkey:
  585|     31|{
  586|     31|	if (!key)
  ------------------
  |  Branch (586:6): [True: 31, False: 0]
  ------------------
  587|     31|		return;
  588|      0|	sc_pkcs15_erase_prkey(key);
  589|      0|	free(key);
  590|      0|}
sc_pkcs15_free_prkey_info:
  593|  4.26k|{
  594|  4.26k|	if (!key)
  ------------------
  |  Branch (594:6): [True: 0, False: 4.26k]
  ------------------
  595|      0|		return;
  596|       |
  597|  4.26k|	if (key->subject.value)
  ------------------
  |  Branch (597:6): [True: 0, False: 4.26k]
  ------------------
  598|      0|		free(key->subject.value);
  599|       |
  600|  4.26k|	sc_pkcs15_free_key_params(&key->params);
  601|       |
  602|  4.26k|	sc_aux_data_free(&key->aux_data);
  603|       |
  604|  4.26k|	free(key);
  605|  4.26k|}

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

sc_pkcs15_decode_pukdf_entry:
  202|      9|{
  203|      9|	struct sc_context *ctx = p15card->card->ctx;
  204|      9|	struct sc_pkcs15_pubkey_info *info;
  205|      9|	int r, gostr3410_params[3];
  206|      9|	struct sc_pkcs15_keyinfo_gostparams *keyinfo_gostparams;
  207|      9|	size_t usage_len, af_len;
  208|      9|	struct sc_pkcs15_der *der = &obj->content;
  209|      9|	struct sc_asn1_entry asn1_com_key_attr[C_ASN1_COM_KEY_ATTR_SIZE];
  210|      9|	struct sc_asn1_entry asn1_com_pubkey_attr[C_ASN1_COM_PUBKEY_ATTR_SIZE];
  211|      9|	struct sc_asn1_entry asn1_rsakey_value_choice[C_ASN1_RSAKEY_VALUE_CHOICE_SIZE];
  212|      9|	struct sc_asn1_entry asn1_rsakey_attr[C_ASN1_RSAKEY_ATTR_SIZE];
  213|      9|	struct sc_asn1_entry asn1_rsa_type_attr[C_ASN1_RSA_TYPE_ATTR_SIZE];
  214|      9|	struct sc_asn1_entry asn1_eckey_value_choice[C_ASN1_ECKEY_VALUE_CHOICE_SIZE];
  215|      9|	struct sc_asn1_entry asn1_eckey_attr[C_ASN1_ECKEY_ATTR_SIZE];
  216|      9|	struct sc_asn1_entry asn1_ec_type_attr[C_ASN1_EC_TYPE_ATTR_SIZE];
  217|      9|	struct sc_asn1_entry asn1_gostr3410key_attr[C_ASN1_GOST3410KEY_ATTR_SIZE];
  218|      9|	struct sc_asn1_entry asn1_gostr3410_type_attr[C_ASN1_GOST3410_TYPE_ATTR_SIZE];
  219|      9|	struct sc_asn1_entry asn1_pubkey_choice[C_ASN1_PUBKEY_CHOICE_SIZE];
  220|      9|	struct sc_asn1_entry asn1_pubkey[C_ASN1_PUBKEY_SIZE];
  221|      9|	struct sc_asn1_pkcs15_object rsakey_obj = { obj, asn1_com_key_attr,
  222|      9|			asn1_com_pubkey_attr, asn1_rsa_type_attr };
  223|      9|	struct sc_asn1_pkcs15_object eckey_obj = { obj, asn1_com_key_attr,
  224|      9|			asn1_com_pubkey_attr, asn1_ec_type_attr };
  225|      9|	struct sc_asn1_pkcs15_object gostr3410key_obj =  { obj, asn1_com_key_attr,
  226|      9|			asn1_com_pubkey_attr, asn1_gostr3410_type_attr };
  227|       |
  228|      9|	info = calloc(1, sizeof *info);
  229|      9|	if (info == NULL) {
  ------------------
  |  Branch (229:6): [True: 0, False: 9]
  ------------------
  230|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  231|      0|		goto err;
  232|      0|	}
  233|      9|	usage_len = sizeof(info->usage);
  234|      9|	af_len = sizeof(info->access_flags);
  235|       |
  236|      9|	sc_copy_asn1_entry(c_asn1_pubkey, asn1_pubkey);
  237|      9|	sc_copy_asn1_entry(c_asn1_pubkey_choice, asn1_pubkey_choice);
  238|      9|	sc_copy_asn1_entry(c_asn1_rsa_type_attr, asn1_rsa_type_attr);
  239|      9|	sc_copy_asn1_entry(c_asn1_rsakey_value_choice, asn1_rsakey_value_choice);
  240|      9|	sc_copy_asn1_entry(c_asn1_rsakey_attr, asn1_rsakey_attr);
  241|      9|	sc_copy_asn1_entry(c_asn1_ec_type_attr, asn1_ec_type_attr);
  242|      9|	sc_copy_asn1_entry(c_asn1_eckey_value_choice, asn1_eckey_value_choice);
  243|      9|	sc_copy_asn1_entry(c_asn1_eckey_attr, asn1_eckey_attr);
  244|      9|	sc_copy_asn1_entry(c_asn1_gostr3410_type_attr, asn1_gostr3410_type_attr);
  245|      9|	sc_copy_asn1_entry(c_asn1_gostr3410key_attr, asn1_gostr3410key_attr);
  246|      9|	sc_copy_asn1_entry(c_asn1_com_pubkey_attr, asn1_com_pubkey_attr);
  247|      9|	sc_copy_asn1_entry(c_asn1_com_key_attr, asn1_com_key_attr);
  248|       |
  249|      9|	sc_format_asn1_entry(asn1_com_pubkey_attr + 0, &info->subject.value, &info->subject.len, 0);
  250|       |
  251|      9|	sc_format_asn1_entry(asn1_pubkey_choice + 0, &rsakey_obj, NULL, 0);
  252|      9|	sc_format_asn1_entry(asn1_pubkey_choice + 1, &gostr3410key_obj, NULL, 0);
  253|      9|	sc_format_asn1_entry(asn1_pubkey_choice + 2, &eckey_obj, NULL, 0);
  254|       |
  255|      9|	sc_format_asn1_entry(asn1_rsa_type_attr + 0, asn1_rsakey_attr, NULL, 0);
  256|       |
  257|      9|	sc_format_asn1_entry(asn1_rsakey_value_choice + 0, &info->path, NULL, 0);
  258|      9|	sc_format_asn1_entry(asn1_rsakey_value_choice + 1, &der->value, &der->len, 0);
  259|       |
  260|      9|	sc_format_asn1_entry(asn1_rsakey_attr + 0, asn1_rsakey_value_choice, NULL, 0);
  261|      9|	sc_format_asn1_entry(asn1_rsakey_attr + 1, &info->modulus_length, NULL, 0);
  262|       |
  263|      9|	sc_format_asn1_entry(asn1_ec_type_attr + 0, asn1_eckey_attr, NULL, 0);
  264|       |
  265|      9|	sc_format_asn1_entry(asn1_eckey_value_choice + 0, &info->path, NULL, 0);
  266|      9|	sc_format_asn1_entry(asn1_eckey_value_choice + 1, &der->value, &der->len, 0);
  267|       |
  268|      9|	sc_format_asn1_entry(asn1_eckey_attr + 0, asn1_eckey_value_choice, NULL, 0);
  269|       |
  270|      9|	sc_format_asn1_entry(asn1_gostr3410_type_attr + 0, asn1_gostr3410key_attr, NULL, 0);
  271|       |
  272|      9|	sc_format_asn1_entry(asn1_gostr3410key_attr + 0, &info->path, NULL, 0);
  273|      9|	sc_format_asn1_entry(asn1_gostr3410key_attr + 1, &gostr3410_params[0], NULL, 0);
  274|      9|	sc_format_asn1_entry(asn1_gostr3410key_attr + 2, &gostr3410_params[1], NULL, 0);
  275|      9|	sc_format_asn1_entry(asn1_gostr3410key_attr + 3, &gostr3410_params[2], NULL, 0);
  276|       |
  277|      9|	sc_format_asn1_entry(asn1_com_key_attr + 0, &info->id, NULL, 0);
  278|      9|	sc_format_asn1_entry(asn1_com_key_attr + 1, &info->usage, &usage_len, 0);
  279|      9|	sc_format_asn1_entry(asn1_com_key_attr + 2, &info->native, NULL, 0);
  280|      9|	sc_format_asn1_entry(asn1_com_key_attr + 3, &info->access_flags, &af_len, 0);
  281|      9|	sc_format_asn1_entry(asn1_com_key_attr + 4, &info->key_reference, NULL, 0);
  282|       |
  283|      9|	sc_format_asn1_entry(asn1_pubkey + 0, asn1_pubkey_choice, NULL, 0);
  284|       |
  285|       |	/* Fill in defaults */
  286|      9|	info->key_reference = -1;
  287|      9|	info->native = 1;
  288|      9|	memset(gostr3410_params, 0, sizeof(gostr3410_params));
  289|       |
  290|      9|	r = sc_asn1_decode(ctx, asn1_pubkey, *buf, *buflen, buf, buflen);
  291|      9|	if (r == SC_ERROR_ASN1_END_OF_CONTENTS)
  ------------------
  |  |   84|      9|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (291:6): [True: 3, False: 6]
  ------------------
  292|      3|		goto err;
  293|      6|	LOG_TEST_GOTO_ERR(ctx, r, "ASN.1 decoding failed");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  294|      0|	if (asn1_pubkey_choice[0].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|      0|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (294:6): [True: 0, False: 0]
  ------------------
  295|      0|		obj->type = SC_PKCS15_TYPE_PUBKEY_RSA;
  ------------------
  |  |  426|      0|#define SC_PKCS15_TYPE_PUBKEY_RSA		0x201
  ------------------
  296|      0|	} else if (asn1_pubkey_choice[1].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|      0|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (296:13): [True: 0, False: 0]
  ------------------
  297|      0|		obj->type = SC_PKCS15_TYPE_PUBKEY_GOSTR3410;
  ------------------
  |  |  427|      0|#define SC_PKCS15_TYPE_PUBKEY_GOSTR3410		0x203
  ------------------
  298|      0|		if (info->modulus_length != 0)
  ------------------
  |  Branch (298:7): [True: 0, False: 0]
  ------------------
  299|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  300|      0|		info->modulus_length = SC_PKCS15_GOSTR3410_KEYSIZE;
  ------------------
  |  |  326|      0|#define SC_PKCS15_GOSTR3410_KEYSIZE             256
  ------------------
  301|      0|		if (info->params.len != 0)
  ------------------
  |  Branch (301:7): [True: 0, False: 0]
  ------------------
  302|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  303|      0|		info->params.len = sizeof(struct sc_pkcs15_keyinfo_gostparams);
  304|      0|		info->params.data = malloc(info->params.len);
  305|      0|		if (info->params.data == NULL) {
  ------------------
  |  Branch (305:7): [True: 0, False: 0]
  ------------------
  306|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  307|      0|			goto err;
  308|      0|		}
  309|      0|		if (sizeof(*keyinfo_gostparams) != info->params.len)
  ------------------
  |  Branch (309:7): [True: 0, False: 0]
  ------------------
  310|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  311|      0|		keyinfo_gostparams = info->params.data;
  312|      0|		keyinfo_gostparams->gostr3410 = (unsigned int)gostr3410_params[0];
  313|      0|		keyinfo_gostparams->gostr3411 = (unsigned int)gostr3410_params[1];
  314|      0|		keyinfo_gostparams->gost28147 = (unsigned int)gostr3410_params[2];
  315|      0|	}
  316|      0|	else if (asn1_pubkey_choice[2].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|      0|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (316:11): [True: 0, False: 0]
  ------------------
  317|      0|		obj->type = SC_PKCS15_TYPE_PUBKEY_EC;
  ------------------
  |  |  428|      0|#define SC_PKCS15_TYPE_PUBKEY_EC		0x204
  ------------------
  318|      0|	}
  319|      0|	else {
  320|      0|		goto err;
  321|      0|	}
  322|       |
  323|      0|	if (!p15card->app || !p15card->app->ddo.aid.len) {
  ------------------
  |  Branch (323:6): [True: 0, False: 0]
  |  Branch (323:23): [True: 0, False: 0]
  ------------------
  324|      0|		if (!p15card->file_app) {
  ------------------
  |  Branch (324:7): [True: 0, False: 0]
  ------------------
  325|      0|			r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  326|      0|			goto err;
  327|      0|		}
  328|      0|		r = sc_pkcs15_make_absolute_path(&p15card->file_app->path, &info->path);
  329|      0|		if (r < 0) {
  ------------------
  |  Branch (329:7): [True: 0, False: 0]
  ------------------
  330|      0|			goto err;
  331|      0|		}
  332|      0|	}
  333|      0|	else   {
  334|      0|		info->path.aid = p15card->app->ddo.aid;
  335|      0|	}
  336|      0|	sc_log(ctx, "PubKey path '%s'", sc_print_path(&info->path));
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  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|      0|	if (info->key_reference < -1)
  ------------------
  |  Branch (341:6): [True: 0, False: 0]
  ------------------
  342|      0|		info->key_reference += 256;
  343|       |
  344|      0|	obj->data = info;
  345|      0|	info = NULL;
  346|       |
  347|      0|	r = sc_pkcs15_decode_pubkey_direct_value(p15card, obj);
  348|      0|	if (r < 0) {
  ------------------
  |  Branch (348:6): [True: 0, False: 0]
  ------------------
  349|      0|		info = obj->data;
  350|      0|		obj->data = NULL;
  351|      0|	}
  352|      0|	LOG_TEST_GOTO_ERR(ctx, r, "Decode public key direct value failed");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  353|       |
  354|      9|err:
  355|      9|	if (r < 0) {
  ------------------
  |  Branch (355:6): [True: 9, False: 0]
  ------------------
  356|      9|		sc_pkcs15_free_pubkey_info(info);
  357|      9|		if (der->len) {
  ------------------
  |  Branch (357:7): [True: 0, False: 9]
  ------------------
  358|      0|			free(der->value);
  359|       |			/* der points to obj->content */
  360|      0|			obj->content.value = NULL;
  361|      0|			obj->content.len = 0;
  362|      0|		}
  363|      9|	}
  364|       |
  365|      9|	LOG_FUNC_RETURN(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|      9|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 9, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      9|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      9|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      9|	return _ret; \
  |  |  |  |  163|      9|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  366|      9|}
sc_pkcs15_encode_pubkey_rsa:
  586|     81|{
  587|     81|	struct sc_asn1_entry asn1_public_key[C_ASN1_PUBLIC_KEY_SIZE];
  588|     81|	struct sc_asn1_entry asn1_rsa_pub_coefficients[C_ASN1_RSA_PUB_COEFFICIENTS_SIZE];
  589|     81|	int r;
  590|       |
  591|     81|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     81|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  592|     81|	sc_copy_asn1_entry(c_asn1_public_key, asn1_public_key);
  593|     81|	sc_format_asn1_entry(asn1_public_key + 0, asn1_rsa_pub_coefficients, NULL, 1);
  594|       |
  595|     81|	sc_copy_asn1_entry(c_asn1_rsa_pub_coefficients, asn1_rsa_pub_coefficients);
  596|     81|	sc_format_asn1_entry(asn1_rsa_pub_coefficients + 0, key->modulus.data, &key->modulus.len, 1);
  597|     81|	sc_format_asn1_entry(asn1_rsa_pub_coefficients + 1, key->exponent.data, &key->exponent.len, 1);
  598|       |
  599|     81|	r = sc_asn1_encode(ctx, asn1_public_key, buf, buflen);
  600|     81|	LOG_TEST_RET(ctx, r, "ASN.1 encoding 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: 3, False: 78]
  |  |  |  |  ------------------
  |  |  |  |  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|     81|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 78]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  601|       |
  602|     78|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     78|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     78|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     78|	int _ret = r; \
  |  |  |  |  155|     78|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 78, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     78|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 78]
  |  |  |  |  ------------------
  |  |  |  |  157|     78|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     78|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     78|	return _ret; \
  |  |  |  |  163|     78|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  603|     78|}
sc_pkcs15_encode_pubkey_ec:
  692|     40|{
  693|     40|	struct sc_asn1_entry asn1_ec_pointQ[C_ASN1_EC_POINTQ_SIZE];
  694|     40|	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|     40|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     40|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     40|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     40|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     40|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 40]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  706|     40|	sc_copy_asn1_entry(c_asn1_ec_pointQ, asn1_ec_pointQ);
  707|       |
  708|     40|	key_len = key->ecpointQ.len;
  709|     40|	sc_format_asn1_entry(asn1_ec_pointQ + 0, key->ecpointQ.value, &key_len, 1);
  710|       |
  711|     40|	LOG_FUNC_RETURN(ctx,
  ------------------
  |  |  164|     40|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     40|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     40|	int _ret = r; \
  |  |  |  |  155|     40|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 40, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     40|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 40]
  |  |  |  |  ------------------
  |  |  |  |  157|     40|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     40|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     40|	return _ret; \
  |  |  |  |  163|     40|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  712|     40|			sc_asn1_encode(ctx, asn1_ec_pointQ, buf, buflen));
  713|     40|}
sc_pkcs15_encode_pubkey:
  769|     67|{
  770|     67|	if (key->algorithm == SC_ALGORITHM_RSA)
  ------------------
  |  |   69|     67|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (770:6): [True: 27, False: 40]
  ------------------
  771|     27|		return sc_pkcs15_encode_pubkey_rsa(ctx, &key->u.rsa, buf, len);
  772|     40|	if (key->algorithm == SC_ALGORITHM_GOSTR3410)
  ------------------
  |  |   71|     40|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (772:6): [True: 0, False: 40]
  ------------------
  773|      0|		return sc_pkcs15_encode_pubkey_gostr3410(ctx, &key->u.gostr3410, buf, len);
  774|     40|	if (key->algorithm == SC_ALGORITHM_EC)
  ------------------
  |  |   70|     40|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (774:6): [True: 40, False: 0]
  ------------------
  775|     40|		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)
  ------------------
  |  |   72|      0|#define SC_ALGORITHM_EDDSA		4
  ------------------
              	if (key->algorithm == SC_ALGORITHM_EDDSA || key->algorithm == SC_ALGORITHM_XEDDSA)
  ------------------
  |  |   73|      0|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (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|     14|{
  802|     14|	int r = 0;
  803|     14|	struct sc_asn1_entry  asn1_spki_key[2], asn1_spki_key_items[3];
  804|     14|	struct sc_pkcs15_u8 pkey;
  805|     14|	size_t key_len;
  806|       |
  807|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  808|     14|	pkey.value =  NULL;
  809|     14|	pkey.len = 0;
  810|       |
  811|     14|	sc_log(ctx, "Encoding public key with algorithm %lu", pubkey->algorithm);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  812|     14|	if (!pubkey->alg_id)   {
  ------------------
  |  Branch (812:6): [True: 4, False: 10]
  ------------------
  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|     14|	switch (pubkey->algorithm) {
  822|      8|	case SC_ALGORITHM_EC:
  ------------------
  |  |   70|      8|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (822:2): [True: 8, False: 6]
  ------------------
  823|      8|	case SC_ALGORITHM_EDDSA:
  ------------------
  |  |   72|      8|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (823:2): [True: 0, False: 14]
  ------------------
  824|      8|	case SC_ALGORITHM_XEDDSA:
  ------------------
  |  |   73|      8|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (824:2): [True: 0, False: 14]
  ------------------
  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|      8|		key_len = pubkey->u.ec.ecpointQ.len * 8;
  831|      8|		pkey.value = pubkey->u.ec.ecpointQ.value;
  832|      8|		pkey.len = 0; /* flag as do not delete */
  833|       |
  834|      8|		if (pubkey->u.ec.params.named_curve || pubkey->u.ec.params.der.value)   {
  ------------------
  |  Branch (834:7): [True: 8, False: 0]
  |  Branch (834:42): [True: 0, False: 0]
  ------------------
  835|      8|			struct sc_ec_parameters *ec_params = NULL;
  836|       |
  837|      8|			r = sc_pkcs15_fix_ec_parameters(ctx, &pubkey->u.ec.params);
  838|      8|			LOG_TEST_RET(ctx, r, "failed to fix EC parameters");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  839|       |
  840|       |			/* EDDSA and XEDDSA only have algo and no param in SPKI */
  841|      8|			if (pubkey->algorithm == SC_ALGORITHM_EC) {
  ------------------
  |  |   70|      8|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (841:8): [True: 8, False: 0]
  ------------------
  842|      8|				ec_params = calloc(1, sizeof(struct sc_ec_parameters));
  843|      8|				if (!ec_params)
  ------------------
  |  Branch (843:9): [True: 0, False: 8]
  ------------------
  844|      8|					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|      8|				ec_params->type = 1;
  846|      8|				ec_params->der.value = calloc(1, pubkey->u.ec.params.der.len);
  847|      8|				if (!ec_params->der.value) {
  ------------------
  |  Branch (847:9): [True: 0, False: 8]
  ------------------
  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|      8|				memcpy(ec_params->der.value, pubkey->u.ec.params.der.value, pubkey->u.ec.params.der.len);
  852|      8|				ec_params->der.len = pubkey->u.ec.params.der.len;
  853|      8|			}
  854|       |			/* This could have been already allocated: avoid memory leak */
  855|      8|			sc_asn1_clear_algorithm_id(pubkey->alg_id);
  856|      8|			pubkey->alg_id->params = ec_params; /* NULL for EDDSA and XEDDSA */
  857|      8|		}
  858|      8|		break;
  859|      8|	case SC_ALGORITHM_GOSTR3410:
  ------------------
  |  |   71|      0|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (859:2): [True: 0, False: 14]
  ------------------
  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|      6|	default:
  ------------------
  |  Branch (865:2): [True: 6, False: 8]
  ------------------
  866|      6|		r = sc_pkcs15_encode_pubkey(ctx, pubkey, &pkey.value, &pkey.len);
  867|      6|		key_len = pkey.len * 8;
  868|      6|		break;
  869|     14|	}
  870|       |
  871|     14|	if (r == 0) {
  ------------------
  |  Branch (871:6): [True: 14, False: 0]
  ------------------
  872|     14|		sc_copy_asn1_entry(c_asn1_spki_key, asn1_spki_key);
  873|     14|		sc_copy_asn1_entry(c_asn1_spki_key_items, asn1_spki_key_items);
  874|     14|		sc_format_asn1_entry(asn1_spki_key + 0, asn1_spki_key_items, NULL, 1);
  875|     14|		sc_format_asn1_entry(asn1_spki_key_items + 0, pubkey->alg_id, NULL, 1);
  876|     14|		sc_format_asn1_entry(asn1_spki_key_items + 1, pkey.value, &key_len, 1);
  877|       |
  878|     14|		r =  sc_asn1_encode(ctx, asn1_spki_key, buf, len);
  879|     14|	}
  880|       |
  881|       |	/*  pkey.len == 0 is flag to not delete */
  882|     14|	if (pkey.len && pkey.value)
  ------------------
  |  Branch (882:6): [True: 6, False: 8]
  |  Branch (882:18): [True: 6, False: 0]
  ------------------
  883|      6|		free(pkey.value);
  884|       |
  885|     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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 14]
  |  |  |  |  ------------------
  |  |  |  |  157|     14|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     14|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     14|	return _ret; \
  |  |  |  |  163|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  886|     14|}
sc_pkcs15_erase_pubkey:
 1187|  7.96k|{
 1188|  7.96k|	if (key == NULL) {
  ------------------
  |  Branch (1188:6): [True: 0, False: 7.96k]
  ------------------
 1189|      0|		return;
 1190|      0|	}
 1191|  7.96k|	if (key->alg_id) {
  ------------------
  |  Branch (1191:6): [True: 51, False: 7.91k]
  ------------------
 1192|     51|		sc_asn1_clear_algorithm_id(key->alg_id);
 1193|     51|		free(key->alg_id);
 1194|     51|	}
 1195|  7.96k|	switch (key->algorithm) {
  ------------------
  |  Branch (1195:10): [True: 7.96k, False: 0]
  ------------------
 1196|  7.10k|	case SC_ALGORITHM_RSA:
  ------------------
  |  |   69|  7.10k|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (1196:2): [True: 7.10k, False: 860]
  ------------------
 1197|  7.10k|		free(key->u.rsa.modulus.data);
 1198|  7.10k|		free(key->u.rsa.exponent.data);
 1199|  7.10k|		break;
 1200|      0|	case SC_ALGORITHM_GOSTR3410:
  ------------------
  |  |   71|      0|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (1200:2): [True: 0, False: 7.96k]
  ------------------
 1201|      0|		free(key->u.gostr3410.xy.data);
 1202|      0|		break;
 1203|    860|	case SC_ALGORITHM_EC:
  ------------------
  |  |   70|    860|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (1203:2): [True: 860, False: 7.10k]
  ------------------
 1204|    860|	case SC_ALGORITHM_EDDSA:
  ------------------
  |  |   72|    860|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (1204:2): [True: 0, False: 7.96k]
  ------------------
 1205|    860|	case SC_ALGORITHM_XEDDSA:
  ------------------
  |  |   73|    860|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (1205:2): [True: 0, False: 7.96k]
  ------------------
 1206|    860|		free(key->u.ec.params.der.value);
 1207|    860|		free(key->u.ec.params.named_curve);
 1208|    860|		free(key->u.ec.ecpointQ.value);
 1209|    860|		break;
 1210|  7.96k|	}
 1211|  7.96k|	sc_mem_clear(key, sizeof(*key));
 1212|  7.96k|}
sc_pkcs15_free_pubkey:
 1217|     21|{
 1218|     21|	if (!key)
  ------------------
  |  Branch (1218:6): [True: 21, False: 0]
  ------------------
 1219|     21|		return;
 1220|      0|	sc_pkcs15_erase_pubkey(key);
 1221|      0|	free(key);
 1222|      0|}
sc_pkcs15_free_pubkey_info:
 1227|     30|{
 1228|     30|	if (info) {
  ------------------
  |  Branch (1228:6): [True: 30, False: 0]
  ------------------
 1229|     30|		free(info->subject.value);
 1230|     30|		free(info->direct.spki.value);
 1231|     30|		free(info->direct.raw.value);
 1232|     30|		sc_pkcs15_free_key_params(&info->params);
 1233|     30|		free(info);
 1234|     30|	}
 1235|     30|}
sc_pkcs15_fix_ec_parameters:
 1564|  11.4k|{
 1565|  11.4k|	int rv, ii;
 1566|  11.4k|	int mapped_string = 0; /* der is printable string that can be replaced with der of OID */
 1567|       |
 1568|  11.4k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  11.4k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  11.4k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  11.4k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  11.4k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 11.4k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1569|       |
 1570|       |	/* In PKCS#11 EC parameters arrives in DER encoded form */
 1571|  11.4k|	if (ecparams->der.value && ecparams->der.len && ecparams->der.len > 2) {
  ------------------
  |  Branch (1571:6): [True: 7.41k, False: 4.00k]
  |  Branch (1571:29): [True: 7.41k, False: 0]
  |  Branch (1571:50): [True: 7.41k, False: 0]
  ------------------
 1572|       |
 1573|  7.41k|		switch (ecparams->der.value[0]) {
 1574|  7.41k|		case 0x06: /* der.value is an OID */
  ------------------
  |  Branch (1574:3): [True: 7.41k, False: 0]
  ------------------
 1575|   105k|			for (ii = 0; ec_curve_infos[ii].name; ii++) {
  ------------------
  |  Branch (1575:17): [True: 105k, False: 0]
  ------------------
 1576|   105k|				size_t len = ec_curve_infos[ii].oid_der.len;
 1577|       |
 1578|   105k|				if (ecparams->der.len == len &&
  ------------------
  |  Branch (1578:9): [True: 25.0k, False: 80.6k]
  ------------------
 1579|  25.0k|						memcmp(ecparams->der.value, ec_curve_infos[ii].oid_der.value, len) == 0)
  ------------------
  |  Branch (1579:7): [True: 7.41k, False: 17.5k]
  ------------------
 1580|  7.41k|					break; /* found ec_curve_infos[ii] */
 1581|   105k|			}
 1582|  7.41k|			break;
 1583|       |
 1584|      0|		case 0x13:
  ------------------
  |  Branch (1584:3): [True: 0, False: 7.41k]
  ------------------
 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: 7.41k]
  ------------------
 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|  7.41k|		}
 1613|       |
 1614|  7.41k|		if (ec_curve_infos[ii].name == NULL) /* end of ec_curve_info */
  ------------------
  |  Branch (1614:7): [True: 0, False: 7.41k]
  ------------------
 1615|  7.41k|			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|  7.41k|		sc_log(ctx, "Found known curve '%s'", ec_curve_infos[ii].name);
  ------------------
  |  |   71|  7.41k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1619|  7.41k|		if (mapped_string) { /* free previous name if any replace below with new name */
  ------------------
  |  Branch (1619:7): [True: 0, False: 7.41k]
  ------------------
 1620|      0|			free(ecparams->named_curve);
 1621|      0|			ecparams->named_curve = NULL;
 1622|      0|		}
 1623|       |
 1624|  7.41k|		if (!ecparams->named_curve) { /* if present,keep the name as some curves have multiple names */
  ------------------
  |  Branch (1624:7): [True: 7.40k, False: 16]
  ------------------
 1625|  7.40k|			ecparams->named_curve = strdup(ec_curve_infos[ii].name);
 1626|  7.40k|			if (!ecparams->named_curve)
  ------------------
  |  Branch (1626:8): [True: 0, False: 7.40k]
  ------------------
 1627|  7.40k|				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|  7.40k|			sc_log(ctx, "Curve name: '%s'", ecparams->named_curve);
  ------------------
  |  |   71|  7.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__
  |  |  ------------------
  ------------------
 1630|  7.40k|		}
 1631|       |
 1632|       |		/* fill in object_id based on oid_der */
 1633|  7.41k|		sc_format_oid(&ecparams->id, ec_curve_infos[ii].oid_str);
 1634|       |
 1635|  7.41k|		ecparams->field_length = ec_curve_infos[ii].size;
 1636|  7.41k|		ecparams->key_type = ec_curve_infos[ii].key_type;
 1637|  7.41k|		sc_log(ctx, "Curve length %zu key_type %d", ecparams->field_length, ecparams->key_type);
  ------------------
  |  |   71|  7.41k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1638|  7.41k|		if (mapped_string) {
  ------------------
  |  Branch (1638:7): [True: 0, False: 7.41k]
  ------------------
 1639|       |			/* replace the printable string version with the oid */
 1640|      0|			if (ecparams->der.value)
  ------------------
  |  Branch (1640:8): [True: 0, False: 0]
  ------------------
 1641|      0|				free(ecparams->der.value);
 1642|      0|			ecparams->der.len = ec_curve_infos[ii].oid_der.len;
 1643|      0|			ecparams->der.value = malloc(ecparams->der.len);
 1644|      0|			if (ecparams->der.value == NULL) {
  ------------------
  |  Branch (1644:8): [True: 0, False: 0]
  ------------------
 1645|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1646|      0|			}
 1647|      0|			memcpy(ecparams->der.value, ec_curve_infos[ii].oid_der.value, ecparams->der.len);
 1648|      0|		}
 1649|  7.41k|	} else if (ecparams->named_curve) { /* it can be name of curve or OID in ASCII form */
  ------------------
  |  Branch (1649:13): [True: 4.00k, False: 0]
  ------------------
 1650|       |		/* caller did not provide an OID, look for a name or oid_string */
 1651|  28.0k|		for (ii = 0; ec_curve_infos[ii].name; ii++) {
  ------------------
  |  Branch (1651:16): [True: 28.0k, False: 0]
  ------------------
 1652|  28.0k|			if (!strcmp(ec_curve_infos[ii].name, ecparams->named_curve))
  ------------------
  |  Branch (1652:8): [True: 4.00k, False: 24.0k]
  ------------------
 1653|  4.00k|				break;
 1654|  24.0k|			if (!strcmp(ec_curve_infos[ii].oid_str, ecparams->named_curve))
  ------------------
  |  Branch (1654:8): [True: 0, False: 24.0k]
  ------------------
 1655|      0|				break;
 1656|  24.0k|		}
 1657|  4.00k|		if (!ec_curve_infos[ii].name) {
  ------------------
  |  Branch (1657:7): [True: 0, False: 4.00k]
  ------------------
 1658|      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__
  |  |  ------------------
  ------------------
 1659|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1660|      0|		}
 1661|       |
 1662|  4.00k|		rv = sc_format_oid(&ecparams->id, ec_curve_infos[ii].oid_str);
 1663|  4.00k|		LOG_TEST_RET(ctx, rv, "Invalid OID format");
  ------------------
  |  |  174|  4.00k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  4.00k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  4.00k|	int _ret = (r); \
  |  |  |  |  168|  4.00k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 4.00k]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#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.00k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4.00k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1664|       |
 1665|  4.00k|		ecparams->field_length = ec_curve_infos[ii].size;
 1666|  4.00k|		ecparams->key_type = ec_curve_infos[ii].key_type;
 1667|  4.00k|		sc_log(ctx, "Curve length %zu key_type %d", ecparams->field_length, ecparams->key_type);
  ------------------
  |  |   71|  4.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__
  |  |  ------------------
  ------------------
 1668|       |
 1669|  4.00k|		if (ecparams->der.value == NULL || ecparams->der.len == 0) {
  ------------------
  |  Branch (1669:7): [True: 4.00k, False: 0]
  |  Branch (1669:38): [True: 0, False: 0]
  ------------------
 1670|  4.00k|			free(ecparams->der.value); /* just in case */
 1671|  4.00k|			ecparams->der.value = NULL;
 1672|  4.00k|			ecparams->der.len = 0;
 1673|       |			/* if caller did not provide valid der OID, fill in */
 1674|  4.00k|			rv = sc_encode_oid (ctx, &ecparams->id, &ecparams->der.value, &ecparams->der.len);
 1675|  4.00k|			LOG_TEST_RET(ctx, rv, "Cannot encode object ID");
  ------------------
  |  |  174|  4.00k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  4.00k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  4.00k|	int _ret = (r); \
  |  |  |  |  168|  4.00k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 4.00k]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#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.00k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4.00k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1676|  4.00k|		}
 1677|  4.00k|	} else
 1678|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1679|       |
 1680|  11.4k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  11.4k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  11.4k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  11.4k|	int _ret = r; \
  |  |  |  |  155|  11.4k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 11.4k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  11.4k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 11.4k]
  |  |  |  |  ------------------
  |  |  |  |  157|  11.4k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  11.4k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|  11.4k|	return _ret; \
  |  |  |  |  163|  11.4k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1681|  11.4k|}

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

sc_pkcs15emu_skeid_init_ex:
  181|  6.11k|{
  182|  6.11k|	int r = SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  6.11k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  183|       |
  184|  6.11k|	if (p15card->card->type == SC_CARD_TYPE_SKEID_V3
  ------------------
  |  Branch (184:6): [True: 0, False: 6.11k]
  ------------------
  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|  6.11k|	return r;
  189|  6.11k|}

sc_pkcs15_decode_skdf_entry:
  102|      7|{
  103|      7|        struct sc_context *ctx = p15card->card->ctx;
  104|      7|        struct sc_pkcs15_skey_info info;
  105|      7|	int r, i, ii;
  106|      7|	size_t usage_len = sizeof(info.usage);
  107|      7|	size_t af_len = sizeof(info.access_flags);
  108|      7|	struct sc_asn1_entry asn1_com_key_attr[C_ASN1_COM_KEY_ATTR_SIZE];
  109|      7|	struct sc_asn1_entry asn1_com_skey_attr[C_ASN1_COM_SKEY_ATTR_SIZE];
  110|      7|	struct sc_asn1_entry asn1_generic_skey_attr[C_ASN1_COM_SKEY_GENERIC_ATTR_SIZE];
  111|      7|	struct sc_asn1_entry asn1_generic_skey_value_attr[C_ASN1_COM_SKEY_GENERIC_VALUE_ATTR_SIZE];
  112|      7|	struct sc_asn1_entry asn1_skey_choice[C_ASN1_SKEY_CHOICE_SIZE];
  113|      7|	struct sc_asn1_entry asn1_skey[C_ASN1_SKEY_SIZE];
  114|      7|	struct sc_asn1_entry asn1_supported_algorithms[C_ASN1_SUPPORTED_ALGORITHMS_SIZE];
  115|      7|	struct sc_asn1_pkcs15_object skey_des_obj = {
  116|      7|		obj, asn1_com_key_attr, asn1_com_skey_attr, asn1_generic_skey_attr
  117|      7|	};
  118|      7|	static const struct sc_object_id id_aes = { { 2, 16, 840, 1, 101, 3, 4, 1, -1 } };
  119|      7|	struct sc_object_id temp_oid;
  120|       |
  121|      7|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_ASN1);
  ------------------
  |  |  148|      7|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|      7|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|      7|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 7]
  |  |  ------------------
  ------------------
  122|       |
  123|      7|	sc_copy_asn1_entry(c_asn1_skey, asn1_skey);
  124|      7|	sc_copy_asn1_entry(c_asn1_skey_choice, asn1_skey_choice);
  125|      7|	sc_copy_asn1_entry(c_asn1_supported_algorithms, asn1_supported_algorithms);
  126|       |
  127|      7|	sc_copy_asn1_entry(c_asn1_com_key_attr, asn1_com_key_attr);
  128|      7|	sc_copy_asn1_entry(c_asn1_com_skey_attr, asn1_com_skey_attr);
  129|      7|	sc_copy_asn1_entry(c_asn1_generic_skey_attr, asn1_generic_skey_attr);
  130|      7|	sc_copy_asn1_entry(c_asn1_generic_skey_value_attr, asn1_generic_skey_value_attr);
  131|       |
  132|      7|	sc_format_asn1_entry(asn1_skey + 0, asn1_skey_choice, NULL, 0);
  133|      7|	sc_format_asn1_entry(asn1_skey_choice + 0, &skey_des_obj, NULL, 0);
  134|      7|	sc_format_asn1_entry(asn1_skey_choice + 1, &skey_des_obj, NULL, 0);
  135|      7|	sc_format_asn1_entry(asn1_skey_choice + 2, &skey_des_obj, NULL, 0);
  136|      7|	sc_format_asn1_entry(asn1_skey_choice + 3, &skey_des_obj, NULL, 0);
  137|       |
  138|      7|	sc_format_asn1_entry(asn1_com_key_attr + 0, &info.id, NULL, 0);
  139|      7|	sc_format_asn1_entry(asn1_com_key_attr + 1, &info.usage, &usage_len, 0);
  140|      7|	sc_format_asn1_entry(asn1_com_key_attr + 2, &info.native, NULL, 0);
  141|      7|	sc_format_asn1_entry(asn1_com_key_attr + 3, &info.access_flags, &af_len, 0);
  142|      7|	sc_format_asn1_entry(asn1_com_key_attr + 4, &info.key_reference, NULL, 0);
  143|    119|	for (i=0; i<SC_MAX_SUPPORTED_ALGORITHMS && (asn1_supported_algorithms + i)->name; i++)
  ------------------
  |  |   61|    238|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (143:12): [True: 112, False: 7]
  |  Branch (143:45): [True: 112, False: 0]
  ------------------
  144|    112|		sc_format_asn1_entry(asn1_supported_algorithms + i, &info.algo_refs[i], NULL, 0);
  145|      7|	sc_format_asn1_entry(asn1_com_key_attr + 5, asn1_supported_algorithms, NULL, 0);
  146|       |
  147|      7|	sc_format_asn1_entry(asn1_com_skey_attr + 0, &info.value_len, NULL, 0);
  148|       |
  149|      7|	sc_format_asn1_entry(asn1_generic_skey_attr + 0, asn1_generic_skey_value_attr, NULL, 0);
  150|      7|	sc_format_asn1_entry(asn1_generic_skey_value_attr + 0, &info.path, NULL, 0);
  151|       |
  152|       |        /* Fill in defaults */
  153|      7|	memset(&info, 0, sizeof(info));
  154|      7|	info.native = 1;
  155|       |
  156|      7|	r = sc_asn1_decode(ctx, asn1_skey, *buf, *buflen, buf, buflen);
  157|      7|	if (r == SC_ERROR_ASN1_END_OF_CONTENTS)
  ------------------
  |  |   84|      7|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (157:6): [True: 1, False: 6]
  ------------------
  158|      1|		return r;
  159|      6|	LOG_TEST_RET(ctx, r, "ASN.1 decoding 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  160|      0|	if (asn1_skey_choice[0].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|      0|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (160:6): [True: 0, False: 0]
  ------------------
  161|      0|		obj->type = SC_PKCS15_TYPE_SKEY_GENERIC;
  ------------------
  |  |  433|      0|#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|      0|		for (i = 0; i < SC_MAX_SUPPORTED_ALGORITHMS && info.algo_refs[i] != 0 && info.key_type == 0; i++) {
  ------------------
  |  |   61|      0|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (166:15): [True: 0, False: 0]
  |  Branch (166:50): [True: 0, False: 0]
  |  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|      0|	}
  180|      0|	else if (asn1_skey_choice[1].flags & SC_ASN1_PRESENT)
  ------------------
  |  |  147|      0|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (180:11): [True: 0, False: 0]
  ------------------
  181|      0|		obj->type = SC_PKCS15_TYPE_SKEY_DES;
  ------------------
  |  |  434|      0|#define SC_PKCS15_TYPE_SKEY_DES			0x302
  ------------------
  182|      0|	else if (asn1_skey_choice[2].flags & SC_ASN1_PRESENT)
  ------------------
  |  |  147|      0|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (182:11): [True: 0, False: 0]
  ------------------
  183|      0|		obj->type = SC_PKCS15_TYPE_SKEY_2DES;
  ------------------
  |  |  435|      0|#define SC_PKCS15_TYPE_SKEY_2DES		0x303
  ------------------
  184|      0|	else if (asn1_skey_choice[3].flags & SC_ASN1_PRESENT)
  ------------------
  |  |  147|      0|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (184:11): [True: 0, False: 0]
  ------------------
  185|      0|		obj->type = SC_PKCS15_TYPE_SKEY_3DES;
  ------------------
  |  |  436|      0|#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|      0|	obj->data = malloc(sizeof(info));
  190|      0|	if (obj->data == NULL)
  ------------------
  |  Branch (190:6): [True: 0, False: 0]
  ------------------
  191|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  192|      0|	memcpy(obj->data, &info, sizeof(info));
  193|       |
  194|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  195|      0|}
sc_pkcs15_encode_skdf_entry:
  201|     97|{
  202|     97|	struct sc_pkcs15_skey_info *skey = (struct sc_pkcs15_skey_info *) obj->data;
  203|     97|	int r, i;
  204|     97|	size_t usage_len = sizeof(skey->usage);
  205|     97|	size_t af_len = sizeof(skey->access_flags);
  206|     97|	struct sc_asn1_entry asn1_com_key_attr[C_ASN1_COM_KEY_ATTR_SIZE];
  207|     97|	struct sc_asn1_entry asn1_com_skey_attr[C_ASN1_COM_SKEY_ATTR_SIZE];
  208|     97|	struct sc_asn1_entry asn1_generic_skey_attr[C_ASN1_COM_SKEY_GENERIC_ATTR_SIZE];
  209|     97|	struct sc_asn1_entry asn1_generic_skey_value_attr[C_ASN1_COM_SKEY_GENERIC_VALUE_ATTR_SIZE];
  210|     97|	struct sc_asn1_entry asn1_skey_choice[C_ASN1_SKEY_CHOICE_SIZE];
  211|     97|	struct sc_asn1_entry asn1_skey[C_ASN1_SKEY_SIZE];
  212|     97|	struct sc_asn1_entry asn1_supported_algorithms[C_ASN1_SUPPORTED_ALGORITHMS_SIZE];
  213|     97|	struct sc_asn1_pkcs15_object skey_obj = {
  214|     97|		(struct sc_pkcs15_object *) obj, asn1_com_key_attr,
  215|     97|		asn1_com_skey_attr, asn1_generic_skey_attr
  216|     97|	};
  217|       |
  218|     97|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_ASN1);
  ------------------
  |  |  148|     97|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     97|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     97|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 97]
  |  |  ------------------
  ------------------
  219|       |
  220|     97|	sc_copy_asn1_entry(c_asn1_skey, asn1_skey);
  221|     97|	sc_copy_asn1_entry(c_asn1_skey_choice, asn1_skey_choice);
  222|     97|	sc_copy_asn1_entry(c_asn1_supported_algorithms, asn1_supported_algorithms);
  223|       |
  224|     97|	sc_copy_asn1_entry(c_asn1_com_key_attr, asn1_com_key_attr);
  225|     97|	sc_copy_asn1_entry(c_asn1_com_skey_attr, asn1_com_skey_attr);
  226|     97|	sc_copy_asn1_entry(c_asn1_generic_skey_attr, asn1_generic_skey_attr);
  227|     97|	sc_copy_asn1_entry(c_asn1_generic_skey_value_attr, asn1_generic_skey_value_attr);
  228|       |
  229|     97|	sc_format_asn1_entry(asn1_skey + 0, asn1_skey_choice, NULL, 1);
  230|     97|	switch (obj->type) {
  231|     43|	case SC_PKCS15_TYPE_SKEY_GENERIC:
  ------------------
  |  |  433|     43|#define SC_PKCS15_TYPE_SKEY_GENERIC		0x301
  ------------------
  |  Branch (231:2): [True: 43, False: 54]
  ------------------
  232|     43|		sc_format_asn1_entry(asn1_skey_choice + 0, &skey_obj, NULL, 1);
  233|     43|		break;
  234|     32|	case SC_PKCS15_TYPE_SKEY_DES:
  ------------------
  |  |  434|     32|#define SC_PKCS15_TYPE_SKEY_DES			0x302
  ------------------
  |  Branch (234:2): [True: 32, False: 65]
  ------------------
  235|     32|		sc_format_asn1_entry(asn1_skey_choice + 1, &skey_obj, NULL, 1);
  236|     32|		break;
  237|      0|	case SC_PKCS15_TYPE_SKEY_2DES:
  ------------------
  |  |  435|      0|#define SC_PKCS15_TYPE_SKEY_2DES		0x303
  ------------------
  |  Branch (237:2): [True: 0, False: 97]
  ------------------
  238|      0|		sc_format_asn1_entry(asn1_skey_choice + 2, &skey_obj, NULL, 1);
  239|      0|		break;
  240|     22|	case SC_PKCS15_TYPE_SKEY_3DES:
  ------------------
  |  |  436|     22|#define SC_PKCS15_TYPE_SKEY_3DES		0x304
  ------------------
  |  Branch (240:2): [True: 22, False: 75]
  ------------------
  241|     22|		sc_format_asn1_entry(asn1_skey_choice + 3, &skey_obj, NULL, 1);
  242|     22|		break;
  243|      0|	default:
  ------------------
  |  Branch (243:2): [True: 0, False: 97]
  ------------------
  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|     97|	}
  248|       |
  249|     97|	sc_format_asn1_entry(asn1_com_key_attr + 0, &skey->id, NULL, 1);
  250|     97|	sc_format_asn1_entry(asn1_com_key_attr + 1, &skey->usage, &usage_len, 1);
  251|     97|	if (skey->native == 0)
  ------------------
  |  Branch (251:6): [True: 0, False: 97]
  ------------------
  252|      0|		sc_format_asn1_entry(asn1_com_key_attr + 2, &skey->native, NULL, 1);
  253|     97|	if (skey->access_flags)
  ------------------
  |  Branch (253:6): [True: 97, False: 0]
  ------------------
  254|     97|		sc_format_asn1_entry(asn1_com_key_attr + 3, &skey->access_flags, &af_len, 1);
  255|     97|	if (skey->key_reference >= 0)
  ------------------
  |  Branch (255:6): [True: 97, False: 0]
  ------------------
  256|     97|		sc_format_asn1_entry(asn1_com_key_attr + 4, &skey->key_reference, NULL, 1);
  257|    183|	for (i=0; i<SC_MAX_SUPPORTED_ALGORITHMS && i<C_ASN1_SUPPORTED_ALGORITHMS_SIZE && skey->algo_refs[i]; i++)
  ------------------
  |  |   61|    366|#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|    366|#define C_ASN1_SUPPORTED_ALGORITHMS_SIZE (SC_MAX_SUPPORTED_ALGORITHMS + 1)
  |  |  ------------------
  |  |  |  |   61|    183|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  |  |  ------------------
  ------------------
  |  Branch (257:12): [True: 183, False: 0]
  |  Branch (257:45): [True: 183, False: 0]
  |  Branch (257:83): [True: 86, False: 97]
  ------------------
  258|     86|		sc_format_asn1_entry(asn1_supported_algorithms + i, &skey->algo_refs[i], NULL, 1);
  259|     97|	sc_format_asn1_entry(asn1_com_key_attr + 5, asn1_supported_algorithms, NULL, skey->algo_refs[0] != 0);
  260|       |
  261|     97|	sc_format_asn1_entry(asn1_com_skey_attr + 0, &skey->value_len, NULL, 1);
  262|       |
  263|     97|	sc_format_asn1_entry(asn1_generic_skey_attr + 0, asn1_generic_skey_value_attr, NULL, 1);
  264|       |
  265|     97|	sc_format_asn1_entry(asn1_generic_skey_value_attr + 0, &skey->path, NULL, 1);
  266|       |
  267|     97|	r = sc_asn1_encode(ctx, asn1_skey, buf, buflen);
  268|       |
  269|     97|	sc_log(ctx, "Key path %s", sc_print_path(&skey->path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  270|     97|	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|     11|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 11, False: 86]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  271|     97|}
sc_pkcs15_free_skey_info:
  275|  5.18k|{
  276|  5.18k|	if (info) {
  ------------------
  |  Branch (276:6): [True: 5.18k, False: 0]
  ------------------
  277|  5.18k|		free(info->data.value);
  278|  5.18k|		free(info);
  279|  5.18k|	}
  280|  5.18k|}

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

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

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

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

sc_pkcs15emu_tcos_init_ex:
  522|  9.24k|){
  523|  9.24k|	sc_card_t         *card = p15card->card;
  524|  9.24k|	sc_context_t      *ctx = p15card->card->ctx;
  525|  9.24k|	sc_serial_number_t serialnr;
  526|  9.24k|	char               serial[30];
  527|  9.24k|	int r;
  528|       |
  529|       |	/* check if we have the correct card OS unless SC_PKCS15EMU_FLAGS_NO_CHECK */
  530|  9.24k|	if (card->type!=SC_CARD_TYPE_TCOS_V2 && card->type!=SC_CARD_TYPE_TCOS_V3) return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  9.24k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  |  Branch (530:6): [True: 9.24k, False: 0]
  |  Branch (530:42): [True: 9.24k, 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|    366|{
  146|    366|	int r;
  147|    366|	size_t ii;
  148|    366|	u8 serial[128];
  149|    366|	size_t serial_len = sizeof(serial);
  150|    366|	u8 mnfid[SC_PKCS15_MAX_LABEL_SIZE];
  151|    366|	size_t mnfid_len  = sizeof(mnfid) - 1;
  152|    366|	u8 label[SC_PKCS15_MAX_LABEL_SIZE];
  153|    366|	size_t label_len = sizeof(label) - 1;
  154|    366|	u8 last_update[32], profile_indication[SC_PKCS15_MAX_LABEL_SIZE];
  155|    366|	size_t lupdate_len = sizeof(last_update) - 1, pi_len = sizeof(profile_indication) - 1;
  156|    366|	size_t flags_len   = sizeof(ti->flags);
  157|    366|	u8 preferred_language[64];
  158|    366|	size_t lang_length = sizeof(preferred_language) - 1;
  159|    366|	struct sc_asn1_entry asn1_supported_algorithms[SC_MAX_SUPPORTED_ALGORITHMS + 1],
  160|    366|			asn1_algo_infos[SC_MAX_SUPPORTED_ALGORITHMS][7],
  161|    366|			asn1_algo_infos_parameters[SC_MAX_SUPPORTED_ALGORITHMS][3];
  162|    366|	size_t reference_len = sizeof(ti->supported_algos[0].reference);
  163|    366|	size_t mechanism_len = sizeof(ti->supported_algos[0].mechanism);
  164|    366|	size_t parameter_len = sizeof(ti->supported_algos[0].parameters);
  165|    366|	size_t operations_len = sizeof(ti->supported_algos[0].operations);
  166|    366|	size_t algo_ref_len = sizeof(ti->supported_algos[0].algo_ref);
  167|       |
  168|    366|	struct sc_asn1_entry asn1_last_update[C_ASN1_LAST_UPDATE_SIZE];
  169|    366|	struct sc_asn1_entry asn1_profile_indication[C_ASN1_PROFILE_INDICATION_SIZE];
  170|    366|	struct sc_asn1_entry asn1_toki_attrs[C_ASN1_TOKI_ATTRS_SIZE], asn1_tokeninfo[3], asn1_twlabel[3];
  171|       |
  172|    366|	memset(last_update, 0, sizeof(last_update));
  173|    366|	memset(label, 0, sizeof(label));
  174|    366|	memset(profile_indication, 0, sizeof(profile_indication));
  175|    366|	memset(mnfid, 0, sizeof(mnfid));
  176|       |
  177|    366|	sc_copy_asn1_entry(c_asn1_twlabel, asn1_twlabel);
  178|    366|	sc_copy_asn1_entry(c_asn1_toki_attrs, asn1_toki_attrs);
  179|    366|	sc_copy_asn1_entry(c_asn1_tokeninfo, asn1_tokeninfo);
  180|    366|	sc_copy_asn1_entry(c_asn1_last_update, asn1_last_update);
  181|    366|	sc_format_asn1_entry(asn1_twlabel, label, &label_len, 0);
  182|    366|	sc_copy_asn1_entry(c_asn1_profile_indication, asn1_profile_indication);
  183|       |
  184|  6.22k|	for (ii=0; ii<SC_MAX_SUPPORTED_ALGORITHMS; ii++) {
  ------------------
  |  |   61|  6.22k|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (184:13): [True: 5.85k, False: 366]
  ------------------
  185|  5.85k|		sc_copy_asn1_entry(c_asn1_algorithm_info, asn1_algo_infos[ii]);
  186|  5.85k|		sc_copy_asn1_entry(c_asn1_algorithm_info_parameters,
  187|  5.85k|			asn1_algo_infos_parameters[ii]);
  188|  5.85k|	}
  189|    366|	sc_copy_asn1_entry(c_asn1_supported_algorithms, asn1_supported_algorithms);
  190|       |
  191|  6.22k|	for (ii=0; ii<SC_MAX_SUPPORTED_ALGORITHMS; ii++)   {
  ------------------
  |  |   61|  6.22k|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (191:13): [True: 5.85k, False: 366]
  ------------------
  192|  5.85k|		sc_format_asn1_entry(asn1_algo_infos[ii] + 0, &ti->supported_algos[ii].reference, &reference_len, 0);
  193|  5.85k|		sc_format_asn1_entry(asn1_algo_infos[ii] + 1, &ti->supported_algos[ii].mechanism, &mechanism_len, 0);
  194|  5.85k|		sc_format_asn1_entry(asn1_algo_infos[ii] + 2,
  195|  5.85k|			asn1_algo_infos_parameters[ii], NULL, 0);
  196|  5.85k|		sc_format_asn1_entry(asn1_algo_infos_parameters[ii] + 0,
  197|  5.85k|			NULL, NULL, 0);
  198|  5.85k|		sc_format_asn1_entry(asn1_algo_infos_parameters[ii] + 1,
  199|  5.85k|			&ti->supported_algos[ii].parameters, &parameter_len, 0);
  200|  5.85k|		sc_format_asn1_entry(asn1_algo_infos[ii] + 3, &ti->supported_algos[ii].operations, &operations_len, 0);
  201|  5.85k|		sc_format_asn1_entry(asn1_algo_infos[ii] + 4, &ti->supported_algos[ii].algo_id, NULL, 1);
  202|  5.85k|		sc_format_asn1_entry(asn1_algo_infos[ii] + 5, &ti->supported_algos[ii].algo_ref, &algo_ref_len, 0);
  203|  5.85k|		sc_format_asn1_entry(asn1_supported_algorithms + ii, asn1_algo_infos[ii], NULL, 0);
  204|  5.85k|	}
  205|       |
  206|    366|	sc_format_asn1_entry(asn1_last_update + 0, last_update, &lupdate_len, 0);
  207|    366|	sc_format_asn1_entry(asn1_last_update + 1, &ti->last_update.path, NULL, 0);
  208|       |
  209|    366|	sc_format_asn1_entry(asn1_profile_indication + 0, &ti->profile_indication.oid, NULL, 0);
  210|    366|	sc_format_asn1_entry(asn1_profile_indication + 1, profile_indication, &pi_len, 0);
  211|       |
  212|    366|	sc_format_asn1_entry(asn1_toki_attrs + 0, &ti->version, NULL, 0);
  213|    366|	sc_format_asn1_entry(asn1_toki_attrs + 1, serial, &serial_len, 0);
  214|    366|	sc_format_asn1_entry(asn1_toki_attrs + 2, mnfid, &mnfid_len, 0);
  215|    366|	sc_format_asn1_entry(asn1_toki_attrs + 3, label, &label_len, 0);
  216|    366|	sc_format_asn1_entry(asn1_toki_attrs + 4, asn1_twlabel, NULL, 0);
  217|    366|	sc_format_asn1_entry(asn1_toki_attrs + 5, &ti->flags, &flags_len, 0);
  218|    366|	sc_format_asn1_entry(asn1_toki_attrs + 6, &ti->seInfo, &ti->num_seInfo, 0);
  219|    366|	sc_format_asn1_entry(asn1_toki_attrs + 7, NULL, NULL, 0);
  220|    366|	sc_format_asn1_entry(asn1_toki_attrs + 8, asn1_supported_algorithms, NULL, 0);
  221|    366|	sc_format_asn1_entry(asn1_toki_attrs + 9, NULL, NULL, 0);
  222|    366|	sc_format_asn1_entry(asn1_toki_attrs + 10, NULL, NULL, 0);
  223|    366|	sc_format_asn1_entry(asn1_toki_attrs + 11, asn1_last_update, NULL, 0);
  224|    366|	sc_format_asn1_entry(asn1_toki_attrs + 12, preferred_language, &lang_length, 0);
  225|    366|	sc_format_asn1_entry(asn1_toki_attrs + 13, asn1_profile_indication, NULL, 0);
  226|    366|	sc_format_asn1_entry(asn1_tokeninfo, asn1_toki_attrs, NULL, 0);
  227|       |
  228|    366|	r = sc_asn1_decode(ctx, asn1_tokeninfo, buf, blen, NULL, NULL);
  229|    366|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|    366|#define SC_SUCCESS				0
  ------------------
  |  Branch (229:6): [True: 203, False: 163]
  ------------------
  230|       |		/* The decoding could have allocated something we need to free */
  231|    203|		sc_pkcs15_clear_tokeninfo(ti);
  232|    203|		LOG_TEST_RET(ctx, r, "ASN.1 parsing of EF(TokenInfo) failed");
  ------------------
  |  |  174|    203|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    203|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    203|	int _ret = (r); \
  |  |  |  |  168|    203|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 203, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    203|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    203|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    203|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    203|		return _ret; \
  |  |  |  |  172|    203|	} \
  |  |  |  |  173|    203|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  233|    203|	}
  234|       |
  235|    163|	if (asn1_toki_attrs[1].flags & SC_ASN1_PRESENT && serial_len > 0)   {
  ------------------
  |  |  147|    326|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (235:6): [True: 155, False: 8]
  |  Branch (235:52): [True: 154, False: 1]
  ------------------
  236|    154|		free(ti->serial_number);
  237|    154|		ti->serial_number = malloc(serial_len * 2 + 1);
  238|    154|		if (ti->serial_number == NULL)
  ------------------
  |  Branch (238:7): [True: 0, False: 154]
  ------------------
  239|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  240|    154|		sc_bin_to_hex(serial, serial_len, ti->serial_number, serial_len * 2 + 1, 0);
  241|    154|		sc_log(ctx, "TokenInfo.serialNunmber '%s'", ti->serial_number);
  ------------------
  |  |   71|    154|#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|    154|	}
  243|       |
  244|    163|	if (ti->manufacturer_id == NULL) {
  ------------------
  |  Branch (244:6): [True: 163, False: 0]
  ------------------
  245|    163|		if (asn1_toki_attrs[2].flags & SC_ASN1_PRESENT)
  ------------------
  |  |  147|    163|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (245:7): [True: 155, False: 8]
  ------------------
  246|    155|			ti->manufacturer_id = strdup((char *) mnfid);
  247|      8|		else
  248|      8|			ti->manufacturer_id = strdup("(unknown)");
  249|    163|		if (ti->manufacturer_id == NULL)
  ------------------
  |  Branch (249:7): [True: 0, False: 163]
  ------------------
  250|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  251|    163|	}
  252|    163|	if (ti->label == NULL) {
  ------------------
  |  Branch (252:6): [True: 163, False: 0]
  ------------------
  253|    163|		if (asn1_toki_attrs[3].flags & SC_ASN1_PRESENT ||
  ------------------
  |  |  147|    326|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (253:7): [True: 151, False: 12]
  ------------------
  254|     12|		    asn1_toki_attrs[4].flags & SC_ASN1_PRESENT)
  ------------------
  |  |  147|     12|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (254:7): [True: 0, False: 12]
  ------------------
  255|    151|			ti->label = strdup((char *) label);
  256|     12|		else
  257|     12|			ti->label = strdup("(unknown)");
  258|    163|		if (ti->label == NULL)
  ------------------
  |  Branch (258:7): [True: 0, False: 163]
  ------------------
  259|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  260|    163|	}
  261|    163|	if (asn1_toki_attrs[11].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|    163|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (261:6): [True: 19, False: 144]
  ------------------
  262|     19|		if (asn1_last_update[0].flags & SC_ASN1_PRESENT)   {
  ------------------
  |  |  147|     19|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (262:7): [True: 9, False: 10]
  ------------------
  263|      9|			sc_log(ctx, "LastUpdate.generalizedTime present");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  264|      9|			ti->last_update.gtime = strdup((char *)last_update);
  265|      9|			if (ti->last_update.gtime == NULL)
  ------------------
  |  Branch (265:8): [True: 0, False: 9]
  ------------------
  266|      0|				return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  267|      9|		}
  268|     10|		else if (asn1_last_update[1].flags & SC_ASN1_PRESENT)  {
  ------------------
  |  |  147|     10|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (268:12): [True: 7, False: 3]
  ------------------
  269|      7|			sc_log(ctx, "LastUpdate.referencedTime present");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  270|      7|		}
  271|     19|	}
  272|    163|	if (asn1_toki_attrs[12].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|    163|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (272:6): [True: 2, False: 161]
  ------------------
  273|      2|		preferred_language[lang_length] = 0;
  274|      2|		ti->preferred_language = strdup((char *)preferred_language);
  275|      2|		if (ti->preferred_language == NULL)
  ------------------
  |  Branch (275:7): [True: 0, False: 2]
  ------------------
  276|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  277|      2|	}
  278|       |
  279|    163|	sc_init_oid(&ti->profile_indication.oid);
  280|    163|	if (asn1_toki_attrs[13].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|    163|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (280:6): [True: 32, False: 131]
  ------------------
  281|     32|		if (asn1_profile_indication[0].flags & SC_ASN1_PRESENT)   {
  ------------------
  |  |  147|     32|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (281:7): [True: 1, False: 31]
  ------------------
  282|      1|			sc_log(ctx, "ProfileIndication.oid present");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  283|      1|		}
  284|     31|		else if (asn1_profile_indication[1].flags & SC_ASN1_PRESENT)  {
  ------------------
  |  |  147|     31|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (284:12): [True: 28, False: 3]
  ------------------
  285|     28|			sc_log(ctx, "ProfileIndication.name present");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  286|     28|			ti->profile_indication.name = strdup((char *)profile_indication);
  287|     28|			if (ti->profile_indication.name == NULL)
  ------------------
  |  Branch (287:8): [True: 0, False: 28]
  ------------------
  288|      0|				return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  289|     28|		}
  290|     32|	}
  291|       |
  292|    163|	sc_log(ctx, "LastUpdate.path '%s'", sc_print_path(&ti->last_update.path));
  ------------------
  |  |   71|    163|#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|    163|	sc_log(ctx, "ProfileIndication.name '%s'",  ti->profile_indication.name);
  ------------------
  |  |   71|    163|#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|    163|	return SC_SUCCESS;
  ------------------
  |  |   28|    163|#define SC_SUCCESS				0
  ------------------
  295|    163|}
sc_pkcs15_encode_tokeninfo:
  301|    124|{
  302|    124|	int r, ii;
  303|    124|	size_t serial_len, mnfid_len, label_len, flags_len, last_upd_len, pi_len, lang_len;
  304|       |
  305|    124|	struct sc_asn1_entry asn1_toki_attrs[C_ASN1_TOKI_ATTRS_SIZE];
  306|    124|	struct sc_asn1_entry asn1_tokeninfo[2];
  307|    124|	struct sc_asn1_entry asn1_supported_algorithms[SC_MAX_SUPPORTED_ALGORITHMS + 1],
  308|    124|			asn1_algo_infos[SC_MAX_SUPPORTED_ALGORITHMS][7],
  309|    124|			asn1_algo_infos_parameters[SC_MAX_SUPPORTED_ALGORITHMS][3];
  310|    124|	size_t reference_len = sizeof(ti->supported_algos[0].reference);
  311|    124|	size_t mechanism_len = sizeof(ti->supported_algos[0].mechanism);
  312|    124|	size_t parameter_len = sizeof(ti->supported_algos[0].parameters);
  313|    124|	size_t operations_len = sizeof(ti->supported_algos[0].operations);
  314|    124|	size_t algo_ref_len = sizeof(ti->supported_algos[0].algo_ref);
  315|    124|	struct sc_asn1_entry asn1_last_update[C_ASN1_LAST_UPDATE_SIZE];
  316|    124|	struct sc_asn1_entry asn1_profile_indication[C_ASN1_PROFILE_INDICATION_SIZE];
  317|    124|	u8 serial[128];
  318|       |
  319|    124|	sc_copy_asn1_entry(c_asn1_toki_attrs, asn1_toki_attrs);
  320|    124|	sc_copy_asn1_entry(c_asn1_tokeninfo, asn1_tokeninfo);
  321|    124|	sc_copy_asn1_entry(c_asn1_last_update, asn1_last_update);
  322|    124|	sc_copy_asn1_entry(c_asn1_profile_indication, asn1_profile_indication);
  323|       |
  324|    376|	for (ii=0; ii<SC_MAX_SUPPORTED_ALGORITHMS && ti->supported_algos[ii].reference; ii++) {
  ------------------
  |  |   61|    752|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (324:13): [True: 376, False: 0]
  |  Branch (324:47): [True: 252, False: 124]
  ------------------
  325|    252|		sc_copy_asn1_entry(c_asn1_algorithm_info, asn1_algo_infos[ii]);
  326|    252|		sc_copy_asn1_entry(c_asn1_algorithm_info_parameters,
  327|    252|			asn1_algo_infos_parameters[ii]);
  328|    252|	}
  329|    124|	sc_copy_asn1_entry(c_asn1_supported_algorithms, asn1_supported_algorithms);
  330|       |
  331|    376|	for (ii=0; ii<SC_MAX_SUPPORTED_ALGORITHMS && ti->supported_algos[ii].reference; ii++)   {
  ------------------
  |  |   61|    752|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (331:13): [True: 376, False: 0]
  |  Branch (331:47): [True: 252, False: 124]
  ------------------
  332|    252|		sc_format_asn1_entry(asn1_algo_infos[ii] + 0, &ti->supported_algos[ii].reference, &reference_len, 1);
  333|    252|		sc_format_asn1_entry(asn1_algo_infos[ii] + 1, &ti->supported_algos[ii].mechanism, &mechanism_len, 1);
  334|    252|		sc_format_asn1_entry(asn1_algo_infos[ii] + 2,
  335|    252|			asn1_algo_infos_parameters[ii], NULL, 1);
  336|    252|		if (!sc_valid_oid(&ti->supported_algos[ii].parameters)) {
  ------------------
  |  Branch (336:7): [True: 252, False: 0]
  ------------------
  337|    252|			sc_format_asn1_entry(asn1_algo_infos_parameters[ii] + 0,
  338|    252|				NULL, NULL, 1);
  339|    252|		}
  340|      0|		else {
  341|      0|			sc_format_asn1_entry(asn1_algo_infos_parameters[ii] + 1,
  342|      0|				&ti->supported_algos[ii].parameters, &parameter_len, 0);
  343|      0|		}
  344|    252|		sc_format_asn1_entry(asn1_algo_infos[ii] + 3, &ti->supported_algos[ii].operations, &operations_len, 1);
  345|    252|		sc_format_asn1_entry(asn1_algo_infos[ii] + 4, &ti->supported_algos[ii].algo_id, NULL, 1);
  346|    252|		sc_format_asn1_entry(asn1_algo_infos[ii] + 5, &ti->supported_algos[ii].algo_ref, &algo_ref_len, 1);
  347|    252|		sc_format_asn1_entry(asn1_supported_algorithms + ii, asn1_algo_infos[ii], NULL, 1);
  348|    252|	}
  349|       |
  350|    124|	sc_format_asn1_entry(asn1_toki_attrs + 0, &ti->version, NULL, 1);
  351|    124|	if (ti->serial_number != NULL) {
  ------------------
  |  Branch (351:6): [True: 49, False: 75]
  ------------------
  352|     49|		serial_len = 0;
  353|     49|		if (strlen(ti->serial_number)/2 > sizeof(serial))
  ------------------
  |  Branch (353:7): [True: 0, False: 49]
  ------------------
  354|      0|			return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  355|     49|		serial_len = sizeof(serial);
  356|     49|		if (sc_hex_to_bin(ti->serial_number, serial, &serial_len) < 0)
  ------------------
  |  Branch (356:7): [True: 0, False: 49]
  ------------------
  357|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  358|     49|		sc_format_asn1_entry(asn1_toki_attrs + 1, serial, &serial_len, 1);
  359|     49|	}
  360|     75|	else   {
  361|     75|		sc_format_asn1_entry(asn1_toki_attrs + 1, NULL, NULL, 0);
  362|     75|	}
  363|       |
  364|    124|	if (ti->manufacturer_id != NULL) {
  ------------------
  |  Branch (364:6): [True: 49, False: 75]
  ------------------
  365|     49|		mnfid_len = strlen(ti->manufacturer_id);
  366|     49|		sc_format_asn1_entry(asn1_toki_attrs + 2, ti->manufacturer_id, &mnfid_len, 1);
  367|     49|	}
  368|     75|	else    {
  369|     75|		sc_format_asn1_entry(asn1_toki_attrs + 2, NULL, NULL, 0);
  370|     75|	}
  371|       |
  372|    124|	if (ti->label != NULL) {
  ------------------
  |  Branch (372:6): [True: 49, False: 75]
  ------------------
  373|     49|		label_len = strlen(ti->label);
  374|     49|		sc_format_asn1_entry(asn1_toki_attrs + 3, ti->label, &label_len, 1);
  375|     49|	}
  376|     75|	else   {
  377|     75|		sc_format_asn1_entry(asn1_toki_attrs + 3, NULL, NULL, 0);
  378|     75|	}
  379|       |
  380|    124|	if (ti->flags) {
  ------------------
  |  Branch (380:6): [True: 49, False: 75]
  ------------------
  381|     49|		flags_len = sizeof(ti->flags);
  382|     49|		sc_format_asn1_entry(asn1_toki_attrs + 5, &ti->flags, &flags_len, 1);
  383|     49|	}
  384|     75|	else   {
  385|     75|		sc_format_asn1_entry(asn1_toki_attrs + 5, NULL, NULL, 0);
  386|     75|	}
  387|       |
  388|    124|	if (ti->num_seInfo)
  ------------------
  |  Branch (388:6): [True: 16, False: 108]
  ------------------
  389|     16|		sc_format_asn1_entry(asn1_toki_attrs + 6, ti->seInfo, &ti->num_seInfo, 1);
  390|    108|	else
  391|    108|		sc_format_asn1_entry(asn1_toki_attrs + 6, NULL, NULL, 0);
  392|       |
  393|    124|	sc_format_asn1_entry(asn1_toki_attrs + 7, NULL, NULL, 0);
  394|       |
  395|    124|	if (ti->supported_algos[0].reference)
  ------------------
  |  Branch (395:6): [True: 100, False: 24]
  ------------------
  396|    100|		sc_format_asn1_entry(asn1_toki_attrs + 8, asn1_supported_algorithms, NULL, 1);
  397|     24|	else
  398|     24|		sc_format_asn1_entry(asn1_toki_attrs + 8, NULL, NULL, 0);
  399|       |
  400|    124|	sc_format_asn1_entry(asn1_toki_attrs + 9, NULL, NULL, 0);
  401|    124|	sc_format_asn1_entry(asn1_toki_attrs + 10, NULL, NULL, 0);
  402|       |
  403|    124|	if (ti->last_update.path.len) {
  ------------------
  |  Branch (403:6): [True: 0, False: 124]
  ------------------
  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|    124|	else if (ti->last_update.gtime != NULL) {
  ------------------
  |  Branch (407:11): [True: 124, False: 0]
  ------------------
  408|    124|		last_upd_len = strlen(ti->last_update.gtime);
  409|    124|		sc_format_asn1_entry(asn1_last_update + 0, ti->last_update.gtime, &last_upd_len, 1);
  410|    124|		sc_format_asn1_entry(asn1_toki_attrs + 11, asn1_last_update, NULL, 1);
  411|    124|	}
  412|      0|	else   {
  413|      0|		sc_format_asn1_entry(asn1_toki_attrs + 11, NULL, NULL, 0);
  414|      0|	}
  415|       |
  416|    124|	if (ti->preferred_language != NULL) {
  ------------------
  |  Branch (416:6): [True: 1, False: 123]
  ------------------
  417|      1|		lang_len = strlen(ti->preferred_language);
  418|      1|		sc_format_asn1_entry(asn1_toki_attrs + 12, ti->preferred_language, &lang_len, 1);
  419|    123|	} else {
  420|    123|		sc_format_asn1_entry(asn1_toki_attrs + 12, NULL, NULL, 0);
  421|    123|	}
  422|       |
  423|    124|	if (sc_valid_oid(&ti->profile_indication.oid))   {
  ------------------
  |  Branch (423:6): [True: 0, False: 124]
  ------------------
  424|      0|		sc_format_asn1_entry(asn1_profile_indication + 0, &ti->profile_indication.oid, NULL, 1);
  425|      0|		sc_format_asn1_entry(asn1_toki_attrs + 13, asn1_profile_indication, NULL, 1);
  426|      0|	}
  427|    124|	else if (ti->profile_indication.name)   {
  ------------------
  |  Branch (427:11): [True: 1, False: 123]
  ------------------
  428|      1|		pi_len = strlen(ti->profile_indication.name);
  429|      1|		sc_format_asn1_entry(asn1_profile_indication + 1, ti->profile_indication.name, &pi_len, 1);
  430|      1|		sc_format_asn1_entry(asn1_toki_attrs + 13, asn1_profile_indication, NULL, 1);
  431|      1|	}
  432|    123|	else    {
  433|    123|		sc_format_asn1_entry(asn1_toki_attrs + 13, NULL, NULL, 0);
  434|    123|	}
  435|       |
  436|    124|	sc_format_asn1_entry(asn1_tokeninfo, asn1_toki_attrs, NULL, 1);
  437|       |
  438|    124|	r = sc_asn1_encode(ctx, asn1_tokeninfo, buf, buflen);
  439|    124|	LOG_TEST_RET(ctx, r, "sc_asn1_encode() failed");
  ------------------
  |  |  174|    124|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    124|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    124|	int _ret = (r); \
  |  |  |  |  168|    124|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 75, False: 49]
  |  |  |  |  ------------------
  |  |  |  |  169|     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
  |  |  |  |  ------------------
  |  |  |  |  170|     75|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     75|		return _ret; \
  |  |  |  |  172|     75|	} \
  |  |  |  |  173|    124|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 49]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  440|       |
  441|     49|	return SC_SUCCESS;
  ------------------
  |  |   28|     49|#define SC_SUCCESS				0
  ------------------
  442|    124|}
sc_pkcs15_get_lastupdate:
  541|     22|{
  542|     22|	struct sc_context *ctx  = p15card->card->ctx;
  543|     22|	struct sc_file *file = NULL;
  544|     22|	struct sc_asn1_entry asn1_last_update[C_ASN1_LAST_UPDATE_SIZE];
  545|     22|	unsigned char *content, last_update[32] = {0};
  546|     22|	size_t lupdate_len = sizeof(last_update) - 1;
  547|     22|	int r, content_len;
  548|     22|	size_t size;
  549|       |
  550|     22|	if (p15card->tokeninfo->last_update.gtime)
  ------------------
  |  Branch (550:6): [True: 1, False: 21]
  ------------------
  551|      1|		goto done;
  552|       |
  553|     21|	if (!p15card->tokeninfo->last_update.path.len)
  ------------------
  |  Branch (553:6): [True: 20, False: 1]
  ------------------
  554|     20|		return NULL;
  555|       |
  556|      1|	r = sc_select_file(p15card->card, &p15card->tokeninfo->last_update.path, &file);
  557|      1|	if (r < 0)
  ------------------
  |  Branch (557:6): [True: 1, False: 0]
  ------------------
  558|      1|		return NULL;
  559|       |
  560|      0|	size = file->size ? file->size : 1024;
  ------------------
  |  Branch (560:9): [True: 0, False: 0]
  ------------------
  561|      0|	sc_file_free(file);
  562|       |
  563|      0|	content = calloc(1, size);
  564|      0|	if (!content)
  ------------------
  |  Branch (564:6): [True: 0, False: 0]
  ------------------
  565|      0|		return NULL;
  566|       |
  567|      0|	r = sc_read_binary(p15card->card, 0, content, size, 0);
  568|      0|	if (r < 0) {
  ------------------
  |  Branch (568:6): [True: 0, False: 0]
  ------------------
  569|      0|		free(content);
  570|      0|		return NULL;
  571|      0|	}
  572|      0|	content_len = r;
  573|       |
  574|      0|	sc_copy_asn1_entry(c_asn1_last_update, asn1_last_update);
  575|      0|	sc_format_asn1_entry(asn1_last_update + 0, last_update, &lupdate_len, 0);
  576|       |
  577|      0|	r = sc_asn1_decode(ctx, asn1_last_update, content, content_len, NULL, NULL);
  578|      0|	free(content);
  579|      0|	if (r < 0)
  ------------------
  |  Branch (579:6): [True: 0, False: 0]
  ------------------
  580|      0|		return NULL;
  581|       |
  582|      0|	if (asn1_last_update[0].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|      0|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (582:6): [True: 0, False: 0]
  ------------------
  583|      0|		p15card->tokeninfo->last_update.gtime = strdup((char *)last_update);
  584|      0|		if (!p15card->tokeninfo->last_update.gtime)
  ------------------
  |  Branch (584:7): [True: 0, False: 0]
  ------------------
  585|      0|			return NULL;
  586|      0|	}
  587|      1|done:
  588|      1|	sc_log(ctx, "lastUpdate.gtime '%s'", p15card->tokeninfo->last_update.gtime);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  589|      1|	return p15card->tokeninfo->last_update.gtime;
  590|      0|}
sc_pkcs15_encode_odf:
  658|    844|{
  659|    844|	struct sc_path path;
  660|    844|	struct sc_asn1_entry asn1_obj_or_path[] = {
  661|    844|		{ "path", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_SEQUENCE, 0, &path, NULL },
  ------------------
  |  |  174|    844|#define SC_ASN1_PATH			256
  ------------------
              		{ "path", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_SEQUENCE, 0, &path, NULL },
  ------------------
  |  |  141|    844|#define SC_ASN1_CONS			0x20000000
  ------------------
              		{ "path", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_SEQUENCE, 0, &path, NULL },
  ------------------
  |  |  162|    844|#define SC_ASN1_SEQUENCE                16
  ------------------
  662|    844|		{ NULL, 0, 0, 0, NULL, NULL }
  663|    844|	};
  664|    844|	struct sc_asn1_entry *asn1_paths = NULL;
  665|    844|	struct sc_asn1_entry *asn1_odf = NULL;
  666|    844|	int df_count = 0, r, c = 0;
  667|    844|	const int nr_indexes = sizeof(odf_indexes)/sizeof(odf_indexes[0]);
  668|    844|	struct sc_pkcs15_df *df;
  669|       |
  670|    844|	df = p15card->df_list;
  671|  3.69k|	while (df != NULL) {
  ------------------
  |  Branch (671:9): [True: 2.84k, False: 844]
  ------------------
  672|  2.84k|		df_count++;
  673|  2.84k|		df = df->next;
  674|  2.84k|	};
  675|    844|	if (df_count == 0)
  ------------------
  |  Branch (675:6): [True: 0, False: 844]
  ------------------
  676|    844|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  677|       |
  678|    844|	asn1_odf = malloc(sizeof(struct sc_asn1_entry) * (df_count + 1));
  679|    844|	if (asn1_odf == NULL) {
  ------------------
  |  Branch (679:6): [True: 0, False: 844]
  ------------------
  680|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  681|      0|		goto err;
  682|      0|	}
  683|    844|	asn1_paths = malloc(sizeof(struct sc_asn1_entry) * (df_count * 2));
  684|    844|	if (asn1_paths == NULL) {
  ------------------
  |  Branch (684:6): [True: 0, False: 844]
  ------------------
  685|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  686|      0|		goto err;
  687|      0|	}
  688|  3.69k|	for (df = p15card->df_list; df != NULL; df = df->next) {
  ------------------
  |  Branch (688:30): [True: 2.84k, False: 844]
  ------------------
  689|  2.84k|		int j, type = -1;
  690|       |
  691|  9.62k|		for (j = 0; j < nr_indexes; j++)
  ------------------
  |  Branch (691:15): [True: 9.62k, False: 0]
  ------------------
  692|  9.62k|			if (odf_indexes[j] == df->type) {
  ------------------
  |  Branch (692:8): [True: 2.84k, False: 6.77k]
  ------------------
  693|  2.84k|				type = j;
  694|  2.84k|				break;
  695|  2.84k|			}
  696|  2.84k|		if (type == -1) {
  ------------------
  |  Branch (696:7): [True: 0, False: 2.84k]
  ------------------
  697|      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__
  |  |  ------------------
  ------------------
  698|      0|			continue;
  699|      0|		}
  700|  2.84k|		asn1_odf[c] = c_asn1_odf[type];
  701|  2.84k|		sc_format_asn1_entry(asn1_odf + c, asn1_paths + 2*c, NULL, 1);
  702|  2.84k|		sc_copy_asn1_entry(asn1_obj_or_path, asn1_paths + 2*c);
  703|  2.84k|		sc_format_asn1_entry(asn1_paths + 2*c, &df->path, NULL, 1);
  704|  2.84k|		c++;
  705|  2.84k|	}
  706|    844|	asn1_odf[c].name = NULL;
  707|    844|	r = sc_asn1_encode(ctx, asn1_odf, buf, buflen);
  708|    844|err:
  709|    844|	if (asn1_paths != NULL)
  ------------------
  |  Branch (709:6): [True: 844, False: 0]
  ------------------
  710|    844|		free(asn1_paths);
  711|    844|	if (asn1_odf != NULL)
  ------------------
  |  Branch (711:6): [True: 844, False: 0]
  ------------------
  712|    844|		free(asn1_odf);
  713|    844|	return r;
  714|    844|}
sc_pkcs15_card_new:
  719|  27.8k|{
  720|  27.8k|	struct sc_pkcs15_card *p15card;
  721|       |
  722|  27.8k|	p15card = calloc(1, sizeof(struct sc_pkcs15_card));
  723|  27.8k|	if (p15card == NULL)
  ------------------
  |  Branch (723:6): [True: 0, False: 27.8k]
  ------------------
  724|      0|		return NULL;
  725|       |
  726|  27.8k|	p15card->tokeninfo = calloc(1, sizeof(struct sc_pkcs15_tokeninfo));
  727|  27.8k|	if (p15card->tokeninfo == NULL) {
  ------------------
  |  Branch (727:6): [True: 0, False: 27.8k]
  ------------------
  728|      0|		free(p15card);
  729|      0|		return NULL;
  730|      0|	}
  731|       |
  732|  27.8k|	p15card->magic = SC_PKCS15_CARD_MAGIC;
  ------------------
  |  |  519|  27.8k|#define SC_PKCS15_CARD_MAGIC		0x10203040
  ------------------
  733|  27.8k|	return p15card;
  734|  27.8k|}
sc_pkcs15_tokeninfo_new:
  739|  9.19k|{
  740|  9.19k|	struct sc_pkcs15_tokeninfo *tokeninfo;
  741|       |
  742|  9.19k|	tokeninfo = calloc(1, sizeof(struct sc_pkcs15_tokeninfo));
  743|  9.19k|	if (tokeninfo == NULL) {
  ------------------
  |  Branch (743:6): [True: 0, False: 9.19k]
  ------------------
  744|      0|		return NULL;
  745|      0|	}
  746|       |
  747|  9.19k|	sc_init_oid(&tokeninfo->profile_indication.oid);
  748|       |
  749|  9.19k|	return tokeninfo;
  750|  9.19k|}
sc_pkcs15_free_tokeninfo:
  781|  39.9k|{
  782|  39.9k|	if (!tokeninfo)
  ------------------
  |  Branch (782:6): [True: 2.94k, False: 37.0k]
  ------------------
  783|  2.94k|		return;
  784|       |
  785|  37.0k|	sc_pkcs15_clear_tokeninfo(tokeninfo);
  786|  37.0k|	free(tokeninfo);
  787|  37.0k|}
sc_pkcs15_free_app:
  791|  66.7k|{
  792|  66.7k|	if (p15card && p15card->app) {
  ------------------
  |  Branch (792:6): [True: 66.7k, False: 0]
  |  Branch (792:17): [True: 725, False: 66.0k]
  ------------------
  793|    725|		free(p15card->app->label);
  794|    725|		free(p15card->app->ddo.value);
  795|    725|		free(p15card->app);
  796|       |		p15card->app = NULL;
  797|    725|	}
  798|  66.7k|}
sc_pkcs15_card_free:
  803|  27.8k|{
  804|  27.8k|	if (p15card == NULL || p15card->magic != SC_PKCS15_CARD_MAGIC)
  ------------------
  |  |  519|  27.8k|#define SC_PKCS15_CARD_MAGIC		0x10203040
  ------------------
  |  Branch (804:6): [True: 0, False: 27.8k]
  |  Branch (804:25): [True: 0, False: 27.8k]
  ------------------
  805|      0|		return;
  806|       |
  807|  27.8k|	if (p15card->ops.clear)
  ------------------
  |  Branch (807:6): [True: 702, False: 27.1k]
  ------------------
  808|    702|		p15card->ops.clear(p15card);
  809|       |
  810|       |	/* For more complicated MD data a dedicated release procedure
  811|       |	 * has to be implemented. */
  812|  27.8k|	if (p15card->md_data)
  ------------------
  |  Branch (812:6): [True: 0, False: 27.8k]
  ------------------
  813|      0|		free(p15card->md_data);
  814|       |
  815|  27.8k|	sc_pkcs15_free_app(p15card);
  816|  27.8k|	sc_pkcs15_remove_objects(p15card);
  817|  27.8k|	sc_pkcs15_remove_dfs(p15card);
  818|  27.8k|	sc_pkcs15_free_unusedspace(p15card);
  819|  27.8k|	p15card->unusedspace_read = 0;
  820|       |
  821|  27.8k|	sc_file_free(p15card->file_app);
  822|  27.8k|	sc_file_free(p15card->file_tokeninfo);
  823|  27.8k|	sc_file_free(p15card->file_odf);
  824|  27.8k|	sc_file_free(p15card->file_unusedspace);
  825|       |
  826|  27.8k|	p15card->magic = 0;
  827|  27.8k|	sc_pkcs15_free_tokeninfo(p15card->tokeninfo);
  828|  27.8k|	sc_pkcs15_free_app(p15card);
  829|  27.8k|	free(p15card);
  830|  27.8k|}
sc_pkcs15_card_clear:
  835|  10.9k|{
  836|  10.9k|	if (p15card == NULL)
  ------------------
  |  Branch (836:6): [True: 0, False: 10.9k]
  ------------------
  837|      0|		return;
  838|       |
  839|  10.9k|	if (p15card->ops.clear)
  ------------------
  |  Branch (839:6): [True: 672, False: 10.2k]
  ------------------
  840|    672|		p15card->ops.clear(p15card);
  841|       |
  842|  10.9k|	p15card->flags = 0;
  843|  10.9k|	p15card->tokeninfo->version = 0;
  844|  10.9k|	p15card->tokeninfo->flags   = 0;
  845|       |
  846|  10.9k|	sc_pkcs15_remove_objects(p15card);
  847|  10.9k|	sc_pkcs15_remove_dfs(p15card);
  848|       |
  849|  10.9k|	p15card->df_list = NULL;
  850|  10.9k|	sc_file_free(p15card->file_app);
  851|  10.9k|	p15card->file_app = NULL;
  852|  10.9k|	sc_file_free(p15card->file_tokeninfo);
  853|  10.9k|	p15card->file_tokeninfo = NULL;
  854|  10.9k|	sc_file_free(p15card->file_odf);
  855|  10.9k|	p15card->file_odf = NULL;
  856|  10.9k|	sc_file_free(p15card->file_unusedspace);
  857|  10.9k|	p15card->file_unusedspace = NULL;
  858|       |
  859|  10.9k|	free(p15card->tokeninfo->label);
  860|  10.9k|	p15card->tokeninfo->label = NULL;
  861|  10.9k|	free(p15card->tokeninfo->serial_number);
  862|  10.9k|	p15card->tokeninfo->serial_number = NULL;
  863|  10.9k|	free(p15card->tokeninfo->manufacturer_id);
  864|  10.9k|	p15card->tokeninfo->manufacturer_id = NULL;
  865|  10.9k|	free(p15card->tokeninfo->last_update.gtime);
  866|  10.9k|	p15card->tokeninfo->last_update.gtime = NULL;
  867|  10.9k|	free(p15card->tokeninfo->preferred_language);
  868|  10.9k|	p15card->tokeninfo->preferred_language = NULL;
  869|  10.9k|	free(p15card->tokeninfo->profile_indication.name);
  870|  10.9k|	p15card->tokeninfo->profile_indication.name = NULL;
  871|  10.9k|	if (p15card->tokeninfo->seInfo != NULL) {
  ------------------
  |  Branch (871:6): [True: 5, False: 10.9k]
  ------------------
  872|      5|		size_t i;
  873|     17|		for (i = 0; i < p15card->tokeninfo->num_seInfo; i++)
  ------------------
  |  Branch (873:15): [True: 12, False: 5]
  ------------------
  874|     12|			free(p15card->tokeninfo->seInfo[i]);
  875|      5|		free(p15card->tokeninfo->seInfo);
  876|      5|		p15card->tokeninfo->seInfo     = NULL;
  877|      5|		p15card->tokeninfo->num_seInfo = 0;
  878|      5|	}
  879|       |
  880|  10.9k|	sc_pkcs15_free_app(p15card);
  881|  10.9k|}
sc_find_app:
  886|  10.9k|{
  887|  10.9k|	int ii;
  888|       |
  889|  10.9k|	if (card->app_count <= 0)
  ------------------
  |  Branch (889:6): [True: 10.7k, False: 217]
  ------------------
  890|  10.7k|		return NULL;
  891|       |
  892|    217|	if (!aid || !aid->len)
  ------------------
  |  Branch (892:6): [True: 217, False: 0]
  |  Branch (892:14): [True: 0, False: 0]
  ------------------
  893|    217|		return card->app[0];
  894|       |
  895|      0|	for (ii=0; ii < card->app_count; ii++) {
  ------------------
  |  Branch (895:13): [True: 0, False: 0]
  ------------------
  896|      0|		if (card->app[ii]->aid.len != aid->len)
  ------------------
  |  Branch (896:7): [True: 0, False: 0]
  ------------------
  897|      0|			continue;
  898|      0|		if (memcmp(card->app[ii]->aid.value, aid->value, aid->len))
  ------------------
  |  Branch (898:7): [True: 0, False: 0]
  ------------------
  899|      0|			continue;
  900|      0|		return card->app[ii];
  901|      0|	}
  902|      0|	return NULL;
  903|      0|}
sc_pkcs15_bind_internal_odf:
  983|  1.70k|{
  984|  1.70k|	struct sc_path tmppath;
  985|  1.70k|	struct sc_card    *card = p15card->card;
  986|  1.70k|	struct sc_context *ctx = card->ctx;
  987|  1.70k|	struct sc_pkcs15_df *df;
  988|  1.70k|	unsigned char *buf = NULL;
  989|  1.70k|	size_t len;
  990|  1.70k|	int    err, ok = 0;
  991|       |
  992|  1.70k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  1.70k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.70k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.70k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.70k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.70k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  993|  1.70k|	if (p15card->file_odf == NULL) {
  ------------------
  |  Branch (993:6): [True: 1.70k, False: 0]
  ------------------
  994|       |		/* check if an ODF is present; we don't know yet whether we have a pkcs15 card */
  995|  1.70k|		sc_format_path("5031", &tmppath);
  996|  1.70k|		err = sc_pkcs15_make_absolute_path(&p15card->file_app->path, &tmppath);
  997|  1.70k|		if (err != SC_SUCCESS)   {
  ------------------
  |  |   28|  1.70k|#define SC_SUCCESS				0
  ------------------
  |  Branch (997:7): [True: 0, False: 1.70k]
  ------------------
  998|      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__
  |  |  ------------------
  ------------------
  999|      0|			goto end;
 1000|      0|		}
 1001|  1.70k|		sc_log(ctx, "absolute path to EF(ODF) %s", sc_print_path(&tmppath));
  ------------------
  |  |   71|  1.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__
  |  |  ------------------
  ------------------
 1002|  1.70k|		err = sc_select_file(card, &tmppath, &p15card->file_odf);
 1003|  1.70k|	}
 1004|      0|	else {
 1005|      0|		tmppath = p15card->file_odf->path;
 1006|      0|		sc_file_free(p15card->file_odf);
 1007|      0|		p15card->file_odf = NULL;
 1008|      0|		err = sc_select_file(card, &tmppath, &p15card->file_odf);
 1009|      0|	}
 1010|       |
 1011|  1.70k|	if (err != SC_SUCCESS) {
  ------------------
  |  |   28|  1.70k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1011:6): [True: 181, False: 1.52k]
  ------------------
 1012|    181|		sc_log(ctx, "EF(ODF) not found in '%s'", sc_print_path(&tmppath));
  ------------------
  |  |   71|    181|#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|    181|		goto end;
 1014|    181|	}
 1015|       |
 1016|  1.52k|	len = p15card->file_odf->size;
 1017|  1.52k|	if (!len) {
  ------------------
  |  Branch (1017:6): [True: 551, False: 975]
  ------------------
 1018|    551|		sc_log(ctx, "EF(ODF) is empty");
  ------------------
  |  |   71|    551|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1019|    551|		goto end;
 1020|    551|	}
 1021|    975|	if (len > MAX_FILE_SIZE) {
  ------------------
  |  |  220|    975|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (1021:6): [True: 598, False: 377]
  ------------------
 1022|    598|		sc_log(ctx, "EF(ODF) too large");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1023|    598|		goto end;
 1024|    598|	}
 1025|    377|	buf = malloc(len);
 1026|    377|	if(buf == NULL) {
  ------------------
  |  Branch (1026:5): [True: 0, False: 377]
  ------------------
 1027|      0|		err = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1028|      0|		goto end;
 1029|      0|	}
 1030|       |
 1031|    377|	err = -1; /* file state: not in cache */
 1032|    377|	if (p15card->opts.use_file_cache) {
  ------------------
  |  Branch (1032:6): [True: 83, False: 294]
  ------------------
 1033|     83|		err = sc_pkcs15_read_cached_file(p15card, &tmppath, &buf, &len);
 1034|     83|		if (err == SC_SUCCESS)
  ------------------
  |  |   28|     83|#define SC_SUCCESS				0
  ------------------
  |  Branch (1034:7): [True: 1, False: 82]
  ------------------
 1035|      1|			err = (int)len;
 1036|     83|	}
 1037|    377|	if (err < 0) {
  ------------------
  |  Branch (1037:6): [True: 376, False: 1]
  ------------------
 1038|    376|		err = sc_read_binary(card, 0, buf, len, 0);
 1039|    376|		if (err < 2) {
  ------------------
  |  Branch (1039:7): [True: 63, False: 313]
  ------------------
 1040|     63|			if (err < 0) {
  ------------------
  |  Branch (1040:8): [True: 53, False: 10]
  ------------------
 1041|     53|				sc_log(ctx, "read EF(ODF) file error: %s", sc_strerror(err));
  ------------------
  |  |   71|     53|#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|     53|			} else {
 1043|     10|				err = SC_ERROR_PKCS15_APP_NOT_FOUND;
  ------------------
  |  |  131|     10|#define SC_ERROR_PKCS15_APP_NOT_FOUND		-1901
  ------------------
 1044|     10|				sc_log(ctx, "Invalid content of EF(ODF): %s", sc_strerror(err));
  ------------------
  |  |   71|     10|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1045|     10|			}
 1046|     63|			goto end;
 1047|     63|		}
 1048|       |		/* sc_read_binary may return less than requested */
 1049|    313|		len = err;
 1050|       |
 1051|    313|		if (p15card->opts.use_file_cache) {
  ------------------
  |  Branch (1051:7): [True: 65, False: 248]
  ------------------
 1052|     65|			sc_pkcs15_cache_file(p15card, &tmppath, buf, len);
 1053|     65|		}
 1054|    313|	}
 1055|       |
 1056|    314|	if (parse_odf(buf, len, p15card)) {
  ------------------
  |  Branch (1056:6): [True: 30, False: 284]
  ------------------
 1057|     30|		err = SC_ERROR_PKCS15_APP_NOT_FOUND;
  ------------------
  |  |  131|     30|#define SC_ERROR_PKCS15_APP_NOT_FOUND		-1901
  ------------------
 1058|     30|		sc_log(ctx, "Unable to parse ODF");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1059|     30|		goto end;
 1060|     30|	}
 1061|    284|	free(buf);
 1062|    284|	buf = NULL;
 1063|       |
 1064|    284|	sc_log(ctx, "The following DFs were found:");
  ------------------
  |  |   71|    284|#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|    827|	for (df = p15card->df_list; df; df = df->next)
  ------------------
  |  Branch (1065:30): [True: 543, False: 284]
  ------------------
 1066|    543|		sc_log(ctx, "  DF type %u, path %s, index %u, count %d", df->type,
  ------------------
  |  |   71|    827|#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|    284|				sc_print_path(&df->path), df->path.index, df->path.count);
 1068|       |
 1069|    284|	ok = 1;
 1070|  1.70k|end:
 1071|  1.70k|	if (buf != NULL)
  ------------------
  |  Branch (1071:6): [True: 93, False: 1.61k]
  ------------------
 1072|     93|		free(buf);
 1073|  1.70k|	if (!ok) {
  ------------------
  |  Branch (1073:6): [True: 1.42k, False: 284]
  ------------------
 1074|  1.42k|		LOG_FUNC_RETURN(ctx, err);
  ------------------
  |  |  164|  1.42k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.42k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.42k|	int _ret = r; \
  |  |  |  |  155|  1.42k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.42k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.42k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    274|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 274, False: 1.14k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.42k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.42k|	} else { \
  |  |  |  |  159|      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.42k|	return _ret; \
  |  |  |  |  163|  1.42k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1075|  1.42k|	}
 1076|       |
 1077|    284|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    284|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    284|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    284|	int _ret = r; \
  |  |  |  |  155|    284|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 284, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    284|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 284]
  |  |  |  |  ------------------
  |  |  |  |  157|    284|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    284|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    284|	return _ret; \
  |  |  |  |  163|    284|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1078|    284|}
sc_pkcs15_bind_internal_tokeninfo:
 1082|  10.8k|{
 1083|  10.8k|	struct sc_path tmppath;
 1084|  10.8k|	struct sc_card *card = p15card->card;
 1085|  10.8k|	struct sc_context *ctx = card->ctx;
 1086|  10.8k|	struct sc_pkcs15_tokeninfo tokeninfo;
 1087|  10.8k|	unsigned char *buf = NULL;
 1088|  10.8k|	size_t len;
 1089|  10.8k|	int err, ok = 0;
 1090|       |
 1091|  10.8k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  10.8k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  10.8k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  10.8k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  10.8k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 10.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1092|       |
 1093|  10.8k|	if (p15card->file_tokeninfo == NULL) {
  ------------------
  |  Branch (1093:6): [True: 10.8k, False: 17]
  ------------------
 1094|  10.8k|		sc_format_path("5032", &tmppath);
 1095|  10.8k|		err = sc_pkcs15_make_absolute_path(&p15card->file_app->path, &tmppath);
 1096|  10.8k|		if (err != SC_SUCCESS)   {
  ------------------
  |  |   28|  10.8k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1096:7): [True: 0, False: 10.8k]
  ------------------
 1097|      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__
  |  |  ------------------
  ------------------
 1098|      0|			goto end;
 1099|      0|		}
 1100|  10.8k|		sc_log(ctx, "absolute path to EF(TokenInfo) %s", sc_print_path(&tmppath));
  ------------------
  |  |   71|  10.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__
  |  |  ------------------
  ------------------
 1101|  10.8k|	}
 1102|     17|	else {
 1103|     17|		tmppath = p15card->file_tokeninfo->path;
 1104|     17|		sc_file_free(p15card->file_tokeninfo);
 1105|     17|		p15card->file_tokeninfo = NULL;
 1106|     17|	}
 1107|       |
 1108|  10.8k|	err = sc_select_file(card, &tmppath, &p15card->file_tokeninfo);
 1109|  10.8k|	if (err)   {
  ------------------
  |  Branch (1109:6): [True: 8.78k, False: 2.04k]
  ------------------
 1110|  8.78k|		sc_log(ctx, "cannot select EF(TokenInfo) file: %s", sc_strerror(err));
  ------------------
  |  |   71|  8.78k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1111|  8.78k|		goto end;
 1112|  8.78k|	}
 1113|       |
 1114|  2.04k|	len = p15card->file_tokeninfo->size;
 1115|  2.04k|	if (!len) {
  ------------------
  |  Branch (1115:6): [True: 936, False: 1.11k]
  ------------------
 1116|    936|		sc_log(ctx, "EF(TokenInfo) is empty");
  ------------------
  |  |   71|    936|#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|    936|		goto end;
 1118|    936|	}
 1119|  1.11k|	if (len > MAX_FILE_SIZE) {
  ------------------
  |  |  220|  1.11k|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (1119:6): [True: 698, False: 412]
  ------------------
 1120|    698|		sc_log(ctx, "EF(TokenInfo) too large");
  ------------------
  |  |   71|    698|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1121|    698|		goto end;
 1122|    698|	}
 1123|    412|	buf = malloc(len);
 1124|    412|	if(buf == NULL) {
  ------------------
  |  Branch (1124:5): [True: 0, False: 412]
  ------------------
 1125|      0|		err = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1126|      0|		goto end;
 1127|      0|	}
 1128|       |
 1129|    412|	err = -1; /* file state: not in cache */
 1130|    412|	if (p15card->opts.use_file_cache) {
  ------------------
  |  Branch (1130:6): [True: 277, False: 135]
  ------------------
 1131|    277|		err = sc_pkcs15_read_cached_file(p15card, &tmppath, &buf, &len);
 1132|    277|		if (err == SC_SUCCESS)
  ------------------
  |  |   28|    277|#define SC_SUCCESS				0
  ------------------
  |  Branch (1132:7): [True: 0, False: 277]
  ------------------
 1133|      0|			err = (int)len;
 1134|    277|	}
 1135|    412|	if (err < 0) {
  ------------------
  |  Branch (1135:6): [True: 412, False: 0]
  ------------------
 1136|    412|		err = sc_read_binary(card, 0, buf, len, 0);
 1137|    412|		if (err <= 2) {
  ------------------
  |  Branch (1137:7): [True: 231, False: 181]
  ------------------
 1138|    231|			if (err < 0)   {
  ------------------
  |  Branch (1138:8): [True: 73, False: 158]
  ------------------
 1139|     73|				sc_log(ctx, "read EF(TokenInfo) file error: %s", sc_strerror(err));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1140|    158|			} else {
 1141|    158|				err = SC_ERROR_PKCS15_APP_NOT_FOUND;
  ------------------
  |  |  131|    158|#define SC_ERROR_PKCS15_APP_NOT_FOUND		-1901
  ------------------
 1142|    158|				sc_log(ctx, "Invalid content of EF(TokenInfo): %s", sc_strerror(err));
  ------------------
  |  |   71|    158|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1143|    158|			}
 1144|    231|			goto end;
 1145|    231|		}
 1146|       |		/* sc_read_binary may return less than requested */
 1147|    181|		len = err;
 1148|       |
 1149|    181|		if (p15card->opts.use_file_cache) {
  ------------------
  |  Branch (1149:7): [True: 134, False: 47]
  ------------------
 1150|    134|			sc_pkcs15_cache_file(p15card, &tmppath, buf, len);
 1151|    134|		}
 1152|    181|	}
 1153|       |
 1154|    181|	memset(&tokeninfo, 0, sizeof(tokeninfo));
 1155|    181|	err = sc_pkcs15_parse_tokeninfo(ctx, &tokeninfo, buf, (size_t)err);
 1156|    181|	if (err != SC_SUCCESS)   {
  ------------------
  |  |   28|    181|#define SC_SUCCESS				0
  ------------------
  |  Branch (1156:6): [True: 108, False: 73]
  ------------------
 1157|    108|		sc_log(ctx, "cannot parse TokenInfo content: %s", sc_strerror(err));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1158|    108|		goto end;
 1159|    108|	}
 1160|       |
 1161|     73|	sc_pkcs15_clear_tokeninfo(p15card->tokeninfo);
 1162|     73|	*(p15card->tokeninfo) = tokeninfo;
 1163|       |
 1164|     73|	if (!p15card->tokeninfo->serial_number && 0 == card->serialnr.len) {
  ------------------
  |  Branch (1164:6): [True: 1, False: 72]
  |  Branch (1164:44): [True: 1, False: 0]
  ------------------
 1165|      1|		sc_card_ctl(p15card->card, SC_CARDCTL_GET_SERIALNR, &card->serialnr);
 1166|      1|	}
 1167|       |
 1168|     73|	if (!p15card->tokeninfo->serial_number && card->serialnr.len)   {
  ------------------
  |  Branch (1168:6): [True: 1, False: 72]
  |  Branch (1168:44): [True: 0, False: 1]
  ------------------
 1169|      0|		char *serial = calloc(1, card->serialnr.len*2 + 1);
 1170|      0|		size_t ii;
 1171|      0|		if (!serial) {
  ------------------
  |  Branch (1171:7): [True: 0, False: 0]
  ------------------
 1172|      0|			err = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1173|      0|			goto end;
 1174|      0|		}
 1175|       |
 1176|      0|		for(ii=0;ii<card->serialnr.len;ii++)
  ------------------
  |  Branch (1176:12): [True: 0, False: 0]
  ------------------
 1177|      0|			sprintf(serial + ii*2, "%02X", *(card->serialnr.value + ii));
 1178|       |
 1179|      0|		p15card->tokeninfo->serial_number = serial;
 1180|      0|		sc_log(ctx, "p15card->tokeninfo->serial_number %s", p15card->tokeninfo->serial_number);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1181|      0|	}
 1182|       |
 1183|     73|	ok = 1;
 1184|  10.8k|end:
 1185|  10.8k|	if (buf != NULL)
  ------------------
  |  Branch (1185:6): [True: 412, False: 10.4k]
  ------------------
 1186|    412|		free(buf);
 1187|  10.8k|	if (!ok) {
  ------------------
  |  Branch (1187:6): [True: 10.7k, False: 73]
  ------------------
 1188|  10.7k|		LOG_FUNC_RETURN(ctx, err);
  ------------------
  |  |  164|  10.7k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  10.7k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  10.7k|	int _ret = r; \
  |  |  |  |  155|  10.7k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 10.7k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  10.7k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  9.12k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 9.12k, False: 1.63k]
  |  |  |  |  ------------------
  |  |  |  |  157|  10.7k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  10.7k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|  10.7k|	return _ret; \
  |  |  |  |  163|  10.7k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1189|  10.7k|	}
 1190|       |
 1191|     73|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     73|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     73|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     73|	int _ret = r; \
  |  |  |  |  155|     73|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 73, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     73|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 73]
  |  |  |  |  ------------------
  |  |  |  |  157|     73|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     73|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     73|	return _ret; \
  |  |  |  |  163|     73|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1192|     73|}
sc_pkcs15_bind_internal:
 1196|  10.9k|{
 1197|  10.9k|	struct sc_card *card = p15card->card;
 1198|  10.9k|	struct sc_context *ctx = card->ctx;
 1199|  10.9k|	const struct sc_app_info *info = NULL;
 1200|  10.9k|	int err, ok = 0;
 1201|       |
 1202|  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1203|       |	/* Enumerate apps now */
 1204|  10.9k|	if (card->app_count < 0) {
  ------------------
  |  Branch (1204:6): [True: 6.52k, False: 4.45k]
  ------------------
 1205|  6.52k|		err = sc_enum_apps(card);
 1206|  6.52k|		if (err != SC_SUCCESS)
  ------------------
  |  |   28|  6.52k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1206:7): [True: 6.31k, False: 213]
  ------------------
 1207|  6.31k|			sc_log(ctx, "unable to enumerate apps: %s", sc_strerror(err));
  ------------------
  |  |   71|  6.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__
  |  |  ------------------
  ------------------
 1208|  6.52k|	}
 1209|  10.9k|	sc_file_free(p15card->file_app);
 1210|  10.9k|	p15card->file_app = sc_file_new();
 1211|  10.9k|	if (p15card->file_app == NULL) {
  ------------------
  |  Branch (1211:6): [True: 0, False: 10.9k]
  ------------------
 1212|      0|		err = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1213|      0|		goto end;
 1214|      0|	}
 1215|       |
 1216|  10.9k|	sc_format_path("3F005015", &p15card->file_app->path);
 1217|       |
 1218|  10.9k|	info = sc_find_app(card, aid);
 1219|  10.9k|	if (info) {
  ------------------
  |  Branch (1219:6): [True: 217, False: 10.7k]
  ------------------
 1220|    217|		sc_log(ctx, "bind to application('%s',aid:'%s')", info->label, sc_dump_hex(info->aid.value, info->aid.len));
  ------------------
  |  |   71|    217|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1221|    217|		sc_pkcs15_free_app(p15card);
 1222|    217|		p15card->app = sc_dup_app_info(info);
 1223|    217|		if (!p15card->app) {
  ------------------
  |  Branch (1223:7): [True: 0, False: 217]
  ------------------
 1224|      0|			err = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1225|      0|			goto end;
 1226|      0|		}
 1227|       |
 1228|    217|		if (info->path.len)
  ------------------
  |  Branch (1228:7): [True: 114, False: 103]
  ------------------
 1229|    114|			p15card->file_app->path = info->path;
 1230|       |
 1231|    217|		if (info->ddo.value && info->ddo.len)
  ------------------
  |  Branch (1231:7): [True: 106, False: 111]
  |  Branch (1231:26): [True: 95, False: 11]
  ------------------
 1232|     95|			parse_ddo(p15card, info->ddo.value, info->ddo.len);
 1233|       |
 1234|  10.7k|	} else if (aid) {
  ------------------
  |  Branch (1234:13): [True: 0, False: 10.7k]
  ------------------
 1235|      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__
  |  |  ------------------
  ------------------
 1236|      0|		err = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1237|      0|		goto end;
 1238|      0|	}
 1239|  10.9k|	sc_log(ctx, "application path '%s'", sc_print_path(&p15card->file_app->path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1240|       |
 1241|       |	/* Check if pkcs15 directory exists */
 1242|  10.9k|	err = sc_select_file(card, &p15card->file_app->path, NULL);
 1243|       |
 1244|       |	/* If the above test failed on cards without EF(DIR),
 1245|       |	 * try to continue read ODF from 3F005031. -aet
 1246|       |	 */
 1247|  10.9k|	if ((err != SC_SUCCESS) && (card->app_count < 1)) {
  ------------------
  |  |   28|  10.9k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1247:6): [True: 8.20k, False: 2.77k]
  |  Branch (1247:29): [True: 8.05k, False: 149]
  ------------------
 1248|  8.05k|		sc_format_path("3F00", &p15card->file_app->path);
 1249|  8.05k|		err = SC_SUCCESS;
  ------------------
  |  |   28|  8.05k|#define SC_SUCCESS				0
  ------------------
 1250|  8.05k|	}
 1251|       |
 1252|  10.9k|	if (err < 0) {
  ------------------
  |  Branch (1252:6): [True: 149, False: 10.8k]
  ------------------
 1253|    149|		sc_log(ctx, "Cannot select application path");
  ------------------
  |  |   71|    149|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1254|    149|		goto end;
 1255|    149|	}
 1256|       |
 1257|  10.8k|	err = sc_pkcs15_bind_internal_tokeninfo(p15card);
 1258|  10.8k|	if (err < 0) {
  ------------------
  |  Branch (1258:6): [True: 9.12k, False: 1.70k]
  ------------------
 1259|  9.12k|		sc_log(ctx, "Cannot bind tokeninfo");
  ------------------
  |  |   71|  9.12k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1260|  9.12k|		goto end;
 1261|  9.12k|	}
 1262|       |
 1263|  1.70k|	err = sc_pkcs15_bind_internal_odf(p15card);
 1264|  1.70k|	if (err < 0) {
  ------------------
  |  Branch (1264:6): [True: 274, False: 1.43k]
  ------------------
 1265|    274|		sc_log(ctx, "Cannot bind ODF");
  ------------------
  |  |   71|    274|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1266|    274|		goto end;
 1267|    274|	}
 1268|       |
 1269|  1.43k|	ok = 1;
 1270|  10.9k|end:
 1271|  10.9k|	if (!ok) {
  ------------------
  |  Branch (1271:6): [True: 9.54k, False: 1.43k]
  ------------------
 1272|  9.54k|		sc_pkcs15_card_clear(p15card);
 1273|  9.54k|		if (err == SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|  9.54k|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (1273:7): [True: 860, False: 8.68k]
  ------------------
 1274|    860|			err = SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|    860|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
 1275|  9.54k|		LOG_FUNC_RETURN(ctx, err);
  ------------------
  |  |  164|  9.54k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  9.54k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  9.54k|	int _ret = r; \
  |  |  |  |  155|  9.54k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 9.54k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  9.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|  9.54k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 9.54k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  9.54k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  9.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|  9.54k|	return _ret; \
  |  |  |  |  163|  9.54k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1276|  9.54k|	}
 1277|       |
 1278|  1.43k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  1.43k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 1.43k]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1279|  1.43k|}
pkcs15_get_default_use_file_cache:
 1282|  10.6k|{
 1283|       |	/* enable file caching by default for cards with static content to avoid
 1284|       |	 * synchronization problems.
 1285|       |	 *
 1286|       |	 * The following list was initialized with the cards that can't be modified
 1287|       |	 * with OpenSC i.e. which don't have a profile/driver for pkcs15-init. */
 1288|  10.6k|	const char *card_drivers_with_file_cache[] = {
 1289|  10.6k|			"atrust-acos",
 1290|  10.6k|			"belpic",
 1291|  10.6k|			"cac1",
 1292|  10.6k|			"cac",
 1293|  10.6k|			"cedulauy",
 1294|  10.6k|			"coolkey",
 1295|  10.6k|			"edo",
 1296|  10.6k|			"esteid2018",
 1297|  10.6k|			"esteid2025",
 1298|  10.6k|			"flex",
 1299|  10.6k|			"cyberflex",
 1300|  10.6k|			"gemsafeV1",
 1301|  10.6k|			"idprime",
 1302|  10.6k|			"itacns",
 1303|  10.6k|			"jpki",
 1304|  10.6k|			"MaskTech",
 1305|  10.6k|			"mcrd",
 1306|  10.6k|			"myeid",
 1307|  10.6k|			"npa",
 1308|  10.6k|			"nqapplet",
 1309|  10.6k|			"tcos",
 1310|  10.6k|			"dtrust",
 1311|  10.6k|			"lteid",
 1312|  10.6k|	};
 1313|       |
 1314|  10.6k|	if (NULL == card || NULL == card->driver || NULL == card->driver->short_name)
  ------------------
  |  Branch (1314:6): [True: 0, False: 10.6k]
  |  Branch (1314:22): [True: 0, False: 10.6k]
  |  Branch (1314:46): [True: 0, False: 10.6k]
  ------------------
 1315|      0|		return "no";
 1316|   239k|	for (size_t i = 0; i < (sizeof card_drivers_with_file_cache / sizeof *card_drivers_with_file_cache); i++) {
  ------------------
  |  Branch (1316:21): [True: 230k, False: 8.54k]
  ------------------
 1317|   230k|		if (0 == strcmp(card->driver->short_name, card_drivers_with_file_cache[i]))
  ------------------
  |  Branch (1317:7): [True: 2.07k, False: 228k]
  ------------------
 1318|  2.07k|			return "public";
 1319|   230k|	}
 1320|       |
 1321|  8.54k|	return "no";
 1322|  10.6k|}
sc_pkcs15_bind:
 1327|  10.6k|{
 1328|  10.6k|	struct sc_pkcs15_card *p15card = NULL;
 1329|  10.6k|	struct sc_context *ctx;
 1330|  10.6k|	scconf_block *conf_block = NULL;
 1331|  10.6k|	int r, emu_first, enable_emu;
 1332|  10.6k|	const char *use_file_cache;
 1333|  10.6k|	const char *pin_protected_certificate, *private_certificate;
 1334|       |
 1335|  10.6k|	if (card == NULL || p15card_out == NULL) {
  ------------------
  |  Branch (1335:6): [True: 0, False: 10.6k]
  |  Branch (1335:22): [True: 0, False: 10.6k]
  ------------------
 1336|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1337|      0|	}
 1338|  10.6k|	ctx = card->ctx;
 1339|       |
 1340|  10.6k|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1341|  10.6k|	sc_log(ctx, "application(aid:'%s')", aid ? sc_dump_hex(aid->value, aid->len) : "empty");
  ------------------
  |  |   71|  21.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__
  |  |  ------------------
  |  |  |  Branch (71:122): [True: 0, False: 10.6k]
  |  |  ------------------
  ------------------
 1342|       |
 1343|  10.6k|	p15card = sc_pkcs15_card_new();
 1344|  10.6k|	if (p15card == NULL)
  ------------------
  |  Branch (1344:6): [True: 0, False: 10.6k]
  ------------------
 1345|  10.6k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1346|       |
 1347|  10.6k|	p15card->card = card;
 1348|  10.6k|	p15card->opts.use_file_cache = SC_PKCS15_OPTS_CACHE_NO_FILES;
  ------------------
  |  |  604|  10.6k|#define SC_PKCS15_OPTS_CACHE_NO_FILES			0
  ------------------
 1349|  10.6k|	use_file_cache = pkcs15_get_default_use_file_cache(card);
 1350|  10.6k|	p15card->opts.use_pin_cache = 1;
 1351|  10.6k|	p15card->opts.pin_cache_counter = 10;
 1352|  10.6k|	p15card->opts.pin_cache_ignore_user_consent = 0;
 1353|  10.6k|	pin_protected_certificate = "protect";
 1354|  10.6k|	private_certificate = "";
 1355|       |
 1356|  10.6k|	conf_block = sc_get_conf_block(ctx, "framework", "pkcs15", 1);
 1357|  10.6k|	if (conf_block) {
  ------------------
  |  Branch (1357:6): [True: 0, False: 10.6k]
  ------------------
 1358|      0|		use_file_cache = scconf_get_str(conf_block, "use_file_caching", use_file_cache);
 1359|      0|		p15card->opts.use_pin_cache = scconf_get_bool(conf_block, "use_pin_caching", p15card->opts.use_pin_cache);
 1360|      0|		p15card->opts.pin_cache_counter = scconf_get_int(conf_block, "pin_cache_counter", p15card->opts.pin_cache_counter);
 1361|      0|		p15card->opts.pin_cache_ignore_user_consent = scconf_get_bool(conf_block, "pin_cache_ignore_user_consent",
 1362|      0|				p15card->opts.pin_cache_ignore_user_consent);
 1363|      0|		pin_protected_certificate = scconf_get_str(conf_block, "pin_protected_certificate", pin_protected_certificate);
 1364|       |		/* read also the old value to keep backward compatibility */
 1365|      0|		private_certificate = scconf_get_str(conf_block, "private_certificate", private_certificate);
 1366|      0|	}
 1367|       |
 1368|  10.6k|	if (0 == strcmp(use_file_cache, "yes")) {
  ------------------
  |  Branch (1368:6): [True: 0, False: 10.6k]
  ------------------
 1369|      0|		p15card->opts.use_file_cache = SC_PKCS15_OPTS_CACHE_ALL_FILES;
  ------------------
  |  |  606|      0|#define SC_PKCS15_OPTS_CACHE_ALL_FILES			2
  ------------------
 1370|  10.6k|	} else if (0 == strcmp(use_file_cache, "public")) {
  ------------------
  |  Branch (1370:13): [True: 2.07k, False: 8.54k]
  ------------------
 1371|  2.07k|		p15card->opts.use_file_cache = SC_PKCS15_OPTS_CACHE_PUBLIC_FILES;
  ------------------
  |  |  605|  2.07k|#define SC_PKCS15_OPTS_CACHE_PUBLIC_FILES		1
  ------------------
 1372|  8.54k|	} else if (0 == strcmp(use_file_cache, "no")) {
  ------------------
  |  Branch (1372:13): [True: 8.54k, False: 0]
  ------------------
 1373|  8.54k|		p15card->opts.use_file_cache = SC_PKCS15_OPTS_CACHE_NO_FILES;
  ------------------
  |  |  604|  8.54k|#define SC_PKCS15_OPTS_CACHE_NO_FILES			0
  ------------------
 1374|  8.54k|	}
 1375|       |
 1376|  10.6k|	if (0 == strcmp(pin_protected_certificate, "protect")) {
  ------------------
  |  Branch (1376:6): [True: 10.6k, False: 0]
  ------------------
 1377|  10.6k|		p15card->opts.pin_protected_certificate = SC_PKCS15_CARD_OPTS_PRIV_CERT_PROTECT;
  ------------------
  |  |  609|  10.6k|#define SC_PKCS15_CARD_OPTS_PRIV_CERT_PROTECT		0
  ------------------
 1378|  10.6k|	} else if (0 == strcmp(pin_protected_certificate, "ignore")) {
  ------------------
  |  Branch (1378:13): [True: 0, False: 0]
  ------------------
 1379|      0|		p15card->opts.pin_protected_certificate = SC_PKCS15_CARD_OPTS_PRIV_CERT_IGNORE;
  ------------------
  |  |  610|      0|#define SC_PKCS15_CARD_OPTS_PRIV_CERT_IGNORE		1
  ------------------
 1380|      0|	} else if (0 == strcmp(pin_protected_certificate, "declassify")) {
  ------------------
  |  Branch (1380:13): [True: 0, False: 0]
  ------------------
 1381|      0|		p15card->opts.pin_protected_certificate = SC_PKCS15_CARD_OPTS_PRIV_CERT_DECLASSIFY;
  ------------------
  |  |  611|      0|#define SC_PKCS15_CARD_OPTS_PRIV_CERT_DECLASSIFY	2
  ------------------
 1382|      0|	}
 1383|       |	/* overwrite pin_protected_certificate when private_certificate set */
 1384|  10.6k|	if (0 == strcmp(private_certificate, "protect")) {
  ------------------
  |  Branch (1384:6): [True: 0, False: 10.6k]
  ------------------
 1385|      0|		p15card->opts.pin_protected_certificate = SC_PKCS15_CARD_OPTS_PRIV_CERT_PROTECT;
  ------------------
  |  |  609|      0|#define SC_PKCS15_CARD_OPTS_PRIV_CERT_PROTECT		0
  ------------------
 1386|  10.6k|	} else if (0 == strcmp(private_certificate, "ignore")) {
  ------------------
  |  Branch (1386:13): [True: 0, False: 10.6k]
  ------------------
 1387|      0|		p15card->opts.pin_protected_certificate = SC_PKCS15_CARD_OPTS_PRIV_CERT_IGNORE;
  ------------------
  |  |  610|      0|#define SC_PKCS15_CARD_OPTS_PRIV_CERT_IGNORE		1
  ------------------
 1388|  10.6k|	} else if (0 == strcmp(private_certificate, "declassify")) {
  ------------------
  |  Branch (1388:13): [True: 0, False: 10.6k]
  ------------------
 1389|      0|		p15card->opts.pin_protected_certificate = SC_PKCS15_CARD_OPTS_PRIV_CERT_DECLASSIFY;
  ------------------
  |  |  611|      0|#define SC_PKCS15_CARD_OPTS_PRIV_CERT_DECLASSIFY	2
  ------------------
 1390|      0|	}
 1391|  10.6k|	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|  10.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__
  |  |  ------------------
  ------------------
 1392|  10.6k|			p15card->opts.use_file_cache, p15card->opts.use_pin_cache, p15card->opts.pin_cache_counter,
 1393|  10.6k|			p15card->opts.pin_cache_ignore_user_consent, p15card->opts.pin_protected_certificate);
 1394|       |
 1395|  10.6k|	r = sc_lock(card);
 1396|  10.6k|	if (r) {
  ------------------
  |  Branch (1396:6): [True: 0, False: 10.6k]
  ------------------
 1397|      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__
  |  |  ------------------
  ------------------
 1398|      0|		sc_pkcs15_card_free(p15card);
 1399|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1400|      0|	}
 1401|       |
 1402|  10.6k|	enable_emu = scconf_get_bool(conf_block, "enable_pkcs15_emulation", 1);
 1403|  10.6k|	if (enable_emu) {
  ------------------
  |  Branch (1403:6): [True: 10.6k, False: 0]
  ------------------
 1404|  10.6k|		sc_log(ctx, "PKCS#15 emulation enabled");
  ------------------
  |  |   71|  10.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__
  |  |  ------------------
  ------------------
 1405|  10.6k|		emu_first = scconf_get_bool(conf_block, "try_emulation_first", 0);
 1406|  10.6k|		if (emu_first || sc_pkcs15_is_emulation_only(card)) {
  ------------------
  |  Branch (1406:7): [True: 0, False: 10.6k]
  |  Branch (1406:20): [True: 1.43k, False: 9.17k]
  ------------------
 1407|  1.43k|			r = sc_pkcs15_bind_synthetic(p15card, aid);
 1408|  1.43k|			if (r == SC_SUCCESS)
  ------------------
  |  |   28|  1.43k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1408:8): [True: 629, False: 810]
  ------------------
 1409|    629|				goto done;
 1410|    810|			r = sc_pkcs15_bind_internal(p15card, aid);
 1411|    810|			if (r < 0)
  ------------------
  |  Branch (1411:8): [True: 783, False: 27]
  ------------------
 1412|    783|				goto error;
 1413|  9.17k|		} else {
 1414|  9.17k|			r = sc_pkcs15_bind_internal(p15card, aid);
 1415|  9.17k|			if (r == SC_SUCCESS)
  ------------------
  |  |   28|  9.17k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1415:8): [True: 1.36k, False: 7.81k]
  ------------------
 1416|  1.36k|				goto done;
 1417|  7.81k|			r = sc_pkcs15_bind_synthetic(p15card, aid);
 1418|  7.81k|			if (r < 0)
  ------------------
  |  Branch (1418:8): [True: 5.27k, False: 2.54k]
  ------------------
 1419|  5.27k|				goto error;
 1420|  7.81k|		}
 1421|  10.6k|	}
 1422|      0|	else {
 1423|      0|		r = sc_pkcs15_bind_internal(p15card, aid);
 1424|      0|		if (r < 0)
  ------------------
  |  Branch (1424:7): [True: 0, False: 0]
  ------------------
 1425|      0|			goto error;
 1426|      0|	}
 1427|  4.55k|done:
 1428|  4.55k|	*p15card_out = p15card;
 1429|  4.55k|	sc_unlock(card);
 1430|  4.55k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  4.55k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  4.55k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  4.55k|	int _ret = r; \
  |  |  |  |  155|  4.55k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4.55k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  4.55k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 4.55k]
  |  |  |  |  ------------------
  |  |  |  |  157|  4.55k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  4.55k|	} else { \
  |  |  |  |  159|      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.55k|	return _ret; \
  |  |  |  |  163|  4.55k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1431|  6.05k|error:
 1432|  6.05k|	sc_unlock(card);
 1433|  6.05k|	sc_pkcs15_card_free(p15card);
 1434|  6.05k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  6.05k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  6.05k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  6.05k|	int _ret = r; \
  |  |  |  |  155|  6.05k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 6.05k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  6.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|  6.05k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 6.05k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  6.05k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  6.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|  6.05k|	return _ret; \
  |  |  |  |  163|  6.05k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1435|  6.05k|}
sc_pkcs15_unbind:
 1440|  4.55k|{
 1441|  4.55k|	if (p15card == NULL || p15card->magic != SC_PKCS15_CARD_MAGIC) {
  ------------------
  |  |  519|  4.55k|#define SC_PKCS15_CARD_MAGIC		0x10203040
  ------------------
  |  Branch (1441:6): [True: 0, False: 4.55k]
  |  Branch (1441:25): [True: 0, False: 4.55k]
  ------------------
 1442|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1443|      0|	}
 1444|       |
 1445|  4.55k|	LOG_FUNC_CALLED(p15card->card->ctx);
  ------------------
  |  |  151|  4.55k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  4.55k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  4.55k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  4.55k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 4.55k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1446|  4.55k|	if (p15card->dll_handle)
  ------------------
  |  Branch (1446:6): [True: 0, False: 4.55k]
  ------------------
 1447|      0|		sc_dlclose(p15card->dll_handle);
 1448|  4.55k|	sc_pkcs15_pincache_clear(p15card);
 1449|  4.55k|	sc_pkcs15_card_free(p15card);
 1450|  4.55k|	return 0;
 1451|  4.55k|}
sc_pkcs15_get_objects:
 1539|  37.6k|{
 1540|  37.6k|	return sc_pkcs15_get_objects_cond(p15card, type, NULL, NULL, ret, ret_size);
 1541|  37.6k|}
sc_pkcs15_search_objects:
 1723|   632k|{
 1724|   632k|	return __sc_pkcs15_search_objects(p15card,
 1725|   632k|			sk->class_mask, sk->type,
 1726|   632k|			compare_obj_key, sk,
 1727|   632k|			ret, ret_size);
 1728|   632k|}
sc_pkcs15_get_objects_cond:
 1735|  41.2k|{
 1736|  41.2k|	return __sc_pkcs15_search_objects(p15card, 0, type,
 1737|  41.2k|			func, func_arg, ret, ret_size);
 1738|  41.2k|}
sc_pkcs15_find_object_by_id:
 1744|   663k|{
 1745|   663k|	struct sc_pkcs15_search_key sk;
 1746|   663k|	int	r;
 1747|       |
 1748|   663k|	memset(&sk, 0, sizeof(sk));
 1749|   663k|	sk.id = id;
 1750|       |
 1751|   663k|	r = __sc_pkcs15_search_objects(p15card, 0, type, compare_obj_key, &sk, out, 1);
 1752|   663k|	if (r < 0)
  ------------------
  |  Branch (1752:6): [True: 0, False: 663k]
  ------------------
 1753|      0|		return r;
 1754|   663k|	if (r == 0)
  ------------------
  |  Branch (1754:6): [True: 661k, False: 1.48k]
  ------------------
 1755|   661k|		return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|   661k|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
 1756|  1.48k|	return 0;
 1757|   663k|}
sc_pkcs15_find_prkey_by_id:
 1771|    955|{
 1772|    955|	return sc_pkcs15_find_object_by_id(p15card, SC_PKCS15_TYPE_PRKEY, id, out);
  ------------------
  |  |  418|    955|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
 1773|    955|}
sc_pkcs15_find_pubkey_by_id:
 1779|     10|{
 1780|     10|	return sc_pkcs15_find_object_by_id(p15card, SC_PKCS15_TYPE_PUBKEY, id, out);
  ------------------
  |  |  425|     10|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
 1781|     10|}
sc_pkcs15_find_skey_by_id:
 1787|  11.9k|{
 1788|  11.9k|	return sc_pkcs15_find_object_by_id(p15card, SC_PKCS15_TYPE_SKEY, id, out);
  ------------------
  |  |  432|  11.9k|#define SC_PKCS15_TYPE_SKEY			0x300
  ------------------
 1789|  11.9k|}
sc_pkcs15_find_pin_by_auth_id:
 1795|  5.09k|{
 1796|  5.09k|	return sc_pkcs15_find_object_by_id(p15card, SC_PKCS15_TYPE_AUTH, id, out);
  ------------------
  |  |  444|  5.09k|#define SC_PKCS15_TYPE_AUTH			0x600
  ------------------
 1797|  5.09k|}
sc_pkcs15_find_pin_by_reference:
 1803|  1.87k|{
 1804|  1.87k|	struct sc_pkcs15_search_key sk;
 1805|       |
 1806|  1.87k|	memset(&sk, 0, sizeof(sk));
 1807|  1.87k|	sk.match_reference = 1;
 1808|  1.87k|	sk.reference = reference;
 1809|  1.87k|	sk.path = path;
 1810|       |
 1811|  1.87k|	return find_by_key(p15card, SC_PKCS15_TYPE_AUTH_PIN, &sk, out);
  ------------------
  |  |  445|  1.87k|#define SC_PKCS15_TYPE_AUTH_PIN			0x601
  ------------------
 1812|  1.87k|}
sc_pkcs15_find_pin_by_type_and_reference:
 1819|  1.80k|{
 1820|  1.80k|	struct sc_context *ctx = p15card->card->ctx;
 1821|  1.80k|	struct sc_pkcs15_object *auth_objs[0x10];
 1822|  1.80k|	size_t nn_objs, ii;
 1823|  1.80k|	int r;
 1824|       |
 1825|       |	/* Get all existing pkcs15 AUTH objects */
 1826|  1.80k|	r = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_AUTH_PIN, auth_objs, 0x10);
  ------------------
  |  |  445|  1.80k|#define SC_PKCS15_TYPE_AUTH_PIN			0x601
  ------------------
 1827|  1.80k|	LOG_TEST_RET(ctx, r, "Get PKCS#15 AUTH objects error");
  ------------------
  |  |  174|  1.80k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.80k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.80k|	int _ret = (r); \
  |  |  |  |  168|  1.80k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 1.80k]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#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.80k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.80k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1828|  1.80k|	nn_objs = r;
 1829|       |
 1830|  3.34k|	for (ii=0; ii<nn_objs; ii++)   {
  ------------------
  |  Branch (1830:13): [True: 1.75k, False: 1.58k]
  ------------------
 1831|  1.75k|		struct sc_pkcs15_auth_info *auth_info = (struct sc_pkcs15_auth_info *)auth_objs[ii]->data;
 1832|       |
 1833|  1.75k|		if (auth_info->auth_method != auth_method)
  ------------------
  |  Branch (1833:7): [True: 419, False: 1.34k]
  ------------------
 1834|    419|			continue;
 1835|  1.34k|		if (auth_info->auth_type == SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|  1.34k|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (1835:7): [True: 1.34k, False: 0]
  ------------------
 1836|  1.34k|			if (auth_info->attrs.pin.reference != reference)
  ------------------
  |  Branch (1836:8): [True: 776, False: 564]
  ------------------
 1837|    776|				continue;
 1838|       |
 1839|    564|		if (path && !sc_compare_path(&auth_info->path, path))
  ------------------
  |  Branch (1839:7): [True: 398, False: 166]
  |  Branch (1839:15): [True: 350, False: 48]
  ------------------
 1840|    350|			continue;
 1841|       |
 1842|    214|		if (out)
  ------------------
  |  Branch (1842:7): [True: 214, False: 0]
  ------------------
 1843|    214|			*out = auth_objs[ii];
 1844|       |
 1845|    214|		return SC_SUCCESS;
  ------------------
  |  |   28|    214|#define SC_SUCCESS				0
  ------------------
 1846|    564|	}
 1847|       |
 1848|  1.58k|	return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|  1.58k|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
 1849|  1.80k|}
sc_pkcs15_find_prkey_by_reference:
 1973|  1.68k|{
 1974|  1.68k|	struct sc_pkcs15_search_key sk;
 1975|       |
 1976|  1.68k|	memset(&sk, 0, sizeof(sk));
 1977|  1.68k|	sk.match_reference = 1;
 1978|  1.68k|	sk.reference = reference;
 1979|  1.68k|	sk.path = path;
 1980|       |
 1981|  1.68k|	return find_by_key(p15card, SC_PKCS15_TYPE_PRKEY, &sk, out);
  ------------------
  |  |  418|  1.68k|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
 1982|  1.68k|}
sc_pkcs15_add_object:
 1987|  4.74k|{
 1988|  4.74k|	struct sc_pkcs15_object *p = p15card->obj_list;
 1989|       |
 1990|  4.74k|	if (!obj)
  ------------------
  |  Branch (1990:6): [True: 0, False: 4.74k]
  ------------------
 1991|      0|		return 0;
 1992|  4.74k|	obj->next = obj->prev = NULL;
 1993|  4.74k|	if (p15card->obj_list == NULL) {
  ------------------
  |  Branch (1993:6): [True: 2.68k, False: 2.06k]
  ------------------
 1994|  2.68k|		p15card->obj_list = obj;
 1995|  2.68k|		return 0;
 1996|  2.68k|	}
 1997|  4.60k|	while (p->next != NULL)
  ------------------
  |  Branch (1997:9): [True: 2.54k, False: 2.06k]
  ------------------
 1998|  2.54k|		p = p->next;
 1999|  2.06k|	p->next = obj;
 2000|  2.06k|	obj->prev = p;
 2001|       |
 2002|  2.06k|	return 0;
 2003|  4.74k|}
sc_pkcs15_remove_object:
 2008|  1.78k|{
 2009|  1.78k|	if (!obj)
  ------------------
  |  Branch (2009:6): [True: 0, False: 1.78k]
  ------------------
 2010|      0|		return;
 2011|  1.78k|	else if (obj->prev == NULL)
  ------------------
  |  Branch (2011:11): [True: 1.54k, False: 242]
  ------------------
 2012|  1.54k|		p15card->obj_list = obj->next;
 2013|    242|	else
 2014|    242|		obj->prev->next = obj->next;
 2015|  1.78k|	if (obj->next != NULL)
  ------------------
  |  Branch (2015:6): [True: 98, False: 1.68k]
  ------------------
 2016|     98|		obj->next->prev = obj->prev;
 2017|  1.78k|}
sc_pkcs15_free_object:
 2038|  24.9k|{
 2039|  24.9k|	if (!obj)
  ------------------
  |  Branch (2039:6): [True: 4.39k, False: 20.5k]
  ------------------
 2040|  4.39k|		return;
 2041|  20.5k|	switch (obj->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|  20.5k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
 2042|  4.26k|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|  4.26k|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (2042:2): [True: 4.26k, False: 16.3k]
  ------------------
 2043|  4.26k|		sc_pkcs15_free_prkey_info((sc_pkcs15_prkey_info_t *)obj->data);
 2044|  4.26k|		break;
 2045|     21|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|     21|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (2045:2): [True: 21, False: 20.5k]
  ------------------
 2046|       |		/* This is normally passed to framework-pkcs15,
 2047|       |		 * but if something fails on the way, it would not get freed */
 2048|     21|		if (obj->emulated) {
  ------------------
  |  Branch (2048:7): [True: 0, False: 21]
  ------------------
 2049|      0|			sc_pkcs15_free_pubkey(obj->emulated);
 2050|      0|		}
 2051|     21|		sc_pkcs15_free_pubkey_info((sc_pkcs15_pubkey_info_t *)obj->data);
 2052|     21|		break;
 2053|    508|	case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|    508|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (2053:2): [True: 508, False: 20.0k]
  ------------------
 2054|    508|		sc_pkcs15_free_cert_info((sc_pkcs15_cert_info_t *)obj->data);
 2055|    508|		break;
 2056|  5.18k|	case SC_PKCS15_TYPE_SKEY:
  ------------------
  |  |  432|  5.18k|#define SC_PKCS15_TYPE_SKEY			0x300
  ------------------
  |  Branch (2056:2): [True: 5.18k, False: 15.4k]
  ------------------
 2057|  5.18k|		sc_pkcs15_free_skey_info((sc_pkcs15_skey_info_t *)obj->data);
 2058|  5.18k|		break;
 2059|  4.08k|	case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|  4.08k|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (2059:2): [True: 4.08k, False: 16.5k]
  ------------------
 2060|  4.08k|		sc_pkcs15_free_data_info((sc_pkcs15_data_info_t *)obj->data);
 2061|  4.08k|		break;
 2062|  6.53k|	case SC_PKCS15_TYPE_AUTH:
  ------------------
  |  |  444|  6.53k|#define SC_PKCS15_TYPE_AUTH			0x600
  ------------------
  |  Branch (2062:2): [True: 6.53k, False: 14.0k]
  ------------------
 2063|  6.53k|		sc_pkcs15_free_auth_info((sc_pkcs15_auth_info_t *)obj->data);
 2064|  6.53k|		break;
 2065|      0|	default:
  ------------------
  |  Branch (2065:2): [True: 0, False: 20.5k]
  ------------------
 2066|      0|		free(obj->data);
 2067|  20.5k|	}
 2068|       |
 2069|  20.5k|	sc_pkcs15_free_object_content(obj);
 2070|       |
 2071|  20.5k|	free(obj);
 2072|  20.5k|}
sc_pkcs15_add_df:
 2077|  3.66k|{
 2078|  3.66k|	struct sc_pkcs15_df *p, *newdf;
 2079|       |
 2080|  3.66k|	newdf = calloc(1, sizeof(struct sc_pkcs15_df));
 2081|  3.66k|	if (newdf == NULL)
  ------------------
  |  Branch (2081:6): [True: 0, False: 3.66k]
  ------------------
 2082|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2083|  3.66k|	newdf->path = *path;
 2084|  3.66k|	newdf->type = type;
 2085|       |
 2086|  3.66k|	if (p15card->df_list == NULL) {
  ------------------
  |  Branch (2086:6): [True: 1.68k, False: 1.97k]
  ------------------
 2087|  1.68k|		p15card->df_list = newdf;
 2088|  1.68k|		return 0;
 2089|  1.68k|	}
 2090|       |
 2091|  1.97k|	p = p15card->df_list;
 2092|  4.33k|	while (p->next != NULL)
  ------------------
  |  Branch (2092:9): [True: 2.36k, False: 1.97k]
  ------------------
 2093|  2.36k|		p = p->next;
 2094|  1.97k|	p->next = newdf;
 2095|  1.97k|	newdf->prev = p;
 2096|       |
 2097|  1.97k|	return 0;
 2098|  3.66k|}
sc_pkcs15_encode_df:
 2121|  1.14k|{
 2122|  1.14k|	unsigned char *buf = NULL, *tmp = NULL, *p;
 2123|  1.14k|	size_t bufsize = 0, tmpsize;
 2124|  1.14k|	const struct sc_pkcs15_object *obj;
 2125|  1.14k|	int (* func)(struct sc_context *, const struct sc_pkcs15_object *nobj,
 2126|  1.14k|		     unsigned char **nbuf, size_t *nbufsize) = NULL;
 2127|  1.14k|	int r;
 2128|       |
 2129|  1.14k|	if (p15card == NULL || p15card->magic != SC_PKCS15_CARD_MAGIC) {
  ------------------
  |  |  519|  1.14k|#define SC_PKCS15_CARD_MAGIC		0x10203040
  ------------------
  |  Branch (2129:6): [True: 0, False: 1.14k]
  |  Branch (2129:25): [True: 0, False: 1.14k]
  ------------------
 2130|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 2131|      0|	}
 2132|  1.14k|	switch (df->type) {
  ------------------
  |  Branch (2132:10): [True: 1.14k, False: 0]
  ------------------
 2133|    258|	case SC_PKCS15_PRKDF:
  ------------------
  |  |  488|    258|#define SC_PKCS15_PRKDF			0
  ------------------
  |  Branch (2133:2): [True: 258, False: 883]
  ------------------
 2134|    258|		func = sc_pkcs15_encode_prkdf_entry;
 2135|    258|		break;
 2136|    157|	case SC_PKCS15_PUKDF:
  ------------------
  |  |  489|    157|#define SC_PKCS15_PUKDF			1
  ------------------
  |  Branch (2136:2): [True: 157, False: 984]
  ------------------
 2137|    157|	case SC_PKCS15_PUKDF_TRUSTED:
  ------------------
  |  |  490|    157|#define SC_PKCS15_PUKDF_TRUSTED		2
  ------------------
  |  Branch (2137:2): [True: 0, False: 1.14k]
  ------------------
 2138|    157|		func = sc_pkcs15_encode_pukdf_entry;
 2139|    157|		break;
 2140|    224|	case SC_PKCS15_SKDF:
  ------------------
  |  |  491|    224|#define SC_PKCS15_SKDF			3
  ------------------
  |  Branch (2140:2): [True: 224, False: 917]
  ------------------
 2141|    224|		func = sc_pkcs15_encode_skdf_entry;
 2142|    224|		break;
 2143|    110|	case SC_PKCS15_CDF:
  ------------------
  |  |  492|    110|#define SC_PKCS15_CDF			4
  ------------------
  |  Branch (2143:2): [True: 110, False: 1.03k]
  ------------------
 2144|    213|	case SC_PKCS15_CDF_TRUSTED:
  ------------------
  |  |  493|    213|#define SC_PKCS15_CDF_TRUSTED		5
  ------------------
  |  Branch (2144:2): [True: 103, False: 1.03k]
  ------------------
 2145|    213|	case SC_PKCS15_CDF_USEFUL:
  ------------------
  |  |  494|    213|#define SC_PKCS15_CDF_USEFUL		6
  ------------------
  |  Branch (2145:2): [True: 0, False: 1.14k]
  ------------------
 2146|    213|		func = sc_pkcs15_encode_cdf_entry;
 2147|    213|		break;
 2148|    102|	case SC_PKCS15_DODF:
  ------------------
  |  |  495|    102|#define SC_PKCS15_DODF			7
  ------------------
  |  Branch (2148:2): [True: 102, False: 1.03k]
  ------------------
 2149|    102|		func = sc_pkcs15_encode_dodf_entry;
 2150|    102|		break;
 2151|    187|	case SC_PKCS15_AODF:
  ------------------
  |  |  496|    187|#define SC_PKCS15_AODF			8
  ------------------
  |  Branch (2151:2): [True: 187, False: 954]
  ------------------
 2152|    187|		func = sc_pkcs15_encode_aodf_entry;
 2153|    187|		break;
 2154|  1.14k|	}
 2155|  1.14k|	if (func == NULL) {
  ------------------
  |  Branch (2155:6): [True: 0, False: 1.14k]
  ------------------
 2156|      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__
  |  |  ------------------
  ------------------
 2157|      0|		*buf_out = NULL;
 2158|      0|		*bufsize_out = 0;
 2159|      0|		return 0;
 2160|      0|	}
 2161|  2.91k|	for (obj = p15card->obj_list; obj != NULL; obj = obj->next) {
  ------------------
  |  Branch (2161:32): [True: 1.79k, False: 1.12k]
  ------------------
 2162|  1.79k|		if (obj->df != df)
  ------------------
  |  Branch (2162:7): [True: 1.43k, False: 363]
  ------------------
 2163|  1.43k|			continue;
 2164|    363|		r = func(ctx, obj, &tmp, &tmpsize);
 2165|    363|		if (r) {
  ------------------
  |  Branch (2165:7): [True: 21, False: 342]
  ------------------
 2166|     21|			free(tmp);
 2167|     21|			free(buf);
 2168|     21|			return r;
 2169|     21|		}
 2170|    342|		if (!tmpsize)
  ------------------
  |  Branch (2170:7): [True: 0, False: 342]
  ------------------
 2171|      0|			continue;
 2172|    342|		p = (u8 *) realloc(buf, bufsize + tmpsize);
 2173|    342|		if (!p) {
  ------------------
  |  Branch (2173:7): [True: 0, False: 342]
  ------------------
 2174|      0|			free(tmp);
 2175|      0|			free(buf);
 2176|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2177|      0|		}
 2178|    342|		buf = p;
 2179|    342|		memcpy(buf + bufsize, tmp, tmpsize);
 2180|    342|		free(tmp);
 2181|    342|		tmp = NULL;
 2182|    342|		bufsize += tmpsize;
 2183|    342|	}
 2184|  1.12k|	*buf_out = buf;
 2185|  1.12k|	*bufsize_out = bufsize;
 2186|       |
 2187|  1.12k|	return 0;
 2188|  1.14k|}
sc_pkcs15_parse_df:
 2193|  37.2k|{
 2194|  37.2k|	struct sc_context *ctx = p15card->card->ctx;
 2195|  37.2k|	unsigned char *buf;
 2196|  37.2k|	const unsigned char *p;
 2197|  37.2k|	size_t bufsize;
 2198|  37.2k|	int r;
 2199|  37.2k|	struct sc_pkcs15_object *obj = NULL;
 2200|  37.2k|	int (* func)(struct sc_pkcs15_card *, struct sc_pkcs15_object *,
 2201|  37.2k|		     const u8 **nbuf, size_t *nbufsize) = NULL;
 2202|       |
 2203|  37.2k|	sc_log(ctx, "called; path=%s, type=%d, enum=%d", sc_print_path(&df->path), df->type, df->enumerated);
  ------------------
  |  |   71|  37.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__
  |  |  ------------------
  ------------------
 2204|       |
 2205|  37.2k|	if (df->enumerated)
  ------------------
  |  Branch (2205:6): [True: 0, False: 37.2k]
  ------------------
 2206|  37.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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2207|       |
 2208|  37.2k|	switch (df->type) {
  ------------------
  |  Branch (2208:10): [True: 35.4k, False: 1.86k]
  ------------------
 2209|  15.5k|	case SC_PKCS15_PRKDF:
  ------------------
  |  |  488|  15.5k|#define SC_PKCS15_PRKDF			0
  ------------------
  |  Branch (2209:2): [True: 15.5k, False: 21.7k]
  ------------------
 2210|  15.5k|		func = sc_pkcs15_decode_prkdf_entry;
 2211|  15.5k|		break;
 2212|  2.32k|	case SC_PKCS15_PUKDF:
  ------------------
  |  |  489|  2.32k|#define SC_PKCS15_PUKDF			1
  ------------------
  |  Branch (2212:2): [True: 2.32k, False: 34.9k]
  ------------------
 2213|  2.32k|		func = sc_pkcs15_decode_pukdf_entry;
 2214|  2.32k|		break;
 2215|    751|	case SC_PKCS15_SKDF:
  ------------------
  |  |  491|    751|#define SC_PKCS15_SKDF			3
  ------------------
  |  Branch (2215:2): [True: 751, False: 36.5k]
  ------------------
 2216|    751|		func = sc_pkcs15_decode_skdf_entry;
 2217|    751|		break;
 2218|  4.00k|	case SC_PKCS15_CDF:
  ------------------
  |  |  492|  4.00k|#define SC_PKCS15_CDF			4
  ------------------
  |  Branch (2218:2): [True: 4.00k, False: 33.2k]
  ------------------
 2219|  14.4k|	case SC_PKCS15_CDF_TRUSTED:
  ------------------
  |  |  493|  14.4k|#define SC_PKCS15_CDF_TRUSTED		5
  ------------------
  |  Branch (2219:2): [True: 10.4k, False: 26.8k]
  ------------------
 2220|  16.3k|	case SC_PKCS15_CDF_USEFUL:
  ------------------
  |  |  494|  16.3k|#define SC_PKCS15_CDF_USEFUL		6
  ------------------
  |  Branch (2220:2): [True: 1.89k, False: 35.3k]
  ------------------
 2221|  16.3k|		func = sc_pkcs15_decode_cdf_entry;
 2222|  16.3k|		break;
 2223|     29|	case SC_PKCS15_DODF:
  ------------------
  |  |  495|     29|#define SC_PKCS15_DODF			7
  ------------------
  |  Branch (2223:2): [True: 29, False: 37.2k]
  ------------------
 2224|     29|		func = sc_pkcs15_decode_dodf_entry;
 2225|     29|		break;
 2226|    481|	case SC_PKCS15_AODF:
  ------------------
  |  |  496|    481|#define SC_PKCS15_AODF			8
  ------------------
  |  Branch (2226:2): [True: 481, False: 36.7k]
  ------------------
 2227|    481|		func = sc_pkcs15_decode_aodf_entry;
 2228|    481|		break;
 2229|  37.2k|	}
 2230|  37.2k|	if (func == NULL) {
  ------------------
  |  Branch (2230:6): [True: 1.86k, False: 35.4k]
  ------------------
 2231|  1.86k|		sc_log(ctx, "unknown DF type: %d", df->type);
  ------------------
  |  |   71|  1.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__
  |  |  ------------------
  ------------------
 2232|  1.86k|		LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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|  1.86k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.86k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2233|  1.86k|	}
 2234|  35.4k|	r = sc_pkcs15_read_file(p15card, &df->path, &buf, &bufsize, 0);
 2235|  35.4k|	LOG_TEST_RET(ctx, r, "pkcs15 read file failed");
  ------------------
  |  |  174|  35.4k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  35.4k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  35.4k|	int _ret = (r); \
  |  |  |  |  168|  35.4k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 35.2k, False: 124]
  |  |  |  |  ------------------
  |  |  |  |  169|  35.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|  35.2k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  35.2k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  35.2k|		return _ret; \
  |  |  |  |  172|  35.2k|	} \
  |  |  |  |  173|  35.4k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 124]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2236|       |
 2237|    124|	p = buf;
 2238|    134|	while (bufsize && *p != 0x00) {
  ------------------
  |  Branch (2238:9): [True: 92, False: 42]
  |  Branch (2238:20): [True: 86, False: 6]
  ------------------
 2239|       |
 2240|     86|		obj = calloc(1, sizeof(struct sc_pkcs15_object));
 2241|     86|		if (obj == NULL) {
  ------------------
  |  Branch (2241:7): [True: 0, False: 86]
  ------------------
 2242|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2243|      0|			goto ret;
 2244|      0|		}
 2245|     86|		r = func(p15card, obj, &p, &bufsize);
 2246|     86|		if (r) {
  ------------------
  |  Branch (2246:7): [True: 76, False: 10]
  ------------------
 2247|     76|			free(obj);
 2248|     76|			if (r == SC_ERROR_ASN1_END_OF_CONTENTS) {
  ------------------
  |  |   84|     76|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (2248:8): [True: 14, False: 62]
  ------------------
 2249|     14|				r = 0;
 2250|     14|				break;
 2251|     14|			}
 2252|     62|			sc_log(ctx, "%s: Error decoding DF entry", sc_strerror(r));
  ------------------
  |  |   71|     62|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2253|     62|			goto ret;
 2254|     76|		}
 2255|       |
 2256|     10|		obj->df = df;
 2257|     10|		r = sc_pkcs15_add_object(p15card, obj);
 2258|     10|		if (r) {
  ------------------
  |  Branch (2258:7): [True: 0, False: 10]
  ------------------
 2259|      0|			if (obj->data)
  ------------------
  |  Branch (2259:8): [True: 0, False: 0]
  ------------------
 2260|      0|				free(obj->data);
 2261|      0|			free(obj);
 2262|      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__
  |  |  ------------------
  ------------------
 2263|      0|			goto ret;
 2264|      0|		}
 2265|    177|		while (bufsize > 0 && *p == 00) {
  ------------------
  |  Branch (2265:10): [True: 176, False: 1]
  |  Branch (2265:25): [True: 167, False: 9]
  ------------------
 2266|    167|			bufsize--;
 2267|    167|			p++;
 2268|    167|		}
 2269|     62|	};
 2270|       |
 2271|     62|	if (r > 0)
  ------------------
  |  Branch (2271:6): [True: 0, False: 62]
  ------------------
 2272|      0|		r = 0;
 2273|    124|ret:
 2274|    124|	df->enumerated = 1;
 2275|    124|	free(buf);
 2276|    124|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    124|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    124|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    124|	int _ret = r; \
  |  |  |  |  155|    124|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 124, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    124|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     62|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 62, False: 62]
  |  |  |  |  ------------------
  |  |  |  |  157|    124|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    124|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    124|	return _ret; \
  |  |  |  |  163|    124|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2277|    124|}
sc_pkcs15_read_file:
 2529|  35.6k|{
 2530|  35.6k|	struct sc_context *ctx;
 2531|  35.6k|	struct sc_file *file = NULL;
 2532|  35.6k|	unsigned char *data = NULL;
 2533|  35.6k|	size_t	len = 0, offset = 0;
 2534|  35.6k|	int	r;
 2535|       |
 2536|  35.6k|	if (p15card == NULL || p15card->card == NULL || in_path == NULL || buf == NULL) {
  ------------------
  |  Branch (2536:6): [True: 0, False: 35.6k]
  |  Branch (2536:25): [True: 0, False: 35.6k]
  |  Branch (2536:50): [True: 0, False: 35.6k]
  |  Branch (2536:69): [True: 0, False: 35.6k]
  ------------------
 2537|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 2538|      0|	}
 2539|  35.6k|	ctx = p15card->card->ctx;
 2540|       |
 2541|  35.6k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  35.6k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  35.6k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  35.6k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  35.6k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 35.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2542|  35.6k|	sc_log(ctx, "path=%s, index=%u, count=%d", sc_print_path(in_path), in_path->index, in_path->count);
  ------------------
  |  |   71|  35.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__
  |  |  ------------------
  ------------------
 2543|       |
 2544|  35.6k|	r = -1; /* file state: not in cache */
 2545|  35.6k|	if (p15card->opts.use_file_cache
  ------------------
  |  Branch (2545:6): [True: 3.86k, False: 31.7k]
  ------------------
 2546|  3.86k|	    && ((p15card->opts.use_file_cache & SC_PKCS15_OPTS_CACHE_ALL_FILES) || !private_data)) {
  ------------------
  |  |  606|  3.86k|#define SC_PKCS15_OPTS_CACHE_ALL_FILES			2
  ------------------
  |  Branch (2546:10): [True: 0, False: 3.86k]
  |  Branch (2546:77): [True: 3.86k, False: 0]
  ------------------
 2547|  3.86k|		r = sc_pkcs15_read_cached_file(p15card, in_path, &data, &len);
 2548|       |
 2549|  3.86k|		if (!r && in_path->aid.len > 0 && in_path->len >= 2)   {
  ------------------
  |  Branch (2549:7): [True: 0, False: 3.86k]
  |  Branch (2549:13): [True: 0, False: 0]
  |  Branch (2549:37): [True: 0, False: 0]
  ------------------
 2550|      0|			struct sc_path parent = *in_path;
 2551|       |
 2552|      0|			parent.len -= 2;
 2553|      0|			parent.type = SC_PATH_TYPE_PATH;
  ------------------
  |  |  119|      0|#define SC_PATH_TYPE_PATH		2
  ------------------
 2554|      0|			r = sc_select_file(p15card->card, &parent, NULL);
 2555|      0|		}
 2556|  3.86k|	}
 2557|       |
 2558|  35.6k|	if (r) {
  ------------------
  |  Branch (2558:6): [True: 35.6k, False: 0]
  ------------------
 2559|  35.6k|		r = sc_lock(p15card->card);
 2560|  35.6k|		if (r)
  ------------------
  |  Branch (2560:7): [True: 0, False: 35.6k]
  ------------------
 2561|      0|			goto fail;
 2562|  35.6k|		r = sc_select_file(p15card->card, in_path, &file);
 2563|  35.6k|		if (r)
  ------------------
  |  Branch (2563:7): [True: 31.8k, False: 3.77k]
  ------------------
 2564|  31.8k|			goto fail_unlock;
 2565|       |
 2566|       |		/* Handle the case where the ASN.1 Path object specified
 2567|       |		 * index and length values */
 2568|       |
 2569|  3.77k|		if (file->ef_structure == SC_FILE_EF_LINEAR_VARIABLE) {
  ------------------
  |  |  224|  3.77k|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  |  Branch (2569:7): [True: 581, False: 3.19k]
  ------------------
 2570|       |
 2571|       |			// in_path->index: record_no
 2572|       |			// in_path->count: ignored!
 2573|       |
 2574|    581|			if(file->record_length > 0) {
  ------------------
  |  Branch (2574:7): [True: 23, False: 558]
  ------------------
 2575|     23|				if(file->record_length > MAX_FILE_SIZE) {
  ------------------
  |  |  220|     23|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (2575:8): [True: 0, False: 23]
  ------------------
 2576|      0|					len = MAX_FILE_SIZE;
  ------------------
  |  |  220|      0|#define MAX_FILE_SIZE 65535
  ------------------
 2577|      0|					sc_log(ctx, "  record size truncated, encoded length: %zu", file->record_length);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2578|     23|				} else {
 2579|     23|					len = file->record_length;
 2580|     23|				}
 2581|    558|			} else {
 2582|    558|				len = MAX_FILE_SIZE;
  ------------------
  |  |  220|    558|#define MAX_FILE_SIZE 65535
  ------------------
 2583|    558|			}
 2584|       |
 2585|    581|			if ((in_path->index <= 0) || (in_path->index > (int)(file->record_count))) {
  ------------------
  |  Branch (2585:8): [True: 581, False: 0]
  |  Branch (2585:33): [True: 0, False: 0]
  ------------------
 2586|    581|				sc_log(ctx, "  record number out of bounds: %d", in_path->index);
  ------------------
  |  |   71|    581|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2587|    581|				r = SC_ERROR_RECORD_NOT_FOUND;
  ------------------
  |  |   52|    581|#define SC_ERROR_RECORD_NOT_FOUND		-1202
  ------------------
 2588|    581|				goto fail_unlock;
 2589|    581|			}
 2590|       |
 2591|  3.19k|		} else {
 2592|       |
 2593|  3.19k|			if (in_path->count < 0) {
  ------------------
  |  Branch (2593:8): [True: 3.19k, False: 0]
  ------------------
 2594|  3.19k|				if (file->size)
  ------------------
  |  Branch (2594:9): [True: 1.57k, False: 1.61k]
  ------------------
 2595|  1.57k|					len = (file->size > MAX_FILE_SIZE)? MAX_FILE_SIZE:file->size;
  ------------------
  |  |  220|  1.57k|#define MAX_FILE_SIZE 65535
  ------------------
              					len = (file->size > MAX_FILE_SIZE)? MAX_FILE_SIZE:file->size;
  ------------------
  |  |  220|      0|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (2595:12): [True: 0, False: 1.57k]
  ------------------
 2596|  1.61k|				else
 2597|  1.61k|					len = 1024;
 2598|  3.19k|				offset = 0;
 2599|  3.19k|			}
 2600|      0|			else {
 2601|      0|				offset = in_path->index;
 2602|      0|				len = in_path->count;
 2603|       |				/* Make sure we're within proper bounds */
 2604|      0|				if (offset >= file->size || offset + len > file->size) {
  ------------------
  |  Branch (2604:9): [True: 0, False: 0]
  |  Branch (2604:33): [True: 0, False: 0]
  ------------------
 2605|      0|					r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 2606|      0|					goto fail_unlock;
 2607|      0|				}
 2608|      0|			}
 2609|  3.19k|		}
 2610|       |
 2611|  3.19k|		free(data);
 2612|  3.19k|		data = malloc(len);
 2613|  3.19k|		if (data == NULL) {
  ------------------
  |  Branch (2613:7): [True: 0, False: 3.19k]
  ------------------
 2614|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2615|      0|			goto fail_unlock;
 2616|      0|		}
 2617|       |
 2618|  3.19k|		if (file->ef_structure == SC_FILE_EF_LINEAR_VARIABLE_TLV) {
  ------------------
  |  |  225|  3.19k|#define SC_FILE_EF_LINEAR_VARIABLE_TLV	0x05
  ------------------
  |  Branch (2618:7): [True: 58, False: 3.13k]
  ------------------
 2619|     58|			unsigned int i;
 2620|     58|			size_t l, record_len;
 2621|     58|			unsigned char *head = data;
 2622|       |
 2623|    586|			for (i=1; ; i++) {
 2624|    586|				l = len - (head - data);
 2625|    586|				if (l > 256) {
  ------------------
  |  Branch (2625:9): [True: 290, False: 296]
  ------------------
 2626|    290|					l = 256;
 2627|    290|				}
 2628|    586|				r = sc_read_record(p15card->card, i, 0, head, l, SC_RECORD_BY_REC_NR);
  ------------------
  |  | 1298|    586|#define SC_RECORD_BY_REC_NR		0x00100UL
  ------------------
 2629|    586|				if (r == SC_ERROR_RECORD_NOT_FOUND)
  ------------------
  |  |   52|    586|#define SC_ERROR_RECORD_NOT_FOUND		-1202
  ------------------
  |  Branch (2629:9): [True: 1, False: 585]
  ------------------
 2630|      1|					break;
 2631|    585|				if (r < 0) {
  ------------------
  |  Branch (2631:9): [True: 49, False: 536]
  ------------------
 2632|     49|					goto fail_unlock;
 2633|     49|				}
 2634|    536|				if (r < 2)
  ------------------
  |  Branch (2634:9): [True: 7, False: 529]
  ------------------
 2635|      7|					break;
 2636|    529|				record_len = head[1];
 2637|    529|				if (record_len != 0xff) {
  ------------------
  |  Branch (2637:9): [True: 515, False: 14]
  ------------------
 2638|    515|					memmove(head, head+2, r-2);
 2639|    515|					head += (r-2);
 2640|    515|				}
 2641|     14|				else {
 2642|     14|					if (r < 4)
  ------------------
  |  Branch (2642:10): [True: 1, False: 13]
  ------------------
 2643|      1|						break;
 2644|     13|					memmove(head, head+4, r-4);
 2645|     13|					head += (r-4);
 2646|     13|				}
 2647|    529|			}
 2648|      9|			len = head-data;
 2649|      9|		}
 2650|  3.13k|		else if (file->ef_structure == SC_FILE_EF_LINEAR_VARIABLE) {
  ------------------
  |  |  224|  3.13k|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  |  Branch (2650:12): [True: 0, False: 3.13k]
  ------------------
 2651|      0|			r = sc_read_record(p15card->card, in_path->index, (unsigned)offset, data, len, SC_RECORD_BY_REC_NR);
  ------------------
  |  | 1298|      0|#define SC_RECORD_BY_REC_NR		0x00100UL
  ------------------
 2652|      0|			if (r < 0) {
  ------------------
  |  Branch (2652:8): [True: 0, False: 0]
  ------------------
 2653|      0|				goto fail_unlock;
 2654|      0|			}
 2655|       |			/* sc_read_record may return less than requested */
 2656|      0|			len = r;
 2657|      0|		}
 2658|  3.13k|		else {
 2659|  3.13k|			unsigned long flags = 0;
 2660|  3.13k|			r = sc_read_binary(p15card->card, (unsigned)offset, data, len, &flags);
 2661|  3.13k|			if (r < 0) {
  ------------------
  |  Branch (2661:8): [True: 2.99k, False: 136]
  ------------------
 2662|  2.99k|				goto fail_unlock;
 2663|  2.99k|			}
 2664|       |			/* sc_read_binary may return less than requested */
 2665|    136|			len = r;
 2666|       |
 2667|    136|			if (flags & SC_FILE_FLAG_COMPRESSED_AUTO
  ------------------
  |  |  230|    272|#define SC_FILE_FLAG_COMPRESSED_AUTO		0x01
  ------------------
  |  Branch (2667:8): [True: 0, False: 136]
  ------------------
 2668|    136|			    || flags & SC_FILE_FLAG_COMPRESSED_ZLIB
  ------------------
  |  |  231|    272|#define SC_FILE_FLAG_COMPRESSED_ZLIB		0x02
  ------------------
  |  Branch (2668:11): [True: 0, False: 136]
  ------------------
 2669|    136|			    || flags & SC_FILE_FLAG_COMPRESSED_GZIP) {
  ------------------
  |  |  232|    136|#define SC_FILE_FLAG_COMPRESSED_GZIP		0x04
  ------------------
  |  Branch (2669:11): [True: 0, False: 136]
  ------------------
 2670|      0|				unsigned char *decompressed_buf = NULL;
 2671|      0|				size_t decompressed_len = 0;
 2672|      0|				r = decompress_file(p15card->card, data, len, &decompressed_buf, &decompressed_len, flags);
 2673|      0|				if (r != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (2673:9): [True: 0, False: 0]
  ------------------
 2674|      0|					goto fail_unlock;
 2675|      0|				}
 2676|      0|				free(data);
 2677|      0|				data = decompressed_buf;
 2678|      0|				len = decompressed_len;
 2679|      0|			}
 2680|    136|		}
 2681|    145|		sc_unlock(p15card->card);
 2682|       |
 2683|    145|		sc_file_free(file);
 2684|       |
 2685|    145|		if (p15card->opts.use_file_cache && ((p15card->opts.use_file_cache & SC_PKCS15_OPTS_CACHE_ALL_FILES) || !private_data)) {
  ------------------
  |  |  606|     40|#define SC_PKCS15_OPTS_CACHE_ALL_FILES			2
  ------------------
  |  Branch (2685:7): [True: 40, False: 105]
  |  Branch (2685:40): [True: 0, False: 40]
  |  Branch (2685:107): [True: 40, False: 0]
  ------------------
 2686|     40|			sc_pkcs15_cache_file(p15card, in_path, data, len);
 2687|     40|		}
 2688|    145|		if (len == 0) {
  ------------------
  |  Branch (2688:7): [True: 46, False: 99]
  ------------------
 2689|     46|			free(data);
 2690|     46|			data = NULL;
 2691|     46|		}
 2692|    145|	}
 2693|    145|	*buf = data;
 2694|    145|	*buflen = len;
 2695|    145|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 145]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2696|       |
 2697|  35.4k|fail_unlock:
 2698|  35.4k|	sc_unlock(p15card->card);
 2699|  35.4k|fail:
 2700|  35.4k|	free(data);
 2701|  35.4k|	sc_file_free(file);
 2702|  35.4k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  35.4k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  35.4k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  35.4k|	int _ret = r; \
  |  |  |  |  155|  35.4k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 35.4k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  35.4k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  35.4k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 35.4k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  35.4k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  35.4k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|  35.4k|	return _ret; \
  |  |  |  |  163|  35.4k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2703|  35.4k|}
sc_pkcs15_compare_id:
 2708|   145k|{
 2709|   145k|	if (id1 == NULL || id2 == NULL)
  ------------------
  |  Branch (2709:6): [True: 0, False: 145k]
  |  Branch (2709:21): [True: 0, False: 145k]
  ------------------
 2710|      0|		return 0;
 2711|   145k|	if (id1->len != id2->len)
  ------------------
  |  Branch (2711:6): [True: 216, False: 145k]
  ------------------
 2712|    216|		return 0;
 2713|   145k|	return memcmp(id1->value, id2->value, id1->len) == 0;
 2714|   145k|}
sc_pkcs15_format_id:
 2719|  14.4k|{
 2720|  14.4k|	size_t len;
 2721|       |
 2722|  14.4k|	if (!id)
  ------------------
  |  Branch (2722:6): [True: 0, False: 14.4k]
  ------------------
 2723|      0|		return;
 2724|  14.4k|	len = sizeof(id->value);
 2725|       |
 2726|  14.4k|	if (sc_hex_to_bin(str, id->value, &len) != SC_SUCCESS)
  ------------------
  |  |   28|  14.4k|#define SC_SUCCESS				0
  ------------------
  |  Branch (2726:6): [True: 567, False: 13.9k]
  ------------------
 2727|    567|		id->len = 0;
 2728|  13.9k|	else
 2729|  13.9k|		id->len = len;
 2730|  14.4k|}
sc_pkcs15_print_id:
 2735|  7.34k|{
 2736|  7.34k|	static char buffer[256];
 2737|       |
 2738|  7.34k|	sc_bin_to_hex(id->value, id->len, buffer, sizeof(buffer), '\0');
 2739|  7.34k|	return buffer;
 2740|  7.34k|}
sc_pkcs15_make_absolute_path:
 2753|  13.0k|{
 2754|       |	/* nothing to do if child has valid 'aid' */
 2755|  13.0k|	if (child->aid.len)
  ------------------
  |  Branch (2755:6): [True: 0, False: 13.0k]
  ------------------
 2756|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 2757|       |
 2758|  13.0k|	if (parent->aid.len)   {
  ------------------
  |  Branch (2758:6): [True: 0, False: 13.0k]
  ------------------
 2759|      0|		sc_path_t ppath;
 2760|       |
 2761|       |		/* child inherits parent's 'aid' */
 2762|      0|		child->aid = parent->aid;
 2763|      0|		if (!parent->len)
  ------------------
  |  Branch (2763:7): [True: 0, False: 0]
  ------------------
 2764|      0|			return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 2765|       |
 2766|       |		/* parent has valid 'path' -- concatenate it with the child's one */
 2767|      0|		memcpy(&ppath, parent, sizeof(sc_path_t));
 2768|      0|		ppath.aid.len = 0;
 2769|      0|		ppath.type = SC_PATH_TYPE_FROM_CURRENT;
  ------------------
  |  |  122|      0|#define SC_PATH_TYPE_FROM_CURRENT	4
  ------------------
 2770|      0|		return sc_concatenate_path(child, &ppath, child);
 2771|       |
 2772|      0|	}
 2773|  13.0k|	else if (parent->type == SC_PATH_TYPE_DF_NAME)   {
  ------------------
  |  |  118|  13.0k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (2773:11): [True: 24, False: 13.0k]
  ------------------
 2774|       |		/* child inherits parent's 'DF NAME' as 'aid' */
 2775|     24|		if (parent->len > sizeof(child->aid.value))
  ------------------
  |  Branch (2775:7): [True: 0, False: 24]
  ------------------
 2776|      0|			return SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|      0|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
 2777|       |
 2778|     24|		memcpy(child->aid.value, parent->value, parent->len);
 2779|     24|		child->aid.len = parent->len;
 2780|       |
 2781|     24|		return SC_SUCCESS;
  ------------------
  |  |   28|     24|#define SC_SUCCESS				0
  ------------------
 2782|     24|	}
 2783|       |
 2784|       |	/* a 0 length path stays a 0 length path */
 2785|  13.0k|	if (child->len == 0)
  ------------------
  |  Branch (2785:6): [True: 98, False: 12.9k]
  ------------------
 2786|     98|		return SC_SUCCESS;
  ------------------
  |  |   28|     98|#define SC_SUCCESS				0
  ------------------
 2787|       |
 2788|  12.9k|	if (sc_compare_path_prefix(sc_get_mf_path(), child))
  ------------------
  |  Branch (2788:6): [True: 62, False: 12.9k]
  ------------------
 2789|     62|		return SC_SUCCESS;
  ------------------
  |  |   28|     62|#define SC_SUCCESS				0
  ------------------
 2790|       |
 2791|  12.9k|	return sc_concatenate_path(child, parent, child);
 2792|  12.9k|}
sc_pkcs15_free_object_content:
 2796|  22.2k|{
 2797|  22.2k|	if (obj->content.value && obj->content.len) {
  ------------------
  |  Branch (2797:6): [True: 144, False: 22.0k]
  |  Branch (2797:28): [True: 144, False: 0]
  ------------------
 2798|    144|		if (obj->content_free) {
  ------------------
  |  Branch (2798:7): [True: 94, False: 50]
  ------------------
 2799|     94|			obj->content_free(obj->content.value, obj->content.len);
 2800|     94|		} else {
 2801|     50|			free(obj->content.value);
 2802|     50|		}
 2803|    144|	}
 2804|       |	obj->content.value = NULL;
 2805|  22.2k|	obj->content.len = 0;
 2806|  22.2k|}
sc_pkcs15_allocate_object_content:
 2812|     94|{
 2813|     94|	unsigned char *tmp_buf;
 2814|       |
 2815|     94|	if (!obj)
  ------------------
  |  Branch (2815:6): [True: 0, False: 94]
  ------------------
 2816|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 2817|       |
 2818|     94|	if (!value || !len)   {
  ------------------
  |  Branch (2818:6): [True: 0, False: 94]
  |  Branch (2818:16): [True: 0, False: 94]
  ------------------
 2819|      0|		sc_pkcs15_free_object_content(obj);
 2820|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 2821|      0|	}
 2822|       |
 2823|       |	/* Need to pass by temporary variable,
 2824|       |	 * because 'value' and 'content.value' pointers can be the sames.
 2825|       |	 */
 2826|     94|	if (SC_PKCS15_TYPE_AUTH & obj->type
  ------------------
  |  |  444|     94|#define SC_PKCS15_TYPE_AUTH			0x600
  ------------------
  |  Branch (2826:6): [True: 94, False: 0]
  ------------------
 2827|      0|			|| SC_PKCS15_TYPE_SKEY & obj->type
  ------------------
  |  |  432|      0|#define SC_PKCS15_TYPE_SKEY			0x300
  ------------------
  |  Branch (2827:7): [True: 0, False: 0]
  ------------------
 2828|     94|			|| SC_PKCS15_TYPE_PRKEY & obj->type) {
  ------------------
  |  |  418|      0|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (2828:7): [True: 0, False: 0]
  ------------------
 2829|     94|		tmp_buf = sc_mem_secure_alloc(len);
 2830|     94|		obj->content_free = sc_mem_secure_free;
 2831|     94|	} else {
 2832|      0|		tmp_buf = malloc(len);
 2833|      0|	}
 2834|     94|	if (!tmp_buf)
  ------------------
  |  Branch (2834:6): [True: 0, False: 94]
  ------------------
 2835|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2836|       |
 2837|     94|	memcpy(tmp_buf, value, len);
 2838|       |
 2839|     94|	sc_pkcs15_free_object_content(obj);
 2840|       |
 2841|     94|	obj->content.value = tmp_buf;
 2842|     94|	obj->content.len = len;
 2843|       |
 2844|     94|	return SC_SUCCESS;
  ------------------
  |  |   28|     94|#define SC_SUCCESS				0
  ------------------
 2845|     94|}
sc_pkcs15_get_specific_supported_algo:
 2871|  2.59k|{
 2872|  2.59k|	struct sc_context *ctx = p15card->card->ctx;
 2873|  2.59k|	struct sc_supported_algo_info *info = NULL;
 2874|  2.59k|	int ii;
 2875|       |
 2876|  2.59k|	if (algo_oid == NULL)
  ------------------
  |  Branch (2876:6): [True: 0, False: 2.59k]
  ------------------
 2877|      0|		return NULL;
 2878|       |
 2879|  5.24k|	for (ii=0;ii<SC_MAX_SUPPORTED_ALGORITHMS && p15card->tokeninfo->supported_algos[ii].reference; ii++)
  ------------------
  |  |   61|  10.4k|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (2879:12): [True: 5.24k, False: 0]
  |  Branch (2879:46): [True: 2.65k, False: 2.59k]
  ------------------
 2880|  2.65k|		if ((p15card->tokeninfo->supported_algos[ii].operations & operation)
  ------------------
  |  Branch (2880:7): [True: 2.60k, False: 49]
  ------------------
 2881|  2.60k|				&& (p15card->tokeninfo->supported_algos[ii].mechanism == mechanism)
  ------------------
  |  Branch (2881:8): [True: 641, False: 1.96k]
  ------------------
 2882|    641|				&& sc_compare_oid(algo_oid, &p15card->tokeninfo->supported_algos[ii].algo_id) == 1)
  ------------------
  |  Branch (2882:8): [True: 0, False: 641]
  ------------------
 2883|      0|			break;
 2884|       |
 2885|  2.59k|	if (ii < SC_MAX_SUPPORTED_ALGORITHMS && p15card->tokeninfo->supported_algos[ii].reference)   {
  ------------------
  |  |   61|  5.18k|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (2885:6): [True: 2.59k, False: 0]
  |  Branch (2885:42): [True: 0, False: 2.59k]
  ------------------
 2886|      0|		info = &p15card->tokeninfo->supported_algos[ii];
 2887|      0|		sc_log(ctx, "found supported algorithm (ref:%X,mech:%X,ops:%X,algo_ref:%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__
  |  |  ------------------
  ------------------
 2888|      0|				info->reference, info->mechanism, info->operations, info->algo_ref);
 2889|      0|	}
 2890|       |
 2891|  2.59k|	return info;
 2892|  2.59k|}
sc_pkcs15_get_generalized_time:
 2896|    715|{
 2897|    715|#ifdef HAVE_GETTIMEOFDAY
 2898|    715|	struct timeval tv;
 2899|    715|#endif
 2900|    715|	struct tm tm;
 2901|    715|	time_t t;
 2902|       |
 2903|    715|	if (!ctx || !out)
  ------------------
  |  Branch (2903:6): [True: 0, False: 715]
  |  Branch (2903:14): [True: 0, False: 715]
  ------------------
 2904|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 2905|    715|	*out = NULL;
 2906|       |
 2907|    715|#ifdef HAVE_GETTIMEOFDAY
 2908|    715|	gettimeofday(&tv, NULL);
 2909|    715|	t = tv.tv_sec;
 2910|       |#else
 2911|       |	t = time(NULL);
 2912|       |#endif
 2913|       |
 2914|       |#ifdef _WIN32
 2915|       |	if (0 != gmtime_s(&tm, &t))
 2916|       |		LOG_FUNC_RETURN(ctx, SC_ERROR_INTERNAL);
 2917|       |#else
 2918|    715|	if (NULL == gmtime_r(&t, &tm))
  ------------------
  |  Branch (2918:6): [True: 0, False: 715]
  ------------------
 2919|    715|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2920|    715|#endif
 2921|       |
 2922|    715|	*out = calloc(1, 16);
 2923|    715|	if (*out == NULL)
  ------------------
  |  Branch (2923:6): [True: 0, False: 715]
  ------------------
 2924|    715|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2925|       |
 2926|       |	/* print time in generalized time format */
 2927|    715|	if (!strftime(*out, 16, "%Y%m%d%H%M%SZ", &tm)) {
  ------------------
  |  Branch (2927:6): [True: 0, False: 715]
  ------------------
 2928|      0|		free(*out);
 2929|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2930|      0|	}
 2931|       |
 2932|    715|	return SC_SUCCESS;
  ------------------
  |  |   28|    715|#define SC_SUCCESS				0
  ------------------
 2933|    715|}
sc_pkcs15_add_supported_algo_ref:
 2938|  1.31k|{
 2939|  1.31k|	unsigned int ii, *algo_refs = NULL;
 2940|       |
 2941|  1.31k|	if (!algo)
  ------------------
  |  Branch (2941:6): [True: 0, False: 1.31k]
  ------------------
 2942|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 2943|       |
 2944|  1.31k|	switch (obj->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|  1.31k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  |  Branch (2944:10): [True: 1.31k, False: 0]
  ------------------
 2945|      0|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|      0|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (2945:2): [True: 0, False: 1.31k]
  ------------------
 2946|      0|		algo_refs = ((struct sc_pkcs15_prkey_info *)obj->data)->algo_refs;
 2947|      0|		break;
 2948|      0|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|      0|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (2948:2): [True: 0, False: 1.31k]
  ------------------
 2949|      0|		algo_refs = ((struct sc_pkcs15_pubkey_info *)obj->data)->algo_refs;
 2950|      0|		break;
 2951|  1.31k|	case SC_PKCS15_TYPE_SKEY:
  ------------------
  |  |  432|  1.31k|#define SC_PKCS15_TYPE_SKEY			0x300
  ------------------
  |  Branch (2951:2): [True: 1.31k, False: 0]
  ------------------
 2952|  1.31k|		algo_refs = ((struct sc_pkcs15_skey_info *)obj->data)->algo_refs;
 2953|  1.31k|		break;
 2954|  1.31k|	}
 2955|  1.31k|	if (!algo_refs)
  ------------------
  |  Branch (2955:6): [True: 0, False: 1.31k]
  ------------------
 2956|      0|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 2957|       |
 2958|  1.96k|	for (ii=0;ii<SC_MAX_SUPPORTED_ALGORITHMS && *(algo_refs + ii);ii++)
  ------------------
  |  |   61|  3.93k|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (2958:12): [True: 1.96k, False: 0]
  |  Branch (2958:46): [True: 654, False: 1.31k]
  ------------------
 2959|    654|		if (*(algo_refs + ii) == algo->reference)
  ------------------
  |  Branch (2959:7): [True: 0, False: 654]
  ------------------
 2960|      0|			return SC_SUCCESS;
  ------------------
  |  |   28|  1.31k|#define SC_SUCCESS				0
  ------------------
 2961|       |
 2962|  1.96k|	for (ii=0;ii<SC_MAX_SUPPORTED_ALGORITHMS;ii++)   {
  ------------------
  |  |   61|  1.96k|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (2962:12): [True: 1.96k, False: 0]
  ------------------
 2963|  1.96k|		if (*(algo_refs + ii) == 0)   {
  ------------------
  |  Branch (2963:7): [True: 1.31k, False: 654]
  ------------------
 2964|  1.31k|			*(algo_refs + ii) = algo->reference;
 2965|  1.31k|			return SC_SUCCESS;
  ------------------
  |  |   28|  1.31k|#define SC_SUCCESS				0
  ------------------
 2966|  1.31k|		}
 2967|  1.96k|	}
 2968|       |
 2969|      0|	return SC_ERROR_TOO_MANY_OBJECTS;
  ------------------
  |  |   86|      0|#define SC_ERROR_TOO_MANY_OBJECTS		-1405
  ------------------
 2970|  1.31k|}
sc_pkcs15_free_key_params:
 3138|  4.30k|{
 3139|  4.30k|	if (!params)
  ------------------
  |  Branch (3139:6): [True: 0, False: 4.30k]
  ------------------
 3140|      0|		return;
 3141|  4.30k|	if (params->data && params->free_params)
  ------------------
  |  Branch (3141:6): [True: 902, False: 3.40k]
  |  Branch (3141:22): [True: 894, False: 8]
  ------------------
 3142|    894|		params->free_params(params->data);
 3143|  3.41k|	else if (params->data)
  ------------------
  |  Branch (3143:11): [True: 8, False: 3.40k]
  ------------------
 3144|      8|		free(params->data);
 3145|       |
 3146|       |	params->data = NULL;
 3147|  4.30k|}
pkcs15.c:sc_pkcs15_clear_tokeninfo:
  754|  37.3k|{
  755|  37.3k|	if (!tokeninfo)
  ------------------
  |  Branch (755:6): [True: 0, False: 37.3k]
  ------------------
  756|      0|		return;
  757|       |
  758|  37.3k|	free(tokeninfo->label);
  759|  37.3k|	tokeninfo->label = NULL;
  760|  37.3k|	free(tokeninfo->serial_number);
  761|  37.3k|	tokeninfo->serial_number = NULL;
  762|  37.3k|	free(tokeninfo->manufacturer_id);
  763|  37.3k|	tokeninfo->manufacturer_id = NULL;
  764|  37.3k|	free(tokeninfo->last_update.gtime);
  765|  37.3k|	tokeninfo->last_update.gtime = NULL;
  766|  37.3k|	free(tokeninfo->preferred_language);
  767|  37.3k|	tokeninfo->preferred_language = NULL;
  768|  37.3k|	free(tokeninfo->profile_indication.name);
  769|  37.3k|	tokeninfo->profile_indication.name = NULL;
  770|  37.3k|	if (tokeninfo->seInfo != NULL) {
  ------------------
  |  Branch (770:6): [True: 37, False: 37.2k]
  ------------------
  771|     37|		unsigned i;
  772|    108|		for (i = 0; i < tokeninfo->num_seInfo; i++)
  ------------------
  |  Branch (772:15): [True: 71, False: 37]
  ------------------
  773|     71|			free(tokeninfo->seInfo[i]);
  774|     37|		free(tokeninfo->seInfo);
  775|       |		tokeninfo->seInfo = NULL;
  776|     37|	}
  777|  37.3k|}
pkcs15.c:parse_odf:
  621|    314|{
  622|    314|	const unsigned char *p = buf;
  623|    314|	size_t left = buflen;
  624|    314|	int r, i, type;
  625|    314|	struct sc_path path;
  626|    314|	struct sc_asn1_entry asn1_obj_or_path[] = {
  627|    314|		{ "path", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_SEQUENCE, 0, &path, NULL },
  ------------------
  |  |  174|    314|#define SC_ASN1_PATH			256
  ------------------
              		{ "path", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_SEQUENCE, 0, &path, NULL },
  ------------------
  |  |  141|    314|#define SC_ASN1_CONS			0x20000000
  ------------------
              		{ "path", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_SEQUENCE, 0, &path, NULL },
  ------------------
  |  |  162|    314|#define SC_ASN1_SEQUENCE                16
  ------------------
  628|    314|		{ NULL, 0, 0, 0, NULL, NULL }
  629|    314|	};
  630|    314|	struct sc_asn1_entry asn1_odf[10];
  631|       |
  632|    314|	sc_copy_asn1_entry(c_asn1_odf, asn1_odf);
  633|  3.14k|	for (i = 0; asn1_odf[i].name != NULL; i++)
  ------------------
  |  Branch (633:14): [True: 2.82k, False: 314]
  ------------------
  634|  2.82k|		sc_format_asn1_entry(asn1_odf + i, asn1_obj_or_path, NULL, 0);
  635|    892|	while (left > 0) {
  ------------------
  |  Branch (635:9): [True: 890, False: 2]
  ------------------
  636|    890|		r = sc_asn1_decode_choice(p15card->card->ctx, asn1_odf, p, left, &p, &left);
  637|    890|		if (r == SC_ERROR_ASN1_END_OF_CONTENTS)
  ------------------
  |  |   84|    890|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (637:7): [True: 282, False: 608]
  ------------------
  638|    282|			break;
  639|    608|		if (r < 0)
  ------------------
  |  Branch (639:7): [True: 30, False: 578]
  ------------------
  640|     30|			return r;
  641|    578|		type = r;
  642|    578|		if (p15card->file_app) {
  ------------------
  |  Branch (642:7): [True: 578, False: 0]
  ------------------
  643|    578|			r = sc_pkcs15_make_absolute_path(&p15card->file_app->path, &path);
  644|    578|			if (r < 0)
  ------------------
  |  Branch (644:8): [True: 0, False: 578]
  ------------------
  645|      0|				return r;
  646|    578|			r = sc_pkcs15_add_df(p15card, odf_indexes[type], &path);
  647|    578|			if (r)
  ------------------
  |  Branch (647:8): [True: 0, False: 578]
  ------------------
  648|      0|				return r;
  649|    578|		}
  650|    578|	}
  651|    284|	return 0;
  652|    314|}
pkcs15.c:sc_dup_app_info:
  908|    217|{
  909|    217|	struct sc_app_info *out = calloc(1, sizeof(struct sc_app_info));
  910|       |
  911|    217|	if (!out)
  ------------------
  |  Branch (911:6): [True: 0, False: 217]
  ------------------
  912|      0|		return NULL;
  913|       |
  914|    217|	memcpy(out, info, sizeof(struct sc_app_info));
  915|       |
  916|    217|	if (info->label) {
  ------------------
  |  Branch (916:6): [True: 59, False: 158]
  ------------------
  917|     59|		out->label = strdup(info->label);
  918|     59|		if (!out->label) {
  ------------------
  |  Branch (918:7): [True: 0, False: 59]
  ------------------
  919|      0|			free(out);
  920|      0|			return NULL;
  921|      0|		}
  922|     59|	} else
  923|    158|		out->label = NULL;
  924|       |
  925|    217|	out->ddo.value = malloc(info->ddo.len);
  926|    217|	if (!out->ddo.value) {
  ------------------
  |  Branch (926:6): [True: 0, False: 217]
  ------------------
  927|      0|		free(out->label);
  928|      0|		free(out);
  929|      0|		return NULL;
  930|      0|	}
  931|    217|	memcpy(out->ddo.value, info->ddo.value, info->ddo.len);
  932|    217|	out->ddo.len = info->ddo.len;
  933|       |
  934|    217|	return out;
  935|    217|}
pkcs15.c:parse_ddo:
  473|     95|{
  474|     95|	struct sc_context *ctx = p15card->card->ctx;
  475|     95|	struct sc_asn1_entry asn1_ddo[7];
  476|     95|	sc_path_t odf_path, ti_path, us_path;
  477|     95|	struct sc_iid iid;
  478|     95|	struct sc_aid aid;
  479|     95|	int r;
  480|       |
  481|     95|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     95|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     95|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     95|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     95|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 95]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  482|       |
  483|     95|	iid.len = sizeof(iid.value);
  484|     95|	aid.len = sizeof(aid.value);
  485|       |
  486|     95|	sc_copy_asn1_entry(c_asn1_ddo, asn1_ddo);
  487|     95|	sc_format_asn1_entry(asn1_ddo + 1, &odf_path, NULL, 0);
  488|     95|	sc_format_asn1_entry(asn1_ddo + 2, &ti_path, NULL, 0);
  489|     95|	sc_format_asn1_entry(asn1_ddo + 3, &us_path, NULL, 0);
  490|     95|	sc_format_asn1_entry(asn1_ddo + 4, iid.value, &iid.len, 0);
  491|     95|	sc_format_asn1_entry(asn1_ddo + 5, aid.value, &aid.len, 0);
  492|       |
  493|     95|	r = sc_asn1_decode(ctx, asn1_ddo, buf, buflen, NULL, NULL);
  494|     95|	LOG_TEST_RET(ctx, r, "DDO parsing failed");
  ------------------
  |  |  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: 34, False: 61]
  |  |  |  |  ------------------
  |  |  |  |  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|     95|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 61]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  495|       |
  496|     61|	if (asn1_ddo[1].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|     61|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (496:6): [True: 4, False: 57]
  ------------------
  497|      4|		sc_file_free(p15card->file_odf);
  498|      4|		p15card->file_odf = sc_file_new();
  499|      4|		if (p15card->file_odf == NULL)
  ------------------
  |  Branch (499:7): [True: 0, False: 4]
  ------------------
  500|      0|			goto mem_err;
  501|      4|		p15card->file_odf->path = odf_path;
  502|      4|	}
  503|     61|	if (asn1_ddo[2].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|     61|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (503:6): [True: 40, False: 21]
  ------------------
  504|     40|		sc_file_free(p15card->file_tokeninfo);
  505|     40|		p15card->file_tokeninfo = sc_file_new();
  506|     40|		if (p15card->file_tokeninfo == NULL)
  ------------------
  |  Branch (506:7): [True: 0, False: 40]
  ------------------
  507|      0|			goto mem_err;
  508|     40|		p15card->file_tokeninfo->path = ti_path;
  509|     40|	}
  510|     61|	if (asn1_ddo[3].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|     61|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (510:6): [True: 4, False: 57]
  ------------------
  511|      4|		sc_file_free(p15card->file_unusedspace);
  512|      4|		p15card->file_unusedspace = sc_file_new();
  513|      4|		if (p15card->file_unusedspace == NULL)
  ------------------
  |  Branch (513:7): [True: 0, False: 4]
  ------------------
  514|      0|			goto mem_err;
  515|      4|		p15card->file_unusedspace->path = us_path;
  516|      4|	}
  517|     61|	if (asn1_ddo[4].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|     61|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (517:6): [True: 5, False: 56]
  ------------------
  518|      5|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "DDO.IID '%s'", sc_dump_hex(iid.value, iid.len));
  ------------------
  |  |   70|      5|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  519|      5|		memcpy(&p15card->app->ddo.iid, &iid, sizeof(struct sc_iid));
  520|      5|	}
  521|     61|	if (asn1_ddo[5].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|     61|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (521:6): [True: 3, False: 58]
  ------------------
  522|      3|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "DDO.AID '%s'", sc_dump_hex(aid.value, aid.len));
  ------------------
  |  |   70|      3|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  523|      3|		memcpy(&p15card->app->ddo.aid, &aid, sizeof(struct sc_aid));
  524|      3|	}
  525|       |
  526|     61|	fix_authentic_ddo(p15card);
  527|     61|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     61|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     61|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     61|	int _ret = r; \
  |  |  |  |  155|     61|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 61, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     61|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 61]
  |  |  |  |  ------------------
  |  |  |  |  157|     61|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     61|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     61|	return _ret; \
  |  |  |  |  163|     61|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  528|      0|mem_err:
  529|      0|	sc_file_free(p15card->file_odf);
  530|      0|	p15card->file_odf = NULL;
  531|      0|	sc_file_free(p15card->file_tokeninfo);
  532|      0|	p15card->file_tokeninfo = NULL;
  533|      0|	sc_file_free(p15card->file_unusedspace);
  534|      0|	p15card->file_unusedspace = NULL;
  535|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  536|      0|}
pkcs15.c:fix_authentic_ddo:
  459|     61|{
  460|       |	/* AuthentIC v3.2 card has invalid ODF and tokenInfo paths encoded into DDO.
  461|       |	 * Cleanup this attributes -- default values must be OK.
  462|       |	 */
  463|     61|	if (p15card->card->type == SC_CARD_TYPE_OBERTHUR_AUTHENTIC_3_2)   {
  ------------------
  |  Branch (463:6): [True: 0, False: 61]
  ------------------
  464|      0|		sc_file_free(p15card->file_odf);
  465|      0|		p15card->file_odf = NULL;
  466|      0|		sc_file_free(p15card->file_tokeninfo);
  467|       |		p15card->file_tokeninfo = NULL;
  468|      0|	}
  469|     61|}
pkcs15.c:__sc_pkcs15_search_objects:
 1458|  1.33M|{
 1459|  1.33M|	struct sc_pkcs15_object *obj = NULL;
 1460|  1.33M|	struct sc_pkcs15_df	*df = NULL;
 1461|  1.33M|	unsigned int	df_mask = 0;
 1462|  1.33M|	size_t		match_count = 0;
 1463|  1.33M|	int r;
 1464|       |
 1465|  1.33M|	if (type)
  ------------------
  |  Branch (1465:6): [True: 704k, False: 632k]
  ------------------
 1466|   704k|		class_mask |= SC_PKCS15_TYPE_TO_CLASS(type);
  ------------------
  |  |  449|   704k|#define SC_PKCS15_TYPE_TO_CLASS(t)		(1 << ((t) >> 8))
  ------------------
 1467|       |
 1468|       |	/* Make sure the class mask we have makes sense */
 1469|  1.33M|	if (class_mask == 0
  ------------------
  |  Branch (1469:6): [True: 0, False: 1.33M]
  ------------------
 1470|  1.33M|			|| (class_mask & ~(
  ------------------
  |  Branch (1470:7): [True: 0, False: 1.33M]
  ------------------
 1471|  1.33M|					SC_PKCS15_SEARCH_CLASS_PRKEY |
  ------------------
  |  |  450|  1.33M|#define SC_PKCS15_SEARCH_CLASS_PRKEY		0x0002U
  ------------------
 1472|  1.33M|					SC_PKCS15_SEARCH_CLASS_PUBKEY |
  ------------------
  |  |  451|  1.33M|#define SC_PKCS15_SEARCH_CLASS_PUBKEY		0x0004U
  ------------------
 1473|  1.33M|					SC_PKCS15_SEARCH_CLASS_SKEY |
  ------------------
  |  |  452|  1.33M|#define SC_PKCS15_SEARCH_CLASS_SKEY		0x0008U
  ------------------
 1474|  1.33M|					SC_PKCS15_SEARCH_CLASS_CERT |
  ------------------
  |  |  453|  1.33M|#define SC_PKCS15_SEARCH_CLASS_CERT		0x0010U
  ------------------
 1475|  1.33M|					SC_PKCS15_SEARCH_CLASS_DATA |
  ------------------
  |  |  454|  1.33M|#define SC_PKCS15_SEARCH_CLASS_DATA		0x0020U
  ------------------
 1476|  1.33M|					SC_PKCS15_SEARCH_CLASS_AUTH))) {
  ------------------
  |  |  455|  1.33M|#define SC_PKCS15_SEARCH_CLASS_AUTH		0x0040U
  ------------------
 1477|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1478|      0|	}
 1479|       |
 1480|  1.33M|	if (class_mask & SC_PKCS15_SEARCH_CLASS_PRKEY)
  ------------------
  |  |  450|  1.33M|#define SC_PKCS15_SEARCH_CLASS_PRKEY		0x0002U
  ------------------
  |  Branch (1480:6): [True: 640k, False: 696k]
  ------------------
 1481|   640k|		df_mask |= (1 << SC_PKCS15_PRKDF);
  ------------------
  |  |  488|   640k|#define SC_PKCS15_PRKDF			0
  ------------------
 1482|  1.33M|	if (class_mask & SC_PKCS15_SEARCH_CLASS_PUBKEY)
  ------------------
  |  |  451|  1.33M|#define SC_PKCS15_SEARCH_CLASS_PUBKEY		0x0004U
  ------------------
  |  Branch (1482:6): [True: 632k, False: 704k]
  ------------------
 1483|   632k|		df_mask |= (1 << SC_PKCS15_PUKDF) | (1 << SC_PKCS15_PUKDF_TRUSTED);
  ------------------
  |  |  489|   632k|#define SC_PKCS15_PUKDF			1
  ------------------
              		df_mask |= (1 << SC_PKCS15_PUKDF) | (1 << SC_PKCS15_PUKDF_TRUSTED);
  ------------------
  |  |  490|   632k|#define SC_PKCS15_PUKDF_TRUSTED		2
  ------------------
 1484|  1.33M|	if (class_mask & SC_PKCS15_SEARCH_CLASS_CERT)
  ------------------
  |  |  453|  1.33M|#define SC_PKCS15_SEARCH_CLASS_CERT		0x0010U
  ------------------
  |  Branch (1484:6): [True: 632k, False: 704k]
  ------------------
 1485|   632k|		df_mask |= (1 << SC_PKCS15_CDF) | (1 << SC_PKCS15_CDF_TRUSTED) | (1 << SC_PKCS15_CDF_USEFUL);
  ------------------
  |  |  492|   632k|#define SC_PKCS15_CDF			4
  ------------------
              		df_mask |= (1 << SC_PKCS15_CDF) | (1 << SC_PKCS15_CDF_TRUSTED) | (1 << SC_PKCS15_CDF_USEFUL);
  ------------------
  |  |  493|   632k|#define SC_PKCS15_CDF_TRUSTED		5
  ------------------
              		df_mask |= (1 << SC_PKCS15_CDF) | (1 << SC_PKCS15_CDF_TRUSTED) | (1 << SC_PKCS15_CDF_USEFUL);
  ------------------
  |  |  494|   632k|#define SC_PKCS15_CDF_USEFUL		6
  ------------------
 1486|  1.33M|	if (class_mask & SC_PKCS15_SEARCH_CLASS_DATA)
  ------------------
  |  |  454|  1.33M|#define SC_PKCS15_SEARCH_CLASS_DATA		0x0020U
  ------------------
  |  Branch (1486:6): [True: 7.41k, False: 1.32M]
  ------------------
 1487|  7.41k|		df_mask |= (1 << SC_PKCS15_DODF);
  ------------------
  |  |  495|  7.41k|#define SC_PKCS15_DODF			7
  ------------------
 1488|  1.33M|	if (class_mask & SC_PKCS15_SEARCH_CLASS_AUTH)
  ------------------
  |  |  455|  1.33M|#define SC_PKCS15_SEARCH_CLASS_AUTH		0x0040U
  ------------------
  |  Branch (1488:6): [True: 20.8k, False: 1.31M]
  ------------------
 1489|  20.8k|		df_mask |= (1 << SC_PKCS15_AODF);
  ------------------
  |  |  496|  20.8k|#define SC_PKCS15_AODF			8
  ------------------
 1490|  1.33M|	if (class_mask & SC_PKCS15_SEARCH_CLASS_SKEY)
  ------------------
  |  |  452|  1.33M|#define SC_PKCS15_SEARCH_CLASS_SKEY		0x0008U
  ------------------
  |  Branch (1490:6): [True: 35.8k, False: 1.30M]
  ------------------
 1491|  35.8k|		df_mask |= (1 << SC_PKCS15_SKDF);
  ------------------
  |  |  491|  35.8k|#define SC_PKCS15_SKDF			3
  ------------------
 1492|       |
 1493|       |	/* Make sure all the DFs we want to search have been
 1494|       |	 * enumerated. */
 1495|  2.02M|	for (df = p15card->df_list; df != NULL; df = df->next) {
  ------------------
  |  Branch (1495:30): [True: 686k, False: 1.33M]
  ------------------
 1496|   686k|		if (!(df_mask & (1 << df->type)))   {
  ------------------
  |  Branch (1496:7): [True: 517k, False: 168k]
  ------------------
 1497|   517k|			continue;
 1498|   517k|		}
 1499|   168k|		if (df->enumerated)
  ------------------
  |  Branch (1499:7): [True: 130k, False: 37.2k]
  ------------------
 1500|   130k|			continue;
 1501|       |		/* Enumerate the DF's, so p15card->obj_list is populated. */
 1502|  37.2k|		if (p15card->ops.parse_df)
  ------------------
  |  Branch (1502:7): [True: 0, False: 37.2k]
  ------------------
 1503|      0|			r = p15card->ops.parse_df(p15card, df);
 1504|  37.2k|		else
 1505|  37.2k|			r = sc_pkcs15_parse_df(p15card, df);
 1506|  37.2k|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|  37.2k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1506:7): [True: 37.2k, False: 62]
  ------------------
 1507|  37.2k|			continue;
 1508|  37.2k|	}
 1509|       |
 1510|       |	/* And now loop over all objects */
 1511|  2.10M|	for (obj = p15card->obj_list; obj != NULL; obj = obj->next) {
  ------------------
  |  Branch (1511:32): [True: 765k, False: 1.33M]
  ------------------
 1512|       |		/* Check object type */
 1513|   765k|		if (!(class_mask & SC_PKCS15_TYPE_TO_CLASS(obj->type)))
  ------------------
  |  |  449|   765k|#define SC_PKCS15_TYPE_TO_CLASS(t)		(1 << ((t) >> 8))
  ------------------
  |  Branch (1513:7): [True: 611k, False: 154k]
  ------------------
 1514|   611k|			continue;
 1515|   154k|		if (type != 0
  ------------------
  |  Branch (1515:7): [True: 84.0k, False: 70.3k]
  ------------------
 1516|  84.0k|		 && obj->type != type
  ------------------
  |  Branch (1516:7): [True: 76.3k, False: 7.63k]
  ------------------
 1517|  76.3k|		 && (obj->type & SC_PKCS15_TYPE_CLASS_MASK) != type)
  ------------------
  |  |  416|  76.3k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  |  Branch (1517:7): [True: 0, False: 76.3k]
  ------------------
 1518|      0|			continue;
 1519|       |
 1520|       |		/* Potential candidate, apply search function */
 1521|   154k|		if (func != NULL && func(obj, func_arg) <= 0)
  ------------------
  |  Branch (1521:7): [True: 145k, False: 8.43k]
  |  Branch (1521:23): [True: 144k, False: 1.49k]
  ------------------
 1522|   144k|			continue;
 1523|       |		/* Okay, we have a match. */
 1524|  9.92k|		match_count++;
 1525|  9.92k|		if (!ret || ret_size <= 0)
  ------------------
  |  Branch (1525:7): [True: 581, False: 9.34k]
  |  Branch (1525:15): [True: 0, False: 9.34k]
  ------------------
 1526|    581|			continue;
 1527|  9.34k|		ret[match_count-1] = obj;
 1528|  9.34k|		if (ret_size <= match_count)
  ------------------
  |  Branch (1528:7): [True: 911, False: 8.43k]
  ------------------
 1529|    911|			break;
 1530|  9.34k|	}
 1531|       |
 1532|  1.33M|	return (int)match_count;
 1533|  1.33M|}
pkcs15.c:compare_obj_key:
 1678|   145k|{
 1679|   145k|	struct sc_pkcs15_search_key *sk = (struct sc_pkcs15_search_key *) arg;
 1680|       |
 1681|   145k|	if (sk->id && !compare_obj_id(obj, sk->id))
  ------------------
  |  Branch (1681:6): [True: 145k, False: 75]
  |  Branch (1681:16): [True: 144k, False: 1.49k]
  ------------------
 1682|   144k|		return 0;
 1683|  1.56k|	if (sk->app_oid && !sc_obj_app_oid(obj, sk->app_oid))
  ------------------
  |  Branch (1683:6): [True: 0, False: 1.56k]
  |  Branch (1683:21): [True: 0, False: 0]
  ------------------
 1684|      0|		return 0;
 1685|  1.56k|	if (sk->usage_mask && !compare_obj_usage(obj, sk->usage_mask, sk->usage_value))
  ------------------
  |  Branch (1685:6): [True: 0, False: 1.56k]
  |  Branch (1685:24): [True: 0, False: 0]
  ------------------
 1686|      0|		return 0;
 1687|  1.56k|	if (sk->flags_mask && !compare_obj_flags(obj, sk->flags_mask, sk->flags_value))
  ------------------
  |  Branch (1687:6): [True: 0, False: 1.56k]
  |  Branch (1687:24): [True: 0, False: 0]
  ------------------
 1688|      0|		return 0;
 1689|  1.56k|	if (sk->match_reference && !compare_obj_reference(obj, sk->reference))
  ------------------
  |  Branch (1689:6): [True: 75, False: 1.49k]
  |  Branch (1689:29): [True: 73, False: 2]
  ------------------
 1690|     73|		return 0;
 1691|  1.49k|	if (sk->path && !compare_obj_path(obj, sk->path))
  ------------------
  |  Branch (1691:6): [True: 2, False: 1.49k]
  |  Branch (1691:18): [True: 0, False: 2]
  ------------------
 1692|      0|		return 0;
 1693|  1.49k|	if (sk->app_label) {
  ------------------
  |  Branch (1693:6): [True: 0, False: 1.49k]
  ------------------
 1694|      0|		if (sk->label && !compare_obj_data_name(obj, sk->app_label, sk->label))
  ------------------
  |  Branch (1694:7): [True: 0, False: 0]
  |  Branch (1694:20): [True: 0, False: 0]
  ------------------
 1695|      0|			return 0;
 1696|  1.49k|	} else {
 1697|  1.49k|		if (sk->label && strncmp(sk->label, obj->label, sizeof(obj->label)) != 0)
  ------------------
  |  Branch (1697:7): [True: 0, False: 1.49k]
  |  Branch (1697:20): [True: 0, False: 0]
  ------------------
 1698|      0|			return 0;
 1699|  1.49k|	}
 1700|       |
 1701|  1.49k|	return 1;
 1702|  1.49k|}
pkcs15.c:compare_obj_id:
 1546|   145k|{
 1547|   145k|	void *data = obj->data;
 1548|       |
 1549|   145k|	switch (obj->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|   145k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  |  Branch (1549:10): [True: 145k, False: 0]
  ------------------
 1550|  69.9k|	case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|  69.9k|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (1550:2): [True: 69.9k, False: 75.8k]
  ------------------
 1551|  69.9k|		return sc_pkcs15_compare_id(&((struct sc_pkcs15_cert_info *) data)->id, id);
 1552|  72.7k|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|  72.7k|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (1552:2): [True: 72.7k, False: 73.0k]
  ------------------
 1553|  72.7k|		return sc_pkcs15_compare_id(&((struct sc_pkcs15_prkey_info *) data)->id, id);
 1554|    372|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|    372|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (1554:2): [True: 372, False: 145k]
  ------------------
 1555|    372|		return sc_pkcs15_compare_id(&((struct sc_pkcs15_pubkey_info *) data)->id, id);
 1556|      2|	case SC_PKCS15_TYPE_SKEY:
  ------------------
  |  |  432|      2|#define SC_PKCS15_TYPE_SKEY			0x300
  ------------------
  |  Branch (1556:2): [True: 2, False: 145k]
  ------------------
 1557|      2|		return sc_pkcs15_compare_id(&((struct sc_pkcs15_skey_info *) data)->id, id);
 1558|  2.74k|	case SC_PKCS15_TYPE_AUTH:
  ------------------
  |  |  444|  2.74k|#define SC_PKCS15_TYPE_AUTH			0x600
  ------------------
  |  Branch (1558:2): [True: 2.74k, False: 143k]
  ------------------
 1559|  2.74k|		return sc_pkcs15_compare_id(&((struct sc_pkcs15_auth_info *) data)->auth_id, id);
 1560|      0|	case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|      0|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (1560:2): [True: 0, False: 145k]
  ------------------
 1561|      0|		return sc_pkcs15_compare_id(&((struct sc_pkcs15_data_info *) data)->id, id);
 1562|   145k|	}
 1563|      0|	return 0;
 1564|   145k|}
pkcs15.c:compare_obj_reference:
 1618|     75|{
 1619|     75|	struct sc_pkcs15_auth_info *auth_info;
 1620|     75|	void		*data = obj->data;
 1621|     75|	int		reference;
 1622|       |
 1623|     75|	switch (obj->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|     75|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
 1624|     12|	case SC_PKCS15_TYPE_AUTH:
  ------------------
  |  |  444|     12|#define SC_PKCS15_TYPE_AUTH			0x600
  ------------------
  |  Branch (1624:2): [True: 12, False: 63]
  ------------------
 1625|     12|		auth_info = (struct sc_pkcs15_auth_info *) obj->data;
 1626|     12|		if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|     12|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (1626:7): [True: 0, False: 12]
  ------------------
 1627|      0|			return 0;
 1628|     12|		reference = auth_info->attrs.pin.reference;
 1629|     12|		break;
 1630|     63|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|     63|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (1630:2): [True: 63, False: 12]
  ------------------
 1631|     63|		reference = ((struct sc_pkcs15_prkey_info *) data)->key_reference;
 1632|     63|		break;
 1633|      0|	default:
  ------------------
  |  Branch (1633:2): [True: 0, False: 75]
  ------------------
 1634|      0|		return 0;
 1635|     75|	}
 1636|     75|	return reference == value;
 1637|     75|}
pkcs15.c:compare_obj_path:
 1642|      2|{
 1643|      2|	void *data = obj->data;
 1644|       |
 1645|      2|	switch (obj->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|      2|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  |  Branch (1645:10): [True: 2, False: 0]
  ------------------
 1646|      0|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|      0|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (1646:2): [True: 0, False: 2]
  ------------------
 1647|      0|		return sc_compare_path(&((struct sc_pkcs15_prkey_info *) data)->path, path);
 1648|      0|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|      0|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (1648:2): [True: 0, False: 2]
  ------------------
 1649|      0|		return sc_compare_path(&((struct sc_pkcs15_pubkey_info *) data)->path, path);
 1650|      0|	case SC_PKCS15_TYPE_SKEY:
  ------------------
  |  |  432|      0|#define SC_PKCS15_TYPE_SKEY			0x300
  ------------------
  |  Branch (1650:2): [True: 0, False: 2]
  ------------------
 1651|      0|		return sc_compare_path(&((struct sc_pkcs15_skey_info *) data)->path, path);
 1652|      0|	case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (1652:2): [True: 0, False: 2]
  ------------------
 1653|      0|		return sc_compare_path(&((struct sc_pkcs15_cert_info *) data)->path, path);
 1654|      2|	case SC_PKCS15_TYPE_AUTH:
  ------------------
  |  |  444|      2|#define SC_PKCS15_TYPE_AUTH			0x600
  ------------------
  |  Branch (1654:2): [True: 2, False: 0]
  ------------------
 1655|      2|		return sc_compare_path(&((struct sc_pkcs15_auth_info *) data)->path, path);
 1656|      0|	case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|      0|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (1656:2): [True: 0, False: 2]
  ------------------
 1657|      0|		return sc_compare_path(&((struct sc_pkcs15_data_info *) data)->path, path);
 1658|      2|	}
 1659|      0|	return 0;
 1660|      2|}
pkcs15.c:find_by_key:
 1708|  3.56k|{
 1709|  3.56k|	int r;
 1710|       |
 1711|  3.56k|	r = sc_pkcs15_get_objects_cond(p15card, type, compare_obj_key, sk, out, 1);
 1712|  3.56k|	if (r < 0)
  ------------------
  |  Branch (1712:6): [True: 0, False: 3.56k]
  ------------------
 1713|      0|		return r;
 1714|  3.56k|	if (r == 0)
  ------------------
  |  Branch (1714:6): [True: 3.56k, False: 2]
  ------------------
 1715|  3.56k|		return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|  3.56k|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
 1716|      2|	return 0;
 1717|  3.56k|}
pkcs15.c:sc_pkcs15_remove_objects:
 2022|  38.7k|{
 2023|  38.7k|	struct sc_pkcs15_object *cur = NULL, *next = NULL;
 2024|       |
 2025|  38.7k|	if (!p15card || !p15card->obj_list)
  ------------------
  |  Branch (2025:6): [True: 0, False: 38.7k]
  |  Branch (2025:18): [True: 37.6k, False: 1.14k]
  ------------------
 2026|  37.6k|		return;
 2027|  4.10k|	for (cur = p15card->obj_list; cur; cur = next)   {
  ------------------
  |  Branch (2027:32): [True: 2.95k, False: 1.14k]
  ------------------
 2028|  2.95k|		next = cur->next;
 2029|  2.95k|		sc_pkcs15_free_object(cur);
 2030|  2.95k|	}
 2031|       |
 2032|       |	p15card->obj_list = NULL;
 2033|  1.14k|}
pkcs15.c:sc_pkcs15_remove_dfs:
 2103|  38.7k|{
 2104|  38.7k|	struct sc_pkcs15_df *cur = NULL, *next = NULL;
 2105|       |
 2106|  38.7k|	if (!p15card || !p15card->df_list)
  ------------------
  |  Branch (2106:6): [True: 0, False: 38.7k]
  |  Branch (2106:18): [True: 37.0k, False: 1.68k]
  ------------------
 2107|  37.0k|		return;
 2108|       |
 2109|  5.34k|	for (cur = p15card->df_list; cur; cur = next)   {
  ------------------
  |  Branch (2109:31): [True: 3.66k, False: 1.68k]
  ------------------
 2110|  3.66k|		next = cur->next;
 2111|  3.66k|		free(cur);
 2112|  3.66k|	}
 2113|       |
 2114|       |	p15card->df_list = NULL;
 2115|  1.68k|}
pkcs15.c:sc_pkcs15_free_unusedspace:
 2338|  27.8k|{
 2339|  27.8k|	struct sc_pkcs15_unusedspace *cur = NULL, *next = NULL;
 2340|       |
 2341|  27.8k|	if (!p15card || !p15card->unusedspace_list)
  ------------------
  |  Branch (2341:6): [True: 0, False: 27.8k]
  |  Branch (2341:18): [True: 27.8k, False: 0]
  ------------------
 2342|  27.8k|		return;
 2343|      0|	for (cur = p15card->unusedspace_list; cur; cur = next)   {
  ------------------
  |  Branch (2343:40): [True: 0, False: 0]
  ------------------
 2344|      0|		next = cur->next;
 2345|      0|		free(cur);
 2346|      0|	}
 2347|       |
 2348|       |	p15card->unusedspace_list = NULL;
 2349|      0|}

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

card-entersafe.c:sc_evp_cipher:
  135|    258|{
  136|    258|	return (EVP_CIPHER *)EVP_get_cipherbyname(algorithm);
  137|    258|}
card-entersafe.c:sc_evp_cipher_free:
  140|    258|{
  141|    258|	return;
  142|    258|}
card-epass2003.c:sc_evp_cipher:
  135|  3.66k|{
  136|  3.66k|	return (EVP_CIPHER *)EVP_get_cipherbyname(algorithm);
  137|  3.66k|}
card-epass2003.c:sc_evp_cipher_free:
  140|  3.66k|{
  141|  3.66k|	return;
  142|  3.66k|}
card-epass2003.c:sc_evp_md:
  120|     31|{
  121|     31|	return (EVP_MD *)EVP_get_digestbyname(algorithm);
  122|     31|}
card-epass2003.c:sc_evp_md_free:
  125|     31|{
  126|     31|	return;
  127|     31|}

sc_get_version:
   59|  16.3k|{
   60|  16.3k|    return sc_version;
   61|  16.3k|}
sc_hex_to_bin:
   64|   219k|{
   65|   219k|	const char *sc_hex_to_bin_separators = " :";
   66|   219k|	if (in == NULL || out == NULL || outlen == NULL) {
  ------------------
  |  Branch (66:6): [True: 0, False: 219k]
  |  Branch (66:20): [True: 0, False: 219k]
  |  Branch (66:35): [True: 0, False: 219k]
  ------------------
   67|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   68|      0|	}
   69|       |
   70|   219k|	int byte_needs_nibble = 0;
   71|   219k|	int r = SC_SUCCESS;
  ------------------
  |  |   28|   219k|#define SC_SUCCESS				0
  ------------------
   72|   219k|	size_t left = *outlen;
   73|   219k|	u8 byte = 0;
   74|  5.39M|	while (*in != '\0' && 0 != left) {
  ------------------
  |  Branch (74:9): [True: 5.18M, False: 217k]
  |  Branch (74:24): [True: 5.18M, False: 115]
  ------------------
   75|  5.18M|		char c = *in++;
   76|  5.18M|		u8 nibble;
   77|  5.18M|		if      ('0' <= c && c <= '9')
  ------------------
  |  Branch (77:12): [True: 5.17M, False: 1.46k]
  |  Branch (77:24): [True: 2.61M, False: 2.56M]
  ------------------
   78|  2.61M|			nibble = c - '0';
   79|  2.56M|		else if ('a' <= c && c <= 'f')
  ------------------
  |  Branch (79:12): [True: 462k, False: 2.10M]
  |  Branch (79:24): [True: 462k, False: 383]
  ------------------
   80|   462k|			nibble = c - 'a' + 10;
   81|  2.10M|		else if ('A' <= c && c <= 'F')
  ------------------
  |  Branch (81:12): [True: 683k, False: 1.42M]
  |  Branch (81:24): [True: 683k, False: 560]
  ------------------
   82|   683k|			nibble = c - 'A' + 10;
   83|  1.42M|		else {
   84|  1.42M|			if (strchr(sc_hex_to_bin_separators, (int) c)) {
  ------------------
  |  Branch (84:8): [True: 1.42M, False: 1.51k]
  ------------------
   85|  1.42M|				if (byte_needs_nibble) {
  ------------------
  |  Branch (85:9): [True: 358, False: 1.42M]
  ------------------
   86|    358|					r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|    358|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   87|    358|					goto err;
   88|    358|				}
   89|  1.42M|				continue;
   90|  1.42M|			}
   91|  1.51k|			r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|  1.51k|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   92|  1.51k|			goto err;
   93|  1.42M|		}
   94|       |
   95|  3.75M|		if (byte_needs_nibble) {
  ------------------
  |  Branch (95:7): [True: 1.87M, False: 1.88M]
  ------------------
   96|  1.87M|			byte |= nibble;
   97|  1.87M|			*out++ = (u8) byte;
   98|  1.87M|			left--;
   99|  1.87M|			byte_needs_nibble = 0;
  100|  1.88M|		} else {
  101|  1.88M|			byte  = nibble << 4;
  102|  1.88M|			byte_needs_nibble = 1;
  103|  1.88M|		}
  104|  3.75M|	}
  105|       |
  106|   217k|	if (left == *outlen && 1 == byte_needs_nibble && 0 != left) {
  ------------------
  |  Branch (106:6): [True: 7.20k, False: 210k]
  |  Branch (106:25): [True: 6.86k, False: 342]
  |  Branch (106:51): [True: 6.86k, False: 0]
  ------------------
  107|       |		/* no output written so far, but we have a valid nibble in the upper
  108|       |		 * bits. Allow this special case. */
  109|  6.86k|		*out = (u8) byte>>4;
  110|  6.86k|		left--;
  111|  6.86k|		byte_needs_nibble = 0;
  112|  6.86k|	}
  113|       |
  114|       |	/* for ease of implementation we only accept completely hexed bytes. */
  115|   217k|	if (byte_needs_nibble) {
  ------------------
  |  Branch (115:6): [True: 1.12k, False: 216k]
  ------------------
  116|  1.12k|		r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|  1.12k|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  117|  1.12k|		goto err;
  118|  1.12k|	}
  119|       |
  120|       |	/* skip all trailing separators to see if we missed something */
  121|   216k|	while (*in != '\0') {
  ------------------
  |  Branch (121:9): [True: 337, False: 216k]
  ------------------
  122|    337|		if (NULL == strchr(sc_hex_to_bin_separators, (int) *in))
  ------------------
  |  Branch (122:7): [True: 113, False: 224]
  ------------------
  123|    113|			break;
  124|    224|		in++;
  125|    224|	}
  126|   216k|	if (*in != '\0') {
  ------------------
  |  Branch (126:6): [True: 113, False: 216k]
  ------------------
  127|    113|		r = SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|    113|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  128|    113|		goto err;
  129|    113|	}
  130|       |
  131|   219k|err:
  132|   219k|	*outlen -= left;
  133|   219k|	return r;
  134|   216k|}
sc_bin_to_hex:
  138|   380k|{
  139|   380k|	if (in == NULL || out == NULL) {
  ------------------
  |  Branch (139:6): [True: 0, False: 380k]
  |  Branch (139:20): [True: 0, False: 380k]
  ------------------
  140|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  141|      0|	}
  142|       |
  143|   380k|	if (in_sep > 0) {
  ------------------
  |  Branch (143:6): [True: 370k, False: 9.73k]
  ------------------
  144|   370k|		if (out_len < in_len*3 || out_len < 1)
  ------------------
  |  Branch (144:7): [True: 0, False: 370k]
  |  Branch (144:29): [True: 0, False: 370k]
  ------------------
  145|      0|			return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  146|   370k|	} else {
  147|  9.73k|		if (out_len < in_len*2 + 1)
  ------------------
  |  Branch (147:7): [True: 0, False: 9.73k]
  ------------------
  148|      0|			return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  149|  9.73k|	}
  150|       |
  151|   380k|	const char hex[] = "0123456789abcdef";
  152|  3.27M|	while (in_len) {
  ------------------
  |  Branch (152:9): [True: 2.89M, False: 380k]
  ------------------
  153|  2.89M|		unsigned char value = *in++;
  154|  2.89M|		*out++ = hex[(value >> 4) & 0xF];
  155|  2.89M|		*out++ = hex[ value       & 0xF];
  156|  2.89M|		in_len--;
  157|  2.89M|		if (in_len && in_sep > 0)
  ------------------
  |  Branch (157:7): [True: 2.68M, False: 202k]
  |  Branch (157:17): [True: 2.63M, False: 53.2k]
  ------------------
  158|  2.63M|			*out++ = (char)in_sep;
  159|  2.89M|	}
  160|   380k|	*out = '\0';
  161|       |
  162|   380k|	return SC_SUCCESS;
  ------------------
  |  |   28|   380k|#define SC_SUCCESS				0
  ------------------
  163|   380k|}
ulong2bebytes:
  189|  12.8k|{
  190|  12.8k|	if (buf != NULL) {
  ------------------
  |  Branch (190:6): [True: 12.8k, False: 0]
  ------------------
  191|  12.8k|		buf[3] = (u8) (x & 0xff);
  192|  12.8k|		buf[2] = (u8) ((x >> 8) & 0xff);
  193|  12.8k|		buf[1] = (u8) ((x >> 16) & 0xff);
  194|  12.8k|		buf[0] = (u8) ((x >> 24) & 0xff);
  195|  12.8k|	}
  196|  12.8k|	return buf;
  197|  12.8k|}
ushort2bebytes:
  200|  3.04k|{
  201|  3.04k|	if (buf != NULL) {
  ------------------
  |  Branch (201:6): [True: 3.04k, False: 0]
  ------------------
  202|  3.04k|		buf[1] = (u8) (x & 0xff);
  203|  3.04k|		buf[0] = (u8) ((x >> 8) & 0xff);
  204|  3.04k|	}
  205|  3.04k|	return buf;
  206|  3.04k|}
bebytes2ulong:
  209|   182k|{
  210|   182k|	if (buf == NULL)
  ------------------
  |  Branch (210:6): [True: 0, False: 182k]
  ------------------
  211|      0|		return 0UL;
  212|   182k|	return (unsigned long)buf[0] << 24
  213|   182k|		| (unsigned long)buf[1] << 16
  214|   182k|		| (unsigned long)buf[2] << 8
  215|   182k|		| (unsigned long)buf[3];
  216|   182k|}
bebytes2ushort:
  219|   541k|{
  220|   541k|	if (buf == NULL)
  ------------------
  |  Branch (220:6): [True: 0, False: 541k]
  ------------------
  221|      0|		return 0U;
  222|   541k|	return (unsigned short)buf[0] << 8
  223|   541k|		| (unsigned short)buf[1];
  224|   541k|}
lebytes2ushort:
  227|  2.16k|{
  228|  2.16k|	if (buf == NULL)
  ------------------
  |  Branch (228:6): [True: 0, False: 2.16k]
  ------------------
  229|      0|		return 0U;
  230|  2.16k|	return (unsigned short)buf[1] << 8
  231|  2.16k|		| (unsigned short)buf[0];
  232|  2.16k|}
set_string:
  245|  4.35k|{
  246|  4.35k|	if (strp == NULL) {
  ------------------
  |  Branch (246:6): [True: 0, False: 4.35k]
  ------------------
  247|      0|		return;
  248|      0|	}
  249|       |
  250|  4.35k|	free(*strp);
  251|  4.35k|	*strp = value ? strdup(value) : NULL;
  ------------------
  |  Branch (251:10): [True: 4.35k, False: 0]
  ------------------
  252|  4.35k|}
sc_init_oid:
  255|  61.2k|{
  256|  61.2k|	int ii;
  257|       |
  258|  61.2k|	if (!oid)
  ------------------
  |  Branch (258:6): [True: 0, False: 61.2k]
  ------------------
  259|      0|		return;
  260|  1.04M|	for (ii=0; ii<SC_MAX_OBJECT_ID_OCTETS; ii++)
  ------------------
  |  |   46|  1.04M|#define SC_MAX_OBJECT_ID_OCTETS		16
  ------------------
  |  Branch (260:13): [True: 980k, False: 61.2k]
  ------------------
  261|   980k|		oid->value[ii] = -1;
  262|  61.2k|}
sc_format_oid:
  265|  15.4k|{
  266|  15.4k|	int        ii, ret = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|  15.4k|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  267|  15.4k|	const char *p;
  268|  15.4k|	char       *q;
  269|       |
  270|  15.4k|	if (oid == NULL || in == NULL)
  ------------------
  |  Branch (270:6): [True: 0, False: 15.4k]
  |  Branch (270:21): [True: 0, False: 15.4k]
  ------------------
  271|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  272|       |
  273|  15.4k|	sc_init_oid(oid);
  274|       |
  275|  15.4k|	p = in;
  276|  78.4k|	for (ii=0; ii < SC_MAX_OBJECT_ID_OCTETS; ii++)   {
  ------------------
  |  |   46|  78.4k|#define SC_MAX_OBJECT_ID_OCTETS		16
  ------------------
  |  Branch (276:13): [True: 78.4k, False: 0]
  ------------------
  277|  78.4k|		oid->value[ii] = (int)strtol(p, &q, 10);
  278|  78.4k|		if (!*q)
  ------------------
  |  Branch (278:7): [True: 11.5k, False: 66.8k]
  ------------------
  279|  11.5k|			break;
  280|       |
  281|  66.8k|		if (!(q[0] == '.' && isdigit((unsigned char)q[1])))
  ------------------
  |  Branch (281:9): [True: 63.0k, False: 3.87k]
  |  Branch (281:24): [True: 63.0k, False: 1]
  ------------------
  282|  3.87k|			goto out;
  283|       |
  284|  63.0k|		p = q + 1;
  285|  63.0k|	}
  286|       |
  287|  11.5k|	if (!sc_valid_oid(oid))
  ------------------
  |  Branch (287:6): [True: 46, False: 11.4k]
  ------------------
  288|     46|		goto out;
  289|       |
  290|  11.4k|	ret = SC_SUCCESS;
  ------------------
  |  |   28|  11.4k|#define SC_SUCCESS				0
  ------------------
  291|  15.4k|out:
  292|  15.4k|	if (ret)
  ------------------
  |  Branch (292:6): [True: 3.92k, False: 11.4k]
  ------------------
  293|  3.92k|		sc_init_oid(oid);
  294|       |
  295|  15.4k|	return ret;
  296|  11.4k|}
sc_compare_oid:
  299|  35.1k|{
  300|  35.1k|	int i;
  301|       |
  302|  35.1k|	if (oid1 == NULL || oid2 == NULL) {
  ------------------
  |  Branch (302:6): [True: 0, False: 35.1k]
  |  Branch (302:22): [True: 0, False: 35.1k]
  ------------------
  303|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  304|      0|	}
  305|       |
  306|  96.3k|	for (i = 0; i < SC_MAX_OBJECT_ID_OCTETS; i++)   {
  ------------------
  |  |   46|  96.3k|#define SC_MAX_OBJECT_ID_OCTETS		16
  ------------------
  |  Branch (306:14): [True: 96.3k, False: 0]
  ------------------
  307|  96.3k|		if (oid1->value[i] != oid2->value[i])
  ------------------
  |  Branch (307:7): [True: 29.4k, False: 66.8k]
  ------------------
  308|  29.4k|			return 0;
  309|  66.8k|		if (oid1->value[i] == -1)
  ------------------
  |  Branch (309:7): [True: 5.65k, False: 61.1k]
  ------------------
  310|  5.65k|			break;
  311|  66.8k|	}
  312|       |
  313|  5.65k|	return 1;
  314|  35.1k|}
sc_valid_oid:
  318|  14.0k|{
  319|  14.0k|	int ii;
  320|       |
  321|  14.0k|	if (!oid)
  ------------------
  |  Branch (321:6): [True: 0, False: 14.0k]
  ------------------
  322|      0|		return 0;
  323|  14.0k|	if (oid->value[0] == -1 || oid->value[1] == -1)
  ------------------
  |  Branch (323:6): [True: 643, False: 13.4k]
  |  Branch (323:29): [True: 9, False: 13.4k]
  ------------------
  324|    652|		return 0;
  325|  13.4k|	if (oid->value[0] > 2 || oid->value[1] > 39)
  ------------------
  |  Branch (325:6): [True: 4, False: 13.4k]
  |  Branch (325:27): [True: 32, False: 13.3k]
  ------------------
  326|     36|		return 0;
  327|  18.8k|	for (ii=0;ii<SC_MAX_OBJECT_ID_OCTETS;ii++)
  ------------------
  |  |   46|  18.8k|#define SC_MAX_OBJECT_ID_OCTETS		16
  ------------------
  |  Branch (327:12): [True: 18.4k, False: 335]
  ------------------
  328|  18.4k|		if (oid->value[ii])
  ------------------
  |  Branch (328:7): [True: 13.0k, False: 5.43k]
  ------------------
  329|  13.0k|			break;
  330|  13.3k|	if (ii==SC_MAX_OBJECT_ID_OCTETS)
  ------------------
  |  |   46|  13.3k|#define SC_MAX_OBJECT_ID_OCTETS		16
  ------------------
  |  Branch (330:6): [True: 335, False: 13.0k]
  ------------------
  331|    335|		return 0;
  332|  13.0k|	return 1;
  333|  13.3k|}
sc_path_set:
  355|  27.5k|{
  356|  27.5k|	if (path == NULL || id == NULL || id_len == 0 || id_len > SC_MAX_PATH_SIZE)
  ------------------
  |  |   47|  27.5k|#define SC_MAX_PATH_SIZE		16
  ------------------
  |  Branch (356:6): [True: 0, False: 27.5k]
  |  Branch (356:22): [True: 0, False: 27.5k]
  |  Branch (356:36): [True: 0, False: 27.5k]
  |  Branch (356:51): [True: 0, False: 27.5k]
  ------------------
  357|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  358|       |
  359|  27.5k|	memset(path, 0, sizeof(*path));
  360|  27.5k|	memcpy(path->value, id, id_len);
  361|  27.5k|	path->len   = id_len;
  362|  27.5k|	path->type  = type;
  363|  27.5k|	path->index = idx;
  364|  27.5k|	path->count = count;
  365|       |
  366|  27.5k|	return SC_SUCCESS;
  ------------------
  |  |   28|  27.5k|#define SC_SUCCESS				0
  ------------------
  367|  27.5k|}
sc_format_path:
  370|  95.2k|{
  371|  95.2k|	int type = SC_PATH_TYPE_PATH;
  ------------------
  |  |  119|  95.2k|#define SC_PATH_TYPE_PATH		2
  ------------------
  372|       |
  373|  95.2k|	if (path) {
  ------------------
  |  Branch (373:6): [True: 95.2k, False: 0]
  ------------------
  374|  95.2k|		memset(path, 0, sizeof(*path));
  375|  95.2k|		if (*str == 'i' || *str == 'I') {
  ------------------
  |  Branch (375:7): [True: 63, False: 95.1k]
  |  Branch (375:22): [True: 37, False: 95.1k]
  ------------------
  376|    100|			type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|    100|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  377|    100|			str++;
  378|    100|		}
  379|  95.2k|		path->len = sizeof(path->value);
  380|  95.2k|		if (sc_hex_to_bin(str, path->value, &path->len) >= 0) {
  ------------------
  |  Branch (380:7): [True: 92.7k, False: 2.50k]
  ------------------
  381|  92.7k|			path->type = type;
  382|  92.7k|		}
  383|  95.2k|		path->count = -1;
  384|  95.2k|	}
  385|  95.2k|}
sc_append_path_id:
  393|  60.0k|{
  394|  60.0k|	if (dest->len + idlen > SC_MAX_PATH_SIZE)
  ------------------
  |  |   47|  60.0k|#define SC_MAX_PATH_SIZE		16
  ------------------
  |  Branch (394:6): [True: 302, False: 59.7k]
  ------------------
  395|    302|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|    302|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  396|  59.7k|	memcpy(dest->value + dest->len, id, idlen);
  397|  59.7k|	dest->len += idlen;
  398|  59.7k|	return SC_SUCCESS;
  ------------------
  |  |   28|  59.7k|#define SC_SUCCESS				0
  ------------------
  399|  60.0k|}
sc_append_file_id:
  402|  60.0k|{
  403|  60.0k|	u8 id[2] = { fid >> 8, fid & 0xff };
  404|       |
  405|  60.0k|	return sc_append_path_id(dest, id, 2);
  406|  60.0k|}
sc_concatenate_path:
  409|  15.9k|{
  410|  15.9k|	sc_path_t tpath;
  411|       |
  412|  15.9k|	if (d == NULL || p1 == NULL || p2 == NULL)
  ------------------
  |  Branch (412:6): [True: 0, False: 15.9k]
  |  Branch (412:19): [True: 0, False: 15.9k]
  |  Branch (412:33): [True: 0, False: 15.9k]
  ------------------
  413|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  414|       |
  415|  15.9k|	if (p1->type == SC_PATH_TYPE_DF_NAME || p2->type == SC_PATH_TYPE_DF_NAME)
  ------------------
  |  |  118|  31.9k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
              	if (p1->type == SC_PATH_TYPE_DF_NAME || p2->type == SC_PATH_TYPE_DF_NAME)
  ------------------
  |  |  118|  15.9k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (415:6): [True: 0, False: 15.9k]
  |  Branch (415:42): [True: 0, False: 15.9k]
  ------------------
  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.9k|	if (p1->len + p2->len > SC_MAX_PATH_SIZE)
  ------------------
  |  |   47|  15.9k|#define SC_MAX_PATH_SIZE		16
  ------------------
  |  Branch (419:6): [True: 0, False: 15.9k]
  ------------------
  420|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  421|       |
  422|  15.9k|	memset(&tpath, 0, sizeof(sc_path_t));
  423|  15.9k|	memcpy(tpath.value, p1->value, p1->len);
  424|  15.9k|	memcpy(tpath.value + p1->len, p2->value, p2->len);
  425|  15.9k|	tpath.len  = p1->len + p2->len;
  426|  15.9k|	tpath.type = SC_PATH_TYPE_PATH;
  ------------------
  |  |  119|  15.9k|#define SC_PATH_TYPE_PATH		2
  ------------------
  427|       |	/* use 'index' and 'count' entry of the second path object */
  428|  15.9k|	tpath.index = p2->index;
  429|  15.9k|	tpath.count = p2->count;
  430|       |	/* the result is currently always as path */
  431|  15.9k|	tpath.type  = SC_PATH_TYPE_PATH;
  ------------------
  |  |  119|  15.9k|#define SC_PATH_TYPE_PATH		2
  ------------------
  432|       |
  433|  15.9k|	*d = tpath;
  434|       |
  435|  15.9k|	return SC_SUCCESS;
  ------------------
  |  |   28|  15.9k|#define SC_SUCCESS				0
  ------------------
  436|  15.9k|}
sc_print_path:
  439|   328k|{
  440|   328k|	static char buffer[SC_MAX_PATH_STRING_SIZE + SC_MAX_AID_STRING_SIZE];
  441|       |
  442|   328k|	if (sc_path_print(buffer, sizeof(buffer), path) != SC_SUCCESS)
  ------------------
  |  |   28|   328k|#define SC_SUCCESS				0
  ------------------
  |  Branch (442:6): [True: 0, False: 328k]
  ------------------
  443|      0|		buffer[0] = '\0';
  444|       |
  445|   328k|	return buffer;
  446|   328k|}
sc_path_print:
  449|   469k|{
  450|   469k|	size_t i;
  451|       |
  452|   469k|	if (buf == NULL || path == NULL)
  ------------------
  |  Branch (452:6): [True: 0, False: 469k]
  |  Branch (452:21): [True: 0, False: 469k]
  ------------------
  453|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  454|       |
  455|   469k|	if (buflen < path->len * 2 + path->aid.len * 2 + 3)
  ------------------
  |  Branch (455:6): [True: 390, False: 468k]
  ------------------
  456|    390|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|    390|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  457|       |
  458|   468k|	buf[0] = '\0';
  459|   468k|	if (path->aid.len)   {
  ------------------
  |  Branch (459:6): [True: 116k, False: 352k]
  ------------------
  460|   904k|		for (i = 0; i < path->aid.len; i++)
  ------------------
  |  Branch (460:15): [True: 788k, False: 116k]
  ------------------
  461|   788k|			snprintf(buf + strlen(buf), buflen - strlen(buf), "%02x", path->aid.value[i]);
  462|   116k|		snprintf(buf + strlen(buf), buflen - strlen(buf), "::");
  463|   116k|	}
  464|       |
  465|  2.21M|	for (i = 0; i < path->len; i++)
  ------------------
  |  Branch (465:14): [True: 1.74M, False: 468k]
  ------------------
  466|  1.74M|		snprintf(buf + strlen(buf), buflen - strlen(buf), "%02x", path->value[i]);
  467|   468k|	if (!path->aid.len && path->type == SC_PATH_TYPE_DF_NAME)
  ------------------
  |  |  118|   352k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (467:6): [True: 352k, False: 116k]
  |  Branch (467:24): [True: 31.1k, False: 321k]
  ------------------
  468|  31.1k|		snprintf(buf + strlen(buf), buflen - strlen(buf), "::");
  469|       |
  470|   468k|	return SC_SUCCESS;
  ------------------
  |  |   28|   468k|#define SC_SUCCESS				0
  ------------------
  471|   469k|}
sc_compare_path:
  474|  23.0k|{
  475|  23.0k|	return path1->len == path2->len
  ------------------
  |  Branch (475:9): [True: 18.8k, False: 4.21k]
  ------------------
  476|  18.8k|		&& !memcmp(path1->value, path2->value, path1->len);
  ------------------
  |  Branch (476:6): [True: 4.25k, False: 14.5k]
  ------------------
  477|  23.0k|}
sc_compare_path_prefix:
  480|  12.9k|{
  481|  12.9k|	sc_path_t tpath;
  482|       |
  483|  12.9k|	if (prefix->len > path->len)
  ------------------
  |  Branch (483:6): [True: 33, False: 12.9k]
  ------------------
  484|     33|		return 0;
  485|       |
  486|  12.9k|	tpath     = *path;
  487|  12.9k|	tpath.len = prefix->len;
  488|       |
  489|  12.9k|	return sc_compare_path(&tpath, prefix);
  490|  12.9k|}
sc_get_mf_path:
  493|  16.9k|{
  494|  16.9k|	static const sc_path_t mf_path = {
  495|  16.9k|		{0x3f, 0x00, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 2,
  496|  16.9k|		0,
  497|  16.9k|		0,
  498|  16.9k|		SC_PATH_TYPE_PATH,
  ------------------
  |  |  119|  16.9k|#define SC_PATH_TYPE_PATH		2
  ------------------
  499|  16.9k|		{{0},0}
  500|  16.9k|	};
  501|  16.9k|	return &mf_path;
  502|  16.9k|}
sc_file_add_acl_entry:
  506|  2.89M|{
  507|  2.89M|	sc_acl_entry_t *p, *_new;
  508|       |
  509|  2.89M|	if (file == NULL || operation >= SC_MAX_AC_OPS) {
  ------------------
  |  |  198|  2.89M|#define SC_MAX_AC_OPS			31
  ------------------
  |  Branch (509:6): [True: 0, False: 2.89M]
  |  Branch (509:22): [True: 0, False: 2.89M]
  ------------------
  510|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  511|      0|	}
  512|       |
  513|  2.89M|	switch (method) {
  514|   139k|	case SC_AC_NEVER:
  ------------------
  |  |  163|   139k|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (514:2): [True: 139k, False: 2.75M]
  ------------------
  515|   139k|		sc_file_clear_acl_entries(file, operation);
  516|   139k|		file->acl[operation] = (sc_acl_entry_t *) 1;
  517|   139k|		return SC_SUCCESS;
  ------------------
  |  |   28|   139k|#define SC_SUCCESS				0
  ------------------
  518|  2.52M|	case SC_AC_NONE:
  ------------------
  |  |  150|  2.52M|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (518:2): [True: 2.52M, False: 376k]
  ------------------
  519|  2.52M|		sc_file_clear_acl_entries(file, operation);
  520|  2.52M|		file->acl[operation] = (sc_acl_entry_t *) 2;
  521|  2.52M|		return SC_SUCCESS;
  ------------------
  |  |   28|  2.52M|#define SC_SUCCESS				0
  ------------------
  522|  2.44k|	case SC_AC_UNKNOWN:
  ------------------
  |  |  162|  2.44k|#define SC_AC_UNKNOWN			0xFFFFFFFE
  ------------------
  |  Branch (522:2): [True: 2.44k, False: 2.89M]
  ------------------
  523|  2.44k|		sc_file_clear_acl_entries(file, operation);
  524|  2.44k|		file->acl[operation] = (sc_acl_entry_t *) 3;
  525|  2.44k|		return SC_SUCCESS;
  ------------------
  |  |   28|  2.44k|#define SC_SUCCESS				0
  ------------------
  526|   234k|	default:
  ------------------
  |  Branch (526:2): [True: 234k, False: 2.66M]
  ------------------
  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|   234k|		if (file->acl[operation] == (sc_acl_entry_t *) 1)
  ------------------
  |  Branch (530:7): [True: 8, False: 234k]
  ------------------
  531|      8|			return SC_SUCCESS;
  ------------------
  |  |   28|      8|#define SC_SUCCESS				0
  ------------------
  532|   234k|		if (file->acl[operation] == (sc_acl_entry_t *) 2
  ------------------
  |  Branch (532:7): [True: 6.87k, False: 227k]
  ------------------
  533|   227k|		 || file->acl[operation] == (sc_acl_entry_t *) 3)
  ------------------
  |  Branch (533:7): [True: 10, False: 227k]
  ------------------
  534|  6.88k|			file->acl[operation] = NULL;
  535|  2.89M|	}
  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|   358k|	for (p = file->acl[operation]; p != NULL; p = p->next) {
  ------------------
  |  Branch (539:33): [True: 127k, False: 231k]
  ------------------
  540|   127k|		if ((p->method == method) && (p->key_ref == key_ref))
  ------------------
  |  Branch (540:7): [True: 126k, False: 1.42k]
  |  Branch (540:32): [True: 2.97k, False: 123k]
  ------------------
  541|  2.97k|			return SC_SUCCESS;
  ------------------
  |  |   28|  2.97k|#define SC_SUCCESS				0
  ------------------
  542|   127k|	}
  543|       |
  544|   231k|	_new = malloc(sizeof(sc_acl_entry_t));
  545|   231k|	if (_new == NULL)
  ------------------
  |  Branch (545:6): [True: 0, False: 231k]
  ------------------
  546|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  547|   231k|	_new->method = method;
  548|   231k|	_new->key_ref = (unsigned)key_ref;
  549|   231k|	_new->next = NULL;
  550|       |
  551|   231k|	p = file->acl[operation];
  552|   231k|	if (p == NULL) {
  ------------------
  |  Branch (552:6): [True: 200k, False: 30.4k]
  ------------------
  553|   200k|		file->acl[operation] = _new;
  554|   200k|		return SC_SUCCESS;
  ------------------
  |  |   28|   200k|#define SC_SUCCESS				0
  ------------------
  555|   200k|	}
  556|   124k|	while (p->next != NULL)
  ------------------
  |  Branch (556:9): [True: 93.7k, False: 30.4k]
  ------------------
  557|  93.7k|		p = p->next;
  558|  30.4k|	p->next = _new;
  559|       |
  560|  30.4k|	return SC_SUCCESS;
  ------------------
  |  |   28|  30.4k|#define SC_SUCCESS				0
  ------------------
  561|   231k|}
sc_file_get_acl_entry:
  565|  1.13M|{
  566|  1.13M|	sc_acl_entry_t *p;
  567|  1.13M|	static const sc_acl_entry_t e_never = {
  568|  1.13M|		SC_AC_NEVER, SC_AC_KEY_REF_NONE, NULL
  ------------------
  |  |  163|  1.13M|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
              		SC_AC_NEVER, SC_AC_KEY_REF_NONE, NULL
  ------------------
  |  |  204|  1.13M|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  569|  1.13M|	};
  570|  1.13M|	static const sc_acl_entry_t e_none = {
  571|  1.13M|		SC_AC_NONE, SC_AC_KEY_REF_NONE, NULL
  ------------------
  |  |  150|  1.13M|#define SC_AC_NONE			0x00000000
  ------------------
              		SC_AC_NONE, SC_AC_KEY_REF_NONE, NULL
  ------------------
  |  |  204|  1.13M|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  572|  1.13M|	};
  573|  1.13M|	static const sc_acl_entry_t e_unknown = {
  574|  1.13M|		SC_AC_UNKNOWN, SC_AC_KEY_REF_NONE, NULL
  ------------------
  |  |  162|  1.13M|#define SC_AC_UNKNOWN			0xFFFFFFFE
  ------------------
              		SC_AC_UNKNOWN, SC_AC_KEY_REF_NONE, NULL
  ------------------
  |  |  204|  1.13M|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  575|  1.13M|	};
  576|       |
  577|  1.13M|	if (file == NULL || operation >= SC_MAX_AC_OPS) {
  ------------------
  |  |  198|  1.13M|#define SC_MAX_AC_OPS			31
  ------------------
  |  Branch (577:6): [True: 1, False: 1.13M]
  |  Branch (577:22): [True: 17, False: 1.13M]
  ------------------
  578|     18|		return NULL;
  579|     18|	}
  580|       |
  581|  1.13M|	p = file->acl[operation];
  582|  1.13M|	if (p == (sc_acl_entry_t *) 1)
  ------------------
  |  Branch (582:6): [True: 50.6k, False: 1.08M]
  ------------------
  583|  50.6k|		return &e_never;
  584|  1.08M|	if (p == (sc_acl_entry_t *) 2)
  ------------------
  |  Branch (584:6): [True: 634k, False: 451k]
  ------------------
  585|   634k|		return &e_none;
  586|   451k|	if (p == (sc_acl_entry_t *) 3)
  ------------------
  |  Branch (586:6): [True: 1.03k, False: 450k]
  ------------------
  587|  1.03k|		return &e_unknown;
  588|       |
  589|   450k|	return file->acl[operation];
  590|   451k|}
sc_file_clear_acl_entries:
  593|  8.76M|{
  594|  8.76M|	sc_acl_entry_t *e;
  595|       |
  596|  8.76M|	if (file == NULL || operation >= SC_MAX_AC_OPS) {
  ------------------
  |  |  198|  8.76M|#define SC_MAX_AC_OPS			31
  ------------------
  |  Branch (596:6): [True: 0, False: 8.76M]
  |  Branch (596:22): [True: 0, False: 8.76M]
  ------------------
  597|      0|		return;
  598|      0|	}
  599|       |
  600|  8.76M|	e = file->acl[operation];
  601|  8.76M|	if (e == (sc_acl_entry_t *) 1 ||
  ------------------
  |  Branch (601:6): [True: 139k, False: 8.62M]
  ------------------
  602|  8.62M|	    e == (sc_acl_entry_t *) 2 ||
  ------------------
  |  Branch (602:6): [True: 2.51M, False: 6.11M]
  ------------------
  603|  6.11M|	    e == (sc_acl_entry_t *) 3) {
  ------------------
  |  Branch (603:6): [True: 2.43k, False: 6.11M]
  ------------------
  604|  2.65M|		file->acl[operation] = NULL;
  605|  2.65M|		return;
  606|  2.65M|	}
  607|       |
  608|  6.34M|	while (e != NULL) {
  ------------------
  |  Branch (608:9): [True: 231k, False: 6.11M]
  ------------------
  609|   231k|		sc_acl_entry_t *tmp = e->next;
  610|   231k|		free(e);
  611|   231k|		e = tmp;
  612|   231k|	}
  613|       |	file->acl[operation] = NULL;
  614|  6.11M|}
sc_file_new:
  617|   193k|{
  618|   193k|	sc_file_t *file = (sc_file_t *)calloc(1, sizeof(sc_file_t));
  619|   193k|	if (file == NULL)
  ------------------
  |  Branch (619:6): [True: 0, False: 193k]
  ------------------
  620|      0|		return NULL;
  621|       |
  622|   193k|	file->magic = SC_FILE_MAGIC;
  ------------------
  |  |   57|   193k|#define SC_FILE_MAGIC			0x14426950
  ------------------
  623|   193k|	return file;
  624|   193k|}
sc_file_free:
  627|   395k|{
  628|   395k|	unsigned int i;
  629|   395k|	if (file == NULL || !sc_file_valid(file))
  ------------------
  |  Branch (629:6): [True: 202k, False: 193k]
  |  Branch (629:22): [True: 0, False: 193k]
  ------------------
  630|   202k|		return;
  631|   193k|	file->magic = 0;
  632|  6.18M|	for (i = 0; i < SC_MAX_AC_OPS; i++)
  ------------------
  |  |  198|  6.18M|#define SC_MAX_AC_OPS			31
  ------------------
  |  Branch (632:14): [True: 5.98M, False: 193k]
  ------------------
  633|  5.98M|		sc_file_clear_acl_entries(file, i);
  634|   193k|	if (file->sec_attr)
  ------------------
  |  Branch (634:6): [True: 6.08k, False: 187k]
  ------------------
  635|  6.08k|		free(file->sec_attr);
  636|   193k|	if (file->prop_attr)
  ------------------
  |  Branch (636:6): [True: 5.33k, False: 187k]
  ------------------
  637|  5.33k|		free(file->prop_attr);
  638|   193k|	if (file->type_attr)
  ------------------
  |  Branch (638:6): [True: 9.46k, False: 183k]
  ------------------
  639|  9.46k|		free(file->type_attr);
  640|   193k|	if (file->encoded_content)
  ------------------
  |  Branch (640:6): [True: 1.01k, False: 192k]
  ------------------
  641|  1.01k|		free(file->encoded_content);
  642|   193k|	free(file);
  643|   193k|}
sc_file_dup:
  646|  30.4k|{
  647|  30.4k|	sc_file_t *newf;
  648|  30.4k|	const sc_acl_entry_t *e;
  649|  30.4k|	unsigned int op;
  650|       |
  651|  30.4k|	if (!dest)
  ------------------
  |  Branch (651:6): [True: 0, False: 30.4k]
  ------------------
  652|      0|		return;
  653|  30.4k|	*dest = NULL;
  654|  30.4k|	if (!sc_file_valid(src))
  ------------------
  |  Branch (654:6): [True: 0, False: 30.4k]
  ------------------
  655|      0|		return;
  656|  30.4k|	newf = sc_file_new();
  657|  30.4k|	if (newf == NULL)
  ------------------
  |  Branch (657:6): [True: 0, False: 30.4k]
  ------------------
  658|      0|		return;
  659|  30.4k|	*dest = newf;
  660|       |
  661|  30.4k|	memcpy(&newf->path, &src->path, sizeof(struct sc_path));
  662|  30.4k|	memcpy(&newf->name, &src->name, sizeof(src->name));
  663|  30.4k|	newf->namelen = src->namelen;
  664|  30.4k|	newf->type    = src->type;
  665|  30.4k|	newf->shareable    = src->shareable;
  666|  30.4k|	newf->ef_structure = src->ef_structure;
  667|  30.4k|	newf->size    = src->size;
  668|  30.4k|	newf->id      = src->id;
  669|  30.4k|	newf->status  = src->status;
  670|   973k|	for (op = 0; op < SC_MAX_AC_OPS; op++) {
  ------------------
  |  |  198|   973k|#define SC_MAX_AC_OPS			31
  ------------------
  |  Branch (670:15): [True: 942k, False: 30.4k]
  ------------------
  671|   942k|		newf->acl[op] = NULL;
  672|   942k|		e = sc_file_get_acl_entry(src, op);
  673|   942k|		if (e != NULL) {
  ------------------
  |  Branch (673:7): [True: 542k, False: 400k]
  ------------------
  674|   542k|			if (sc_file_add_acl_entry(newf, op, e->method, e->key_ref) < 0)
  ------------------
  |  Branch (674:8): [True: 0, False: 542k]
  ------------------
  675|      0|				goto err;
  676|   542k|		}
  677|   942k|	}
  678|  30.4k|	newf->record_length = src->record_length;
  679|  30.4k|	newf->record_count  = src->record_count;
  680|       |
  681|  30.4k|	if (sc_file_set_sec_attr(newf, src->sec_attr, src->sec_attr_len) < 0)
  ------------------
  |  Branch (681:6): [True: 0, False: 30.4k]
  ------------------
  682|      0|		goto err;
  683|  30.4k|	if (sc_file_set_prop_attr(newf, src->prop_attr, src->prop_attr_len) < 0)
  ------------------
  |  Branch (683:6): [True: 0, False: 30.4k]
  ------------------
  684|      0|		goto err;
  685|  30.4k|	if (sc_file_set_type_attr(newf, src->type_attr, src->type_attr_len) < 0)
  ------------------
  |  Branch (685:6): [True: 0, False: 30.4k]
  ------------------
  686|      0|		goto err;
  687|  30.4k|	if (sc_file_set_content(newf, src->encoded_content, src->encoded_content_len) < 0)
  ------------------
  |  Branch (687:6): [True: 0, False: 30.4k]
  ------------------
  688|      0|		goto err;
  689|  30.4k|	return;
  690|  30.4k|err:
  691|      0|	sc_file_free(newf);
  692|       |	*dest = NULL;
  693|      0|}
sc_file_set_sec_attr:
  697|  36.5k|{
  698|  36.5k|	u8 *tmp;
  699|  36.5k|	if (!sc_file_valid(file)) {
  ------------------
  |  Branch (699:6): [True: 0, False: 36.5k]
  ------------------
  700|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  701|      0|	}
  702|       |
  703|  36.5k|	if (sec_attr == NULL || sec_attr_len == 0) {
  ------------------
  |  Branch (703:6): [True: 30.3k, False: 6.20k]
  |  Branch (703:26): [True: 56, False: 6.15k]
  ------------------
  704|  30.4k|		if (file->sec_attr != NULL)
  ------------------
  |  Branch (704:7): [True: 22, False: 30.3k]
  ------------------
  705|     22|			free(file->sec_attr);
  706|  30.4k|		file->sec_attr = NULL;
  707|  30.4k|		file->sec_attr_len = 0;
  708|  30.4k|		return 0;
  709|  30.4k|	 }
  710|  6.15k|	tmp = (u8 *) realloc(file->sec_attr, sec_attr_len);
  711|  6.15k|	if (!tmp) {
  ------------------
  |  Branch (711:6): [True: 0, False: 6.15k]
  ------------------
  712|      0|		if (file->sec_attr)
  ------------------
  |  Branch (712:7): [True: 0, False: 0]
  ------------------
  713|      0|			free(file->sec_attr);
  714|      0|		file->sec_attr     = NULL;
  715|      0|		file->sec_attr_len = 0;
  716|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  717|      0|	}
  718|  6.15k|	file->sec_attr = tmp;
  719|  6.15k|	memcpy(file->sec_attr, sec_attr, sec_attr_len);
  720|  6.15k|	file->sec_attr_len = sec_attr_len;
  721|       |
  722|  6.15k|	return 0;
  723|  6.15k|}
sc_file_set_prop_attr:
  727|  35.9k|{
  728|  35.9k|	u8 *tmp;
  729|  35.9k|	if (!sc_file_valid(file)) {
  ------------------
  |  Branch (729:6): [True: 0, False: 35.9k]
  ------------------
  730|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  731|      0|	}
  732|       |
  733|  35.9k|	if (prop_attr == NULL || prop_attr_len == 0) {
  ------------------
  |  Branch (733:6): [True: 30.3k, False: 5.58k]
  |  Branch (733:27): [True: 202, False: 5.37k]
  ------------------
  734|  30.5k|		if (file->prop_attr != NULL)
  ------------------
  |  Branch (734:7): [True: 26, False: 30.5k]
  ------------------
  735|     26|			free(file->prop_attr);
  736|  30.5k|		file->prop_attr = NULL;
  737|  30.5k|		file->prop_attr_len = 0;
  738|  30.5k|		return SC_SUCCESS;
  ------------------
  |  |   28|  30.5k|#define SC_SUCCESS				0
  ------------------
  739|  30.5k|	 }
  740|  5.37k|	tmp = (u8 *) realloc(file->prop_attr, prop_attr_len);
  741|  5.37k|	if (!tmp) {
  ------------------
  |  Branch (741:6): [True: 0, False: 5.37k]
  ------------------
  742|      0|		if (file->prop_attr)
  ------------------
  |  Branch (742:7): [True: 0, False: 0]
  ------------------
  743|      0|			free(file->prop_attr);
  744|      0|		file->prop_attr = NULL;
  745|      0|		file->prop_attr_len = 0;
  746|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  747|      0|	}
  748|  5.37k|	file->prop_attr = tmp;
  749|  5.37k|	memcpy(file->prop_attr, prop_attr, prop_attr_len);
  750|  5.37k|	file->prop_attr_len = prop_attr_len;
  751|       |
  752|  5.37k|	return SC_SUCCESS;
  ------------------
  |  |   28|  5.37k|#define SC_SUCCESS				0
  ------------------
  753|  5.37k|}
sc_file_set_type_attr:
  757|  37.7k|{
  758|  37.7k|	u8 *tmp;
  759|  37.7k|	if (!sc_file_valid(file)) {
  ------------------
  |  Branch (759:6): [True: 0, False: 37.7k]
  ------------------
  760|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  761|      0|	}
  762|       |
  763|  37.7k|	if (type_attr == NULL || type_attr_len == 0) {
  ------------------
  |  Branch (763:6): [True: 28.1k, False: 9.59k]
  |  Branch (763:27): [True: 0, False: 9.59k]
  ------------------
  764|  28.1k|		if (file->type_attr != NULL)
  ------------------
  |  Branch (764:7): [True: 0, False: 28.1k]
  ------------------
  765|      0|			free(file->type_attr);
  766|  28.1k|		file->type_attr = NULL;
  767|  28.1k|		file->type_attr_len = 0;
  768|  28.1k|		return SC_SUCCESS;
  ------------------
  |  |   28|  28.1k|#define SC_SUCCESS				0
  ------------------
  769|  28.1k|	 }
  770|  9.59k|	tmp = (u8 *) realloc(file->type_attr, type_attr_len);
  771|  9.59k|	if (!tmp) {
  ------------------
  |  Branch (771:6): [True: 0, False: 9.59k]
  ------------------
  772|      0|		if (file->type_attr)
  ------------------
  |  Branch (772:7): [True: 0, False: 0]
  ------------------
  773|      0|			free(file->type_attr);
  774|      0|		file->type_attr = NULL;
  775|      0|		file->type_attr_len = 0;
  776|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  777|      0|	}
  778|  9.59k|	file->type_attr = tmp;
  779|  9.59k|	memcpy(file->type_attr, type_attr, type_attr_len);
  780|  9.59k|	file->type_attr_len = type_attr_len;
  781|       |
  782|  9.59k|	return SC_SUCCESS;
  ------------------
  |  |   28|  9.59k|#define SC_SUCCESS				0
  ------------------
  783|  9.59k|}
sc_file_set_content:
  788|  30.4k|{
  789|  30.4k|	u8 *tmp;
  790|  30.4k|	if (!sc_file_valid(file)) {
  ------------------
  |  Branch (790:6): [True: 0, False: 30.4k]
  ------------------
  791|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  792|      0|	}
  793|       |
  794|  30.4k|	if (content == NULL || content_len == 0) {
  ------------------
  |  Branch (794:6): [True: 29.1k, False: 1.30k]
  |  Branch (794:25): [True: 517, False: 783]
  ------------------
  795|  29.6k|		if (file->encoded_content != NULL)
  ------------------
  |  Branch (795:7): [True: 0, False: 29.6k]
  ------------------
  796|      0|			free(file->encoded_content);
  797|  29.6k|		file->encoded_content = NULL;
  798|  29.6k|		file->encoded_content_len = 0;
  799|  29.6k|		return SC_SUCCESS;
  ------------------
  |  |   28|  29.6k|#define SC_SUCCESS				0
  ------------------
  800|  29.6k|	}
  801|       |
  802|    783|	tmp = (u8 *) realloc(file->encoded_content, content_len);
  803|    783|	if (!tmp) {
  ------------------
  |  Branch (803:6): [True: 0, False: 783]
  ------------------
  804|      0|		if (file->encoded_content)
  ------------------
  |  Branch (804:7): [True: 0, False: 0]
  ------------------
  805|      0|			free(file->encoded_content);
  806|      0|		file->encoded_content = NULL;
  807|      0|		file->encoded_content_len = 0;
  808|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  809|      0|	}
  810|       |
  811|    783|	file->encoded_content = tmp;
  812|    783|	memcpy(file->encoded_content, content, content_len);
  813|    783|	file->encoded_content_len = content_len;
  814|       |
  815|    783|	return SC_SUCCESS;
  ------------------
  |  |   28|    783|#define SC_SUCCESS				0
  ------------------
  816|    783|}
sc_file_valid:
  819|   364k|int sc_file_valid(const sc_file_t *file) {
  820|   364k|	if (file == NULL)
  ------------------
  |  Branch (820:6): [True: 0, False: 364k]
  ------------------
  821|      0|		return 0;
  822|   364k|	return file->magic == SC_FILE_MAGIC;
  ------------------
  |  |   57|   364k|#define SC_FILE_MAGIC			0x14426950
  ------------------
  823|   364k|}
_sc_parse_atr:
  826|  16.3k|{
  827|  16.3k|	u8 *p = reader->atr.value;
  828|  16.3k|	int atr_len = (int) reader->atr.len;
  829|  16.3k|	int n_hist, x;
  830|  16.3k|	int tx[4] = {-1, -1, -1, -1};
  831|  16.3k|	int i, FI, DI;
  832|  16.3k|	const int Fi_table[] = {
  833|  16.3k|		372, 372, 558, 744, 1116, 1488, 1860, -1,
  834|  16.3k|		-1, 512, 768, 1024, 1536, 2048, -1, -1 };
  835|  16.3k|	const int f_table[] = {
  836|  16.3k|		40, 50, 60, 80, 120, 160, 200, -1,
  837|  16.3k|		-1, 50, 75, 100, 150, 200, -1, -1 };
  838|  16.3k|	const int Di_table[] = {
  839|  16.3k|		-1, 1, 2, 4, 8, 16, 32, -1,
  840|  16.3k|		12, 20, -1, -1, -1, -1, -1, -1 };
  841|       |
  842|  16.3k|	reader->atr_info.hist_bytes_len = 0;
  843|  16.3k|	reader->atr_info.hist_bytes = NULL;
  844|       |
  845|  16.3k|	if (atr_len == 0) {
  ------------------
  |  Branch (845:6): [True: 5.99k, False: 10.3k]
  ------------------
  846|  5.99k|		sc_log(reader->ctx, "empty ATR - card not present?\n");
  ------------------
  |  |   71|  5.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__
  |  |  ------------------
  ------------------
  847|  5.99k|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|  5.99k|#define SC_ERROR_INTERNAL			-1400
  ------------------
  848|  5.99k|	}
  849|       |
  850|  10.3k|	if (p[0] != 0x3B && p[0] != 0x3F) {
  ------------------
  |  Branch (850:6): [True: 1.60k, False: 8.76k]
  |  Branch (850:22): [True: 1.43k, False: 169]
  ------------------
  851|  1.43k|		sc_log(reader->ctx, "invalid sync byte in ATR: 0x%02X\n", p[0]);
  ------------------
  |  |   71|  1.43k|#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.43k|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|  1.43k|#define SC_ERROR_INTERNAL			-1400
  ------------------
  853|  1.43k|	}
  854|  8.92k|	n_hist = p[1] & 0x0F;
  855|  8.92k|	x = p[1] >> 4;
  856|  8.92k|	p += 2;
  857|  8.92k|	atr_len -= 2;
  858|  44.5k|	for (i = 0; i < 4 && atr_len > 0; i++) {
  ------------------
  |  Branch (858:14): [True: 35.6k, False: 8.90k]
  |  Branch (858:23): [True: 35.6k, False: 26]
  ------------------
  859|  35.6k|                if (x & (1 << i)) {
  ------------------
  |  Branch (859:21): [True: 23.4k, False: 12.2k]
  ------------------
  860|  23.4k|                        tx[i] = *p;
  861|  23.4k|                        p++;
  862|  23.4k|                        atr_len--;
  863|  23.4k|                } else
  864|  12.2k|                        tx[i] = -1;
  865|  35.6k|        }
  866|  8.92k|	if (tx[0] >= 0) {
  ------------------
  |  Branch (866:6): [True: 7.60k, False: 1.32k]
  ------------------
  867|  7.60k|		reader->atr_info.FI = FI = tx[0] >> 4;
  868|  7.60k|		reader->atr_info.DI = DI = tx[0] & 0x0F;
  869|  7.60k|		reader->atr_info.Fi = Fi_table[FI];
  870|  7.60k|		reader->atr_info.f = f_table[FI];
  871|  7.60k|		reader->atr_info.Di = Di_table[DI];
  872|  7.60k|	} else {
  873|  1.32k|		reader->atr_info.Fi = -1;
  874|  1.32k|		reader->atr_info.f = -1;
  875|  1.32k|		reader->atr_info.Di = -1;
  876|  1.32k|	}
  877|  8.92k|	if (tx[2] >= 0)
  ------------------
  |  Branch (877:6): [True: 5.91k, False: 3.01k]
  ------------------
  878|  5.91k|		reader->atr_info.N = tx[3];
  879|  3.01k|	else
  880|  3.01k|		reader->atr_info.N = -1;
  881|  21.0k|	while (tx[3] > 0 && tx[3] & 0xF0 && atr_len > 0) {
  ------------------
  |  Branch (881:9): [True: 12.8k, False: 8.20k]
  |  Branch (881:22): [True: 12.1k, False: 684]
  |  Branch (881:38): [True: 12.0k, False: 45]
  ------------------
  882|  12.0k|		x = tx[3] >> 4;
  883|  60.3k|		for (i = 0; i < 4 && atr_len > 0; i++) {
  ------------------
  |  Branch (883:15): [True: 48.2k, False: 12.0k]
  |  Branch (883:24): [True: 48.2k, False: 24]
  ------------------
  884|  48.2k|	                if (x & (1 << i)) {
  ------------------
  |  Branch (884:22): [True: 18.9k, False: 29.2k]
  ------------------
  885|  18.9k|	                        tx[i] = *p;
  886|  18.9k|	                        p++;
  887|  18.9k|	                        atr_len--;
  888|  18.9k|	                } else
  889|  29.2k|	                        tx[i] = -1;
  890|  48.2k|		}
  891|  12.0k|	}
  892|  8.92k|	if (atr_len <= 0)
  ------------------
  |  Branch (892:6): [True: 87, False: 8.84k]
  ------------------
  893|     87|		return SC_SUCCESS;
  ------------------
  |  |   28|     87|#define SC_SUCCESS				0
  ------------------
  894|  8.84k|	if (n_hist > atr_len)
  ------------------
  |  Branch (894:6): [True: 341, False: 8.50k]
  ------------------
  895|    341|		n_hist = atr_len;
  896|  8.84k|	reader->atr_info.hist_bytes_len = n_hist;
  897|  8.84k|	reader->atr_info.hist_bytes = p;
  898|  8.84k|	return SC_SUCCESS;
  ------------------
  |  |   28|  8.84k|#define SC_SUCCESS				0
  ------------------
  899|  8.92k|}
sc_mem_secure_alloc:
  902|     94|{
  903|     94|	void *p;
  904|       |
  905|       |#ifdef _WIN32
  906|       |	p = VirtualAlloc(NULL, len, MEM_COMMIT, PAGE_READWRITE);
  907|       |	if (p != NULL) {
  908|       |		VirtualLock(p, len);
  909|       |	}
  910|       |#else
  911|     94|	p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
  912|     94|	if (p != NULL) {
  ------------------
  |  Branch (912:6): [True: 94, False: 0]
  ------------------
  913|     94|		mlock(p, len);
  914|     94|	}
  915|     94|#endif
  916|       |
  917|     94|	return p;
  918|     94|}
sc_mem_secure_free:
  921|     94|{
  922|       |#ifdef _WIN32
  923|       |	VirtualUnlock(ptr, len);
  924|       |	VirtualFree(ptr, 0, MEM_RELEASE);
  925|       |#else
  926|     94|	munlock(ptr, len);
  927|     94|	munmap(ptr, len);
  928|     94|#endif
  929|     94|}
sc_mem_clear:
  932|  53.1k|{
  933|  53.1k|	if (len > 0)   {
  ------------------
  |  Branch (933:6): [True: 53.1k, False: 0]
  ------------------
  934|       |#ifdef HAVE_MEMSET_S
  935|       |		memset_s(ptr, len, 0, len);
  936|       |#elif _WIN32
  937|       |		SecureZeroMemory(ptr, len);
  938|       |#elif HAVE_EXPLICIT_BZERO
  939|       |		explicit_bzero(ptr, len);
  940|       |#elif ENABLE_OPENSSL
  941|       |		OPENSSL_cleanse(ptr, len);
  942|       |#else
  943|       |		memset(ptr, 0, len);
  944|       |#endif
  945|  53.1k|	}
  946|  53.1k|}
sc_compacttlv_find_tag:
 1060|    431|{
 1061|    431|	if (buf != NULL) {
  ------------------
  |  Branch (1061:6): [True: 431, False: 0]
  ------------------
 1062|    431|		size_t idx;
 1063|    431|		u8 plain_tag = tag & 0xF0;
 1064|    431|		size_t expected_len = tag & 0x0F;
 1065|       |
 1066|  9.62k|		for (idx = 0; idx < len; idx++) {
  ------------------
  |  Branch (1066:17): [True: 9.37k, False: 254]
  ------------------
 1067|  9.37k|			u8 ctag = buf[idx] & 0xF0;
 1068|  9.37k|			size_t ctag_len = buf[idx] & 0x0F;
 1069|  9.37k|			if (ctag == plain_tag && idx + ctag_len < len &&
  ------------------
  |  Branch (1069:8): [True: 783, False: 8.58k]
  |  Branch (1069:29): [True: 772, False: 11]
  ------------------
 1070|    772|					(expected_len == 0 || expected_len == ctag_len)) {
  ------------------
  |  Branch (1070:7): [True: 88, False: 684]
  |  Branch (1070:28): [True: 89, False: 595]
  ------------------
 1071|    177|				if (outlen != NULL)
  ------------------
  |  Branch (1071:9): [True: 88, False: 89]
  ------------------
 1072|     88|					*outlen = ctag_len;
 1073|    177|				return buf + (idx + 1);
 1074|    177|			}
 1075|  9.19k|			idx += ctag_len;
 1076|  9.19k|		}
 1077|    431|	}
 1078|    254|	return NULL;
 1079|    431|}
sc_mutex_create:
 1084|  32.7k|{
 1085|  32.7k|	if (ctx == NULL)
  ------------------
  |  Branch (1085:6): [True: 0, False: 32.7k]
  ------------------
 1086|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1087|  32.7k|	if (ctx->thread_ctx != NULL && ctx->thread_ctx->create_mutex != NULL)
  ------------------
  |  Branch (1087:6): [True: 0, False: 32.7k]
  |  Branch (1087:33): [True: 0, False: 0]
  ------------------
 1088|      0|		return ctx->thread_ctx->create_mutex(mutex);
 1089|  32.7k|	else
 1090|  32.7k|		return SC_SUCCESS;
  ------------------
  |  |   28|  32.7k|#define SC_SUCCESS				0
  ------------------
 1091|  32.7k|}
sc_mutex_lock:
 1094|  1.55M|{
 1095|  1.55M|	if (ctx == NULL)
  ------------------
  |  Branch (1095:6): [True: 0, False: 1.55M]
  ------------------
 1096|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1097|  1.55M|	if (ctx->thread_ctx != NULL && ctx->thread_ctx->lock_mutex != NULL)
  ------------------
  |  Branch (1097:6): [True: 0, False: 1.55M]
  |  Branch (1097:33): [True: 0, False: 0]
  ------------------
 1098|      0|		return ctx->thread_ctx->lock_mutex(mutex);
 1099|  1.55M|	else
 1100|  1.55M|		return SC_SUCCESS;
  ------------------
  |  |   28|  1.55M|#define SC_SUCCESS				0
  ------------------
 1101|  1.55M|}
sc_mutex_unlock:
 1104|  1.55M|{
 1105|  1.55M|	if (ctx == NULL)
  ------------------
  |  Branch (1105:6): [True: 0, False: 1.55M]
  ------------------
 1106|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1107|  1.55M|	if (ctx->thread_ctx != NULL && ctx->thread_ctx->unlock_mutex != NULL)
  ------------------
  |  Branch (1107:6): [True: 0, False: 1.55M]
  |  Branch (1107:33): [True: 0, False: 0]
  ------------------
 1108|      0|		return ctx->thread_ctx->unlock_mutex(mutex);
 1109|  1.55M|	else
 1110|  1.55M|		return SC_SUCCESS;
  ------------------
  |  |   28|  1.55M|#define SC_SUCCESS				0
  ------------------
 1111|  1.55M|}

sc_verify:
  131|    683|{
  132|    683|	struct sc_pin_cmd_data data;
  133|       |
  134|    683|	memset(&data, 0, sizeof(data));
  135|    683|	data.cmd = SC_PIN_CMD_VERIFY;
  ------------------
  |  |  415|    683|#define SC_PIN_CMD_VERIFY	0
  ------------------
  136|    683|	data.pin_type = type;
  137|    683|	data.pin_reference = ref;
  138|    683|	data.pin1.data = pin;
  139|    683|	data.pin1.len = pinlen;
  140|       |
  141|    683|	int r = sc_pin_cmd(card, &data);
  142|    683|	if (tries_left)
  ------------------
  |  Branch (142:6): [True: 683, False: 0]
  ------------------
  143|    683|		*tries_left = data.pin1.tries_left;
  144|       |
  145|    683|	return r;
  146|    683|}
sc_change_reference_data:
  159|    155|{
  160|    155|	struct sc_pin_cmd_data data;
  161|       |
  162|    155|	memset(&data, 0, sizeof(data));
  163|    155|	data.cmd = SC_PIN_CMD_CHANGE;
  ------------------
  |  |  416|    155|#define SC_PIN_CMD_CHANGE	1
  ------------------
  164|    155|	data.pin_type = type;
  165|    155|	data.pin_reference = ref;
  166|    155|	data.pin1.data = old;
  167|    155|	data.pin1.len = oldlen;
  168|    155|	data.pin2.data = newref;
  169|    155|	data.pin2.len = newlen;
  170|       |
  171|    155|	int r = sc_pin_cmd(card, &data);
  172|    155|	if (tries_left)
  ------------------
  |  Branch (172:6): [True: 0, False: 155]
  ------------------
  173|      0|		*tries_left = data.pin1.tries_left;
  174|       |
  175|    155|	return r;
  176|    155|}
sc_pin_cmd:
  204|  4.02k|{
  205|  4.02k|	int r, debug;
  206|       |
  207|  4.02k|	if (card == NULL) {
  ------------------
  |  Branch (207:6): [True: 0, False: 4.02k]
  ------------------
  208|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  209|      0|	}
  210|  4.02k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  4.02k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  4.02k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  4.02k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  4.02k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 4.02k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  211|       |
  212|  4.02k|	debug = card->ctx->debug;
  213|  4.02k|	if (data->cmd != SC_PIN_CMD_GET_INFO
  ------------------
  |  |  418|  8.04k|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (213:6): [True: 891, False: 3.13k]
  ------------------
  214|    891|			&& card->ctx->debug < SC_LOG_DEBUG_PIN) {
  ------------------
  |  Branch (214:7): [True: 891, False: 0]
  ------------------
  215|    891|		card->ctx->debug = 0;
  216|    891|	}
  217|       |
  218|  4.02k|	if (card->ops->pin_cmd) {
  ------------------
  |  Branch (218:6): [True: 4.02k, False: 0]
  ------------------
  219|  4.02k|		r = card->ops->pin_cmd(card, data);
  220|  4.02k|	} else if (!(data->flags & SC_PIN_CMD_USE_PINPAD)) {
  ------------------
  |  |  421|      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:
  ------------------
  |  |  415|      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:
  ------------------
  |  |  416|      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:
  ------------------
  |  |  417|      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|  4.02k|	card->ctx->debug = debug;
  265|       |
  266|  4.02k|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|  4.02k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  4.02k|	int _ret = r; \
  |  |  155|  4.02k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 4.02k, False: 0]
  |  |  ------------------
  |  |  156|  4.02k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|  2.57k|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 2.57k, False: 1.44k]
  |  |  ------------------
  |  |  157|  4.02k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|  4.02k|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|  4.02k|	return _ret; \
  |  |  163|  4.02k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  267|  4.02k|}
sc_build_pin:
  281|    179|{
  282|    179|	size_t i = 0, j, pin_len = pin->len;
  283|       |
  284|    179|	if (pin->max_length && pin_len > pin->max_length)
  ------------------
  |  Branch (284:6): [True: 21, False: 158]
  |  Branch (284:25): [True: 0, False: 21]
  ------------------
  285|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  286|       |
  287|    179|	if (pin->encoding == SC_PIN_ENCODING_GLP) {
  ------------------
  |  |  427|    179|#define SC_PIN_ENCODING_GLP	2 /* Global Platform - Card Specification v2.0.1 */
  ------------------
  |  Branch (287:6): [True: 0, False: 179]
  ------------------
  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|    179|	if (pin->encoding == SC_PIN_ENCODING_ASCII) {
  ------------------
  |  |  425|    179|#define SC_PIN_ENCODING_ASCII	0
  ------------------
  |  Branch (302:6): [True: 179, False: 0]
  ------------------
  303|    179|		if (pin_len > buflen)
  ------------------
  |  Branch (303:7): [True: 0, False: 179]
  ------------------
  304|      0|			return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  305|    179|		memcpy(buf, pin->data, pin_len);
  306|    179|		i = pin_len;
  307|    179|	} else if (pin->encoding == SC_PIN_ENCODING_BCD || pin->encoding == SC_PIN_ENCODING_GLP) {
  ------------------
  |  |  426|      0|#define SC_PIN_ENCODING_BCD	1
  ------------------
              	} else if (pin->encoding == SC_PIN_ENCODING_BCD || pin->encoding == SC_PIN_ENCODING_GLP) {
  ------------------
  |  |  427|      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|    179|	if (pad || pin->encoding == SC_PIN_ENCODING_GLP) {
  ------------------
  |  |  427|    156|#define SC_PIN_ENCODING_GLP	2 /* Global Platform - Card Specification v2.0.1 */
  ------------------
  |  Branch (327:6): [True: 23, False: 156]
  |  Branch (327:13): [True: 0, False: 156]
  ------------------
  328|     23|		size_t pad_length = pin->pad_length;
  329|     23|		u8     pad_char   = pin->encoding == SC_PIN_ENCODING_GLP ? 0xFF : pin->pad_char;
  ------------------
  |  |  427|     23|#define SC_PIN_ENCODING_GLP	2 /* Global Platform - Card Specification v2.0.1 */
  ------------------
  |  Branch (329:23): [True: 0, False: 23]
  ------------------
  330|       |
  331|     23|		if (pin->encoding == SC_PIN_ENCODING_BCD)
  ------------------
  |  |  426|     23|#define SC_PIN_ENCODING_BCD	1
  ------------------
  |  Branch (331:7): [True: 0, False: 23]
  ------------------
  332|      0|			pad_length >>= 1;
  333|     23|		if (pin->encoding == SC_PIN_ENCODING_GLP)
  ------------------
  |  |  427|     23|#define SC_PIN_ENCODING_GLP	2 /* Global Platform - Card Specification v2.0.1 */
  ------------------
  |  Branch (333:7): [True: 0, False: 23]
  ------------------
  334|      0|			pad_length = 8;
  335|       |
  336|     23|		if (pad_length > buflen)
  ------------------
  |  Branch (336:7): [True: 0, False: 23]
  ------------------
  337|      0|			return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  338|       |
  339|     23|		if (pad_length && i < pad_length) {
  ------------------
  |  Branch (339:7): [True: 20, False: 3]
  |  Branch (339:21): [True: 10, False: 10]
  ------------------
  340|     10|			memset(buf + i, pad_char, pad_length - i);
  341|     10|			i = pad_length;
  342|     10|		}
  343|     23|	}
  344|       |
  345|    179|	return (int)i;
  346|    179|}

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

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

sc_pkcs15init_get_authentic_ops:
  925|    396|{
  926|    396|	return &sc_pkcs15init_authentic_operations;
  927|    396|}
pkcs15-authentic.c:authentic_pkcs15_erase_card:
  138|    288|{
  139|    288|	struct sc_context *ctx = p15card->card->ctx;
  140|    288|	struct sc_file  *file = NULL;
  141|    288|	struct sc_pkcs15_df *df;
  142|    288|	int rv;
  143|       |
  144|    288|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    288|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    288|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    288|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    288|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 288]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  145|       |
  146|    288|	if (p15card->file_odf)   {
  ------------------
  |  Branch (146:6): [True: 3, False: 285]
  ------------------
  147|      3|		sc_log(ctx, "Select ODF path: %s", sc_print_path(&p15card->file_odf->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__
  |  |  ------------------
  ------------------
  148|      3|		rv = sc_select_file(p15card->card, &p15card->file_odf->path, NULL);
  149|      3|		LOG_TEST_RET(ctx, rv, "Erase application error: cannot select ODF 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  150|      3|	}
  151|       |
  152|    413|	for (df = p15card->df_list; df; df = df->next)   {
  ------------------
  |  Branch (152:30): [True: 203, False: 210]
  ------------------
  153|    203|		struct sc_pkcs15_object *objs[32];
  154|    203|		unsigned obj_type = 0;
  155|    203|		int ii;
  156|       |
  157|    203|		if (df->type == SC_PKCS15_PRKDF)
  ------------------
  |  |  488|    203|#define SC_PKCS15_PRKDF			0
  ------------------
  |  Branch (157:7): [True: 32, False: 171]
  ------------------
  158|     32|			obj_type = SC_PKCS15_TYPE_PRKEY;
  ------------------
  |  |  418|     32|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  159|    171|		else if (df->type == SC_PKCS15_PUKDF)
  ------------------
  |  |  489|    171|#define SC_PKCS15_PUKDF			1
  ------------------
  |  Branch (159:12): [True: 0, False: 171]
  ------------------
  160|      0|			obj_type = SC_PKCS15_TYPE_PUBKEY;
  ------------------
  |  |  425|      0|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  161|    171|		else if (df->type == SC_PKCS15_CDF)
  ------------------
  |  |  492|    171|#define SC_PKCS15_CDF			4
  ------------------
  |  Branch (161:12): [True: 84, False: 87]
  ------------------
  162|     84|			obj_type = SC_PKCS15_TYPE_CERT;
  ------------------
  |  |  438|     84|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  163|     87|		else if (df->type == SC_PKCS15_DODF)
  ------------------
  |  |  495|     87|#define SC_PKCS15_DODF			7
  ------------------
  |  Branch (163:12): [True: 0, False: 87]
  ------------------
  164|      0|			obj_type = SC_PKCS15_TYPE_DATA_OBJECT;
  ------------------
  |  |  442|      0|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  165|     87|		else
  166|     87|			continue;
  167|       |
  168|    116|		if (df->enumerated)   {
  ------------------
  |  Branch (168:7): [True: 116, False: 0]
  ------------------
  169|    116|			rv = sc_pkcs15_get_objects(p15card, obj_type, objs, 32);
  170|    116|			LOG_TEST_RET(ctx, rv, "Failed to get PKCS#15 objects to remove");
  ------------------
  |  |  174|    116|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    116|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    116|	int _ret = (r); \
  |  |  |  |  168|    116|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 116]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|    116|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 116]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  171|       |
  172|    238|			for (ii=0; ii<rv; ii++) {
  ------------------
  |  Branch (172:15): [True: 122, False: 116]
  ------------------
  173|    122|				sc_pkcs15_remove_object(p15card, objs[ii]);
  174|    122|				sc_pkcs15_free_object(objs[ii]);
  175|    122|			}
  176|    116|		}
  177|       |
  178|    116|		rv = sc_select_file(p15card->card, &df->path, &file);
  179|    116|		if (rv == SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|    116|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (179:7): [True: 3, False: 113]
  ------------------
  180|      3|			continue;
  181|    113|		LOG_TEST_RET(ctx, rv, "Cannot select object data file");
  ------------------
  |  |  174|    113|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    113|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    113|	int _ret = (r); \
  |  |  |  |  168|    113|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 58, False: 55]
  |  |  |  |  ------------------
  |  |  |  |  169|     58|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     58|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     58|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     58|		return _ret; \
  |  |  |  |  172|     58|	} \
  |  |  |  |  173|    113|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 55]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  182|       |
  183|     55|		rv = sc_erase_binary(p15card->card, 0, file->size, 0);
  184|     55|		if (rv == SC_ERROR_SECURITY_STATUS_NOT_SATISFIED)   {
  ------------------
  |  |   61|     55|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
  |  Branch (184:7): [True: 3, False: 52]
  ------------------
  185|      3|			rv = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_UPDATE);
  ------------------
  |  |  189|      3|#define SC_AC_OP_UPDATE			23
  ------------------
  186|      3|			if (rv < 0)
  ------------------
  |  Branch (186:8): [True: 1, False: 2]
  ------------------
  187|      1|				sc_file_free(file);
  188|       |
  189|      3|			LOG_TEST_RET(ctx, rv, "'UPDATE' authentication 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  190|       |
  191|      2|			rv = sc_erase_binary(p15card->card, 0, file->size, 0);
  192|      2|		}
  193|       |
  194|     54|		sc_file_free(file);
  195|     54|		LOG_TEST_RET(ctx, rv, "Binary erase 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: 17, False: 37]
  |  |  |  |  ------------------
  |  |  |  |  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|     54|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 37]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  196|       |
  197|     37|		profile->dirty = 1;
  198|     37|	}
  199|       |
  200|    210|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    210|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    210|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    210|	int _ret = r; \
  |  |  |  |  155|    210|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 210, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    210|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 210]
  |  |  |  |  ------------------
  |  |  |  |  157|    210|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    210|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    210|	return _ret; \
  |  |  |  |  163|    210|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  201|    210|}
pkcs15-authentic.c:authentic_pkcs15_init_card:
  872|      5|{
  873|      5|	LOG_FUNC_RETURN(p15card->card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  874|      5|}
pkcs15-authentic.c:authentic_pkcs15_create_pin:
  890|    272|{
  891|    272|	LOG_FUNC_RETURN(p15card->card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|    272|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    272|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    272|	int _ret = r; \
  |  |  |  |  155|    272|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 272, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    272|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    272|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 272, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    272|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    272|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    272|	return _ret; \
  |  |  |  |  163|    272|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  892|    272|}
pkcs15-authentic.c:authentic_pkcs15_select_key_reference:
  269|    179|{
  270|    179|	struct sc_context *ctx = p15card->card->ctx;
  271|       |
  272|    179|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    179|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    179|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    179|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    179|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 179]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  273|       |
  274|       |	/* In authentic PKCS#15 all crypto objects are locals */
  275|    179|	key_info->key_reference |= AUTHENTIC_OBJECT_REF_FLAG_LOCAL;
  ------------------
  |  |   49|    179|#define AUTHENTIC_OBJECT_REF_FLAG_LOCAL	0x80
  ------------------
  276|       |
  277|    179|	if (key_info->key_reference > AUTHENTIC_V3_CRYPTO_OBJECT_REF_MAX)
  ------------------
  |  |   41|    179|#define AUTHENTIC_V3_CRYPTO_OBJECT_REF_MAX	0xFF
  ------------------
  |  Branch (277:6): [True: 0, False: 179]
  ------------------
  278|    179|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  279|       |
  280|    179|	if (key_info->key_reference < AUTHENTIC_V3_CRYPTO_OBJECT_REF_MIN)
  ------------------
  |  |   40|    179|#define AUTHENTIC_V3_CRYPTO_OBJECT_REF_MIN	0x81
  ------------------
  |  Branch (280:6): [True: 179, False: 0]
  ------------------
  281|    179|		key_info->key_reference = AUTHENTIC_V3_CRYPTO_OBJECT_REF_MIN;
  ------------------
  |  |   40|    179|#define AUTHENTIC_V3_CRYPTO_OBJECT_REF_MIN	0x81
  ------------------
  282|       |
  283|    179|	sc_log(ctx, "returns key reference %i", key_info->key_reference);
  ------------------
  |  |   71|    179|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  284|    179|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    179|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    179|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    179|	int _ret = r; \
  |  |  |  |  155|    179|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 179, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    179|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 179]
  |  |  |  |  ------------------
  |  |  |  |  157|    179|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    179|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    179|	return _ret; \
  |  |  |  |  163|    179|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  285|    179|}
pkcs15-authentic.c:authentic_pkcs15_create_key:
  517|    179|{
  518|    179|	struct sc_card *card = p15card->card;
  519|    179|	struct sc_context *ctx = card->ctx;
  520|    179|	struct sc_authentic_sdo *sdo = NULL;
  521|    179|	struct sc_pkcs15_prkey_info *key_info = (struct sc_pkcs15_prkey_info *) object->data;
  522|    179|	struct sc_file	*file_p_prvkey = NULL, *parent = NULL;
  523|    179|	size_t keybits = key_info->modulus_length;
  524|    179|	int	 rv;
  525|       |
  526|    179|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    179|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    179|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    179|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    179|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 179]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  527|    179|	sc_log(ctx, "create private key(keybits:%zu,usage:%X,access:%X,ref:%X)",
  ------------------
  |  |   71|    179|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  528|    179|			keybits, key_info->usage, key_info->access_flags, key_info->key_reference);
  529|    179|	if (keybits < 1024 || keybits > 2048 || (keybits % 256))
  ------------------
  |  Branch (529:6): [True: 0, False: 179]
  |  Branch (529:24): [True: 0, False: 179]
  |  Branch (529:42): [True: 0, False: 179]
  ------------------
  530|    179|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  531|       |
  532|    179|	rv = authentic_pkcs15_new_file(profile, card, SC_PKCS15_TYPE_PRKEY_RSA, key_info->key_reference, &file_p_prvkey);
  ------------------
  |  |  419|    179|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  533|    179|	LOG_TEST_RET(ctx, rv, "IasEcc pkcs15 new PRKEY_RSA file error");
  ------------------
  |  |  174|    179|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    179|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    179|	int _ret = (r); \
  |  |  |  |  168|    179|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 134, False: 45]
  |  |  |  |  ------------------
  |  |  |  |  169|    134|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    134|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    134|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    134|		return _ret; \
  |  |  |  |  172|    134|	} \
  |  |  |  |  173|    179|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 45]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  534|       |
  535|     45|	key_info->key_reference |= AUTHENTIC_OBJECT_REF_FLAG_LOCAL;
  ------------------
  |  |   49|     45|#define AUTHENTIC_OBJECT_REF_FLAG_LOCAL	0x80
  ------------------
  536|       |
  537|     45|	rv = sc_select_file(card, &file_p_prvkey->path, &parent);
  538|     45|	if (rv != SC_SUCCESS)
  ------------------
  |  |   28|     45|#define SC_SUCCESS				0
  ------------------
  |  Branch (538:6): [True: 6, False: 39]
  ------------------
  539|      6|		sc_file_free(file_p_prvkey);
  540|     45|	LOG_TEST_RET(ctx, rv, "DF for the private objects not defined");
  ------------------
  |  |  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: 6, False: 39]
  |  |  |  |  ------------------
  |  |  |  |  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|     45|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 39]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  541|       |
  542|     39|	rv = sc_pkcs15init_authenticate(profile, p15card, parent, SC_AC_OP_CRYPTO);
  ------------------
  |  |  173|     39|#define SC_AC_OP_CRYPTO			7
  ------------------
  543|     39|	sc_file_free(parent);
  544|     39|	if (rv != SC_SUCCESS)
  ------------------
  |  |   28|     39|#define SC_SUCCESS				0
  ------------------
  |  Branch (544:6): [True: 1, False: 38]
  ------------------
  545|      1|		sc_file_free(file_p_prvkey);
  546|     39|	LOG_TEST_RET(ctx, rv, "SC_AC_OP_CRYPTO authentication failed for parent DF");
  ------------------
  |  |  174|     39|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     39|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     39|	int _ret = (r); \
  |  |  |  |  168|     39|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 38]
  |  |  |  |  ------------------
  |  |  |  |  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|     39|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 38]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  547|       |
  548|     38|	key_info->access_flags = SC_PKCS15_PRKEY_ACCESS_NEVEREXTRACTABLE
  ------------------
  |  |  319|     38|#define SC_PKCS15_PRKEY_ACCESS_NEVEREXTRACTABLE	0x08
  ------------------
  549|     38|		| SC_PKCS15_PRKEY_ACCESS_ALWAYSSENSITIVE
  ------------------
  |  |  318|     38|#define SC_PKCS15_PRKEY_ACCESS_ALWAYSSENSITIVE	0x04
  ------------------
  550|     38|		| SC_PKCS15_PRKEY_ACCESS_SENSITIVE;
  ------------------
  |  |  316|     38|#define SC_PKCS15_PRKEY_ACCESS_SENSITIVE	0x01
  ------------------
  551|       |
  552|     38|	rv = authentic_sdo_allocate_prvkey(profile, card, key_info, &sdo);
  553|     38|	if (rv != SC_SUCCESS || sdo == NULL) {
  ------------------
  |  |   28|     76|#define SC_SUCCESS				0
  ------------------
  |  Branch (553:6): [True: 7, False: 31]
  |  Branch (553:26): [True: 0, False: 31]
  ------------------
  554|      7|		sc_log(ctx, "IasEcc: init SDO private key failed");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  555|      7|		sc_file_free(file_p_prvkey);
  556|      7|		LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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: 2, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  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|      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|      7|	return _ret; \
  |  |  |  |  163|      7|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  557|      7|	}
  558|       |
  559|     31|	rv = sc_card_ctl(card, SC_CARDCTL_AUTHENTIC_SDO_CREATE, sdo);
  560|     31|	if (rv == SC_ERROR_FILE_ALREADY_EXISTS)   {
  ------------------
  |  |   65|     31|#define SC_ERROR_FILE_ALREADY_EXISTS		-1215
  ------------------
  |  Branch (560:6): [True: 4, False: 27]
  ------------------
  561|      4|		unsigned long caps = p15card->card->caps;
  562|       |
  563|      4|		p15card->card->caps &= ~SC_CARD_CAP_USE_FCI_AC;
  ------------------
  |  |  557|      4|#define SC_CARD_CAP_USE_FCI_AC		0x00000010
  ------------------
  564|      4|		rv = sc_pkcs15init_authenticate(profile, p15card, file_p_prvkey, SC_AC_OP_DELETE);
  ------------------
  |  |  168|      4|#define SC_AC_OP_DELETE			2
  ------------------
  565|      4|		p15card->card->caps = caps;
  566|      4|		LOG_TEST_GOTO_ERR(ctx, rv, "SC_AC_OP_CRYPTO authentication failed for parent DF");
  ------------------
  |  |  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: 3, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  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|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  567|       |
  568|      1|		rv = sc_card_ctl(card, SC_CARDCTL_AUTHENTIC_SDO_DELETE, sdo);
  569|      1|		LOG_TEST_GOTO_ERR(ctx, rv, "SC_CARDCTL_AUTHENTIC_SDO_DELETE failed for private key");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  570|       |
  571|      0|		rv = sc_card_ctl(card, SC_CARDCTL_AUTHENTIC_SDO_CREATE, sdo);
  572|      0|	}
  573|     27|	LOG_TEST_GOTO_ERR(ctx, rv, "SC_CARDCTL_AUTHENTIC_SDO_CREATE failed");
  ------------------
  |  |  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: 9, False: 18]
  |  |  |  |  ------------------
  |  |  |  |  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|     27|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 18]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  574|       |
  575|     18|	rv = authentic_pkcs15_fix_access(p15card, file_p_prvkey, object);
  576|     18|	LOG_TEST_GOTO_ERR(ctx, rv, "cannot fix access rules for private key");
  ------------------
  |  |  184|     18|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     18|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     18|	int _ret = (r); \
  |  |  |  |  178|     18|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 18, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|     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
  |  |  |  |  ------------------
  |  |  |  |  180|     18|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     18|		goto err; \
  |  |  |  |  182|     18|	} \
  |  |  |  |  183|     18|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  577|       |
  578|      0|	rv = authentic_pkcs15_fix_usage(p15card, 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|       |	/* Here fix the key's supported algorithms, if these ones will be implemented
  582|       |	 * (see src/libopensc/pkcs15-prkey.c).
  583|       |	 */
  584|       |
  585|      0|	sdo->file = file_p_prvkey;
  586|      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__
  |  |  ------------------
  ------------------
  587|       |
  588|      0|	rv = sc_pkcs15_allocate_object_content(ctx, object, (unsigned char *)sdo, sizeof(struct sc_authentic_sdo));
  589|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  590|       |
  591|     31|err:
  592|     31|	if (sdo == NULL || sdo->file != file_p_prvkey)
  ------------------
  |  Branch (592:6): [True: 0, False: 31]
  |  Branch (592:21): [True: 31, False: 0]
  ------------------
  593|     31|		sc_file_free(file_p_prvkey);
  594|     31|	authentic_free_sdo_data(sdo);
  595|     31|	free(sdo);
  596|     31|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|     31|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     31|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     31|	int _ret = r; \
  |  |  |  |  155|     31|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 31, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     31|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     31|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 31, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     31|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     31|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     31|	return _ret; \
  |  |  |  |  163|     31|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  597|     31|}
pkcs15-authentic.c:authentic_pkcs15_new_file:
  210|    217|{
  211|    217|	struct sc_context *ctx = card->ctx;
  212|    217|	struct sc_file	*file = NULL;
  213|    217|	const char *t_name = NULL;
  214|    217|	int rv;
  215|       |
  216|    217|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    217|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    217|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    217|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    217|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 217]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  217|    217|	sc_log(ctx, "type %X; num %i", type, num);
  ------------------
  |  |   71|    217|#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|    217|	switch (type) {
  219|    217|		case SC_PKCS15_TYPE_PRKEY_RSA:
  ------------------
  |  |  419|    217|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (219:3): [True: 217, False: 0]
  ------------------
  220|    217|			t_name = "template-private-key";
  221|    217|			break;
  222|      0|		case SC_PKCS15_TYPE_PUBKEY_RSA:
  ------------------
  |  |  426|      0|#define SC_PKCS15_TYPE_PUBKEY_RSA		0x201
  ------------------
  |  Branch (222:3): [True: 0, False: 217]
  ------------------
  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: 217]
  ------------------
  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: 217]
  ------------------
  229|      0|			t_name = "template-public-data";
  230|      0|			break;
  231|      0|		default:
  ------------------
  |  Branch (231:3): [True: 0, False: 217]
  ------------------
  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|    217|	}
  234|       |
  235|    217|	sc_log(ctx, "df_info path '%s'", sc_print_path(&profile->df_info->file->path));
  ------------------
  |  |   71|    217|#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|    217|	rv = sc_profile_get_file(profile, t_name, &file);
  237|    217|	LOG_TEST_RET(ctx, rv, "Error when getting file from template");
  ------------------
  |  |  174|    217|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    217|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    217|	int _ret = (r); \
  |  |  |  |  168|    217|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 134, False: 83]
  |  |  |  |  ------------------
  |  |  |  |  169|    134|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    134|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    134|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    134|		return _ret; \
  |  |  |  |  172|    134|	} \
  |  |  |  |  173|    217|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 83]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  238|       |
  239|     83|	sc_log(ctx, "file(type:%X), path(type:%X,path:%s)", file->type, file->path.type, sc_print_path(&file->path));
  ------------------
  |  |   71|     83|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  240|       |
  241|     83|	file->id = (file->id & 0xFF00) | (num & 0xFF);
  242|     83|	if (file->type != SC_FILE_TYPE_BSO)   {
  ------------------
  |  |  217|     83|#define SC_FILE_TYPE_BSO		0x10
  ------------------
  |  Branch (242:6): [True: 80, False: 3]
  ------------------
  243|     80|		if (file->path.len == 0)   {
  ------------------
  |  Branch (243:7): [True: 77, False: 3]
  ------------------
  244|     77|			file->path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|     77|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  245|     77|			file->path.len = 2;
  246|     77|		}
  247|     80|		file->path.value[file->path.len - 2] = (file->id >> 8) & 0xFF;
  248|     80|		file->path.value[file->path.len - 1] = file->id & 0xFF;
  249|     80|		file->path.count = -1;
  250|     80|	}
  251|       |
  252|     83|	sc_log(ctx, "file(size:%zu,type:%i/%i,id:%04X), path(type:%X,'%s')", file->size, file->type,
  ------------------
  |  |   71|     83|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  253|     83|			file->ef_structure, file->id, file->path.type, sc_print_path(&file->path));
  254|     83|	if (out)
  ------------------
  |  Branch (254:6): [True: 83, False: 0]
  ------------------
  255|     83|		*out = file;
  256|      0|	else
  257|      0|		sc_file_free(file);
  258|       |
  259|     83|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     83|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     83|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     83|	int _ret = r; \
  |  |  |  |  155|     83|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 83, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     83|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 83]
  |  |  |  |  ------------------
  |  |  |  |  157|     83|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     83|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     83|	return _ret; \
  |  |  |  |  163|     83|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  260|     83|}
pkcs15-authentic.c:authentic_sdo_allocate_prvkey:
  330|     38|{
  331|     38|	struct sc_context *ctx = card->ctx;
  332|     38|	struct sc_authentic_sdo *sdo = NULL;
  333|     38|	struct sc_file *file = NULL;
  334|     38|	int rv;
  335|       |
  336|     38|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     38|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  337|       |
  338|     38|	if (!out)
  ------------------
  |  Branch (338:6): [True: 0, False: 38]
  ------------------
  339|     38|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  340|       |
  341|     38|	if ((key_info->modulus_length % 256) || key_info->modulus_length < 1024 || key_info->modulus_length > 2048)
  ------------------
  |  Branch (341:6): [True: 0, False: 38]
  |  Branch (341:42): [True: 0, False: 38]
  |  Branch (341:77): [True: 0, False: 38]
  ------------------
  342|     38|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  343|       |
  344|     38|	rv = authentic_pkcs15_new_file(profile, card, SC_PKCS15_TYPE_PRKEY_RSA, key_info->key_reference, &file);
  ------------------
  |  |  419|     38|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  345|     38|	LOG_TEST_RET(ctx, rv, "Cannot instantiate new PRKEY-RSA file");
  ------------------
  |  |  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: 0, False: 38]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|     38|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 38]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  346|       |
  347|     38|	sdo = calloc(1, sizeof(struct sc_authentic_sdo));
  348|     38|	if (!sdo) {
  ------------------
  |  Branch (348:6): [True: 0, False: 38]
  ------------------
  349|      0|		sc_file_free(file);
  350|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  351|      0|	}
  352|       |
  353|     38|	sdo->magic = AUTHENTIC_SDO_MAGIC;
  ------------------
  |  |   45|     38|#define AUTHENTIC_SDO_MAGIC                _MAKE_AUTHENTIC_MAGIC('A', 'W', 'S', 'D')
  |  |  ------------------
  |  |  |  |   43|     38|#define _MAKE_AUTHENTIC_MAGIC(a, b, c, d) (((a) << 24) | ((b) << 16) | ((c) << 8) | ((d)))
  |  |  ------------------
  ------------------
  354|     38|	sdo->docp.id = key_info->key_reference &  ~AUTHENTIC_OBJECT_REF_FLAG_LOCAL;
  ------------------
  |  |   49|     38|#define AUTHENTIC_OBJECT_REF_FLAG_LOCAL	0x80
  ------------------
  355|     38|	sdo->docp.mech = authentic_v3_rsa_mechs[(key_info->modulus_length - 1024) / 256];
  356|       |
  357|     38|	rv = authentic_docp_set_acls(card, file, authentic_v3_rsa_ac_ops,
  358|     38|			sizeof(authentic_v3_rsa_ac_ops)/sizeof(authentic_v3_rsa_ac_ops[0]), &sdo->docp);
  359|     38|	sc_file_free(file);
  360|     38|	if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|     38|#define SC_SUCCESS				0
  ------------------
  |  Branch (360:6): [True: 7, False: 31]
  ------------------
  361|      7|		free(sdo);
  362|      7|		sc_log(ctx, "Cannot set key ACLs from file");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  363|      7|		LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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: 2, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  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|      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|      7|	return _ret; \
  |  |  |  |  163|      7|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  364|      7|	}
  365|       |
  366|     31|	sc_log(ctx, "sdo(mech:%X,id:%X,acls:%s)", sdo->docp.mech, sdo->docp.id,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  367|     31|			sc_dump_hex(sdo->docp.acl_data, sdo->docp.acl_data_len));
  368|       |
  369|     31|	*out = sdo;
  370|     31|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     31|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     31|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     31|	int _ret = r; \
  |  |  |  |  155|     31|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 31, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     31|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 31]
  |  |  |  |  ------------------
  |  |  |  |  157|     31|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     31|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     31|	return _ret; \
  |  |  |  |  163|     31|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  371|     31|}
pkcs15-authentic.c:authentic_docp_set_acls:
  292|     38|{
  293|     38|	struct sc_context *ctx = card->ctx;
  294|     38|	unsigned ii, offs;
  295|       |
  296|     38|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     38|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  297|     38|	if (ops_len > sizeof(docp->acl_data) / 2)
  ------------------
  |  Branch (297:6): [True: 0, False: 38]
  ------------------
  298|     38|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  299|       |
  300|    257|	for (ii=0, offs=0; ii<ops_len; ii++)   {
  ------------------
  |  Branch (300:21): [True: 221, False: 36]
  ------------------
  301|    221|		const struct sc_acl_entry *entry;
  302|       |
  303|    221|		entry = sc_file_get_acl_entry(file, *(ops + ii));
  304|    221|		if (entry->method == SC_AC_NEVER)   {
  ------------------
  |  |  163|    221|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (304:7): [True: 7, False: 214]
  ------------------
  305|      7|			docp->acl_data[offs++] = 0x00;
  306|      7|			docp->acl_data[offs++] = 0x00;
  307|      7|		}
  308|    214|		else if (entry->method == SC_AC_NONE)   {
  ------------------
  |  |  150|    214|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (308:12): [True: 23, False: 191]
  ------------------
  309|     23|			docp->acl_data[offs++] = 0x00;
  310|     23|			docp->acl_data[offs++] = 0x00;
  311|     23|		}
  312|    191|		else if (entry->method == SC_AC_CHV)   {
  ------------------
  |  |  151|    191|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (312:12): [True: 2, False: 189]
  ------------------
  313|      2|			if (!(entry->key_ref & AUTHENTIC_V3_CREDENTIAL_ID_MASK)
  ------------------
  |  |   38|      2|#define AUTHENTIC_V3_CREDENTIAL_ID_MASK	7
  ------------------
  |  Branch (313:8): [True: 2, False: 0]
  ------------------
  314|      0|					|| (entry->key_ref & ~AUTHENTIC_V3_CREDENTIAL_ID_MASK))
  ------------------
  |  |   38|      0|#define AUTHENTIC_V3_CREDENTIAL_ID_MASK	7
  ------------------
  |  Branch (314:9): [True: 0, False: 0]
  ------------------
  315|      2|				LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Non supported Credential 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  316|       |
  317|      0|			docp->acl_data[offs++] = 0x00;
  318|      0|			docp->acl_data[offs++] = 0x01 << (entry->key_ref - 1);
  319|      0|		}
  320|    221|	}
  321|       |
  322|     36|	docp->acl_data_len = offs;
  323|     36|	LOG_FUNC_RETURN(ctx, offs);
  ------------------
  |  |  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: 31, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  156|     31|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 31]
  |  |  |  |  ------------------
  |  |  |  |  157|     31|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     31|	} else { \
  |  |  |  |  159|      5|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      5|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      5|	} \
  |  |  |  |  162|     36|	return _ret; \
  |  |  |  |  163|     36|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  324|     36|}
pkcs15-authentic.c:authentic_pkcs15_fix_access:
  449|     18|{
  450|     18|	struct sc_context *ctx = p15card->card->ctx;
  451|     18|	int rv, ii;
  452|       |
  453|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  454|     18|	sc_log(ctx, "authID %s", sc_pkcs15_print_id(&object->auth_id));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  455|       |
  456|     18|	memset(object->access_rules, 0, sizeof(object->access_rules));
  457|       |
  458|     18|	for (ii=0; authentic_v3_rsa_map_attributes[ii].access_rule; ii++)   {
  ------------------
  |  Branch (458:13): [True: 18, False: 0]
  ------------------
  459|     18|		rv = authentic_pkcs15_fix_file_access_rule(p15card, file,
  460|     18|				authentic_v3_rsa_map_attributes[ii].ac_op,
  461|     18|				authentic_v3_rsa_map_attributes[ii].access_rule,
  462|     18|				object);
  463|     18|		LOG_TEST_RET(ctx, rv, "Fix file READ access 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  464|     18|	}
  465|       |
  466|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  467|      0|}
pkcs15-authentic.c:authentic_pkcs15_fix_file_access_rule:
  408|     18|{
  409|     18|	struct sc_context *ctx = p15card->card->ctx;
  410|     18|	const struct sc_acl_entry *acl = NULL;
  411|     18|	struct sc_pkcs15_id id;
  412|     18|	unsigned ref;
  413|     18|	int rv;
  414|       |
  415|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  416|     18|	acl = sc_file_get_acl_entry(file, ac_op);
  417|     18|	sc_log(ctx, "Fix access rule(op:%i;mode:%i) with ACL(method:%X,ref:%X)",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  418|     18|			ac_op, rule_mode, acl->method, acl->key_ref);
  419|     18|	if (acl->method == SC_AC_NEVER)   {
  ------------------
  |  |  163|     18|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (419:6): [True: 0, False: 18]
  ------------------
  420|      0|		sc_log(ctx, "ignore access rule(op:%i,mode:%i)", ac_op, rule_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__
  |  |  ------------------
  ------------------
  421|      0|	}
  422|     18|	else if (acl->method == SC_AC_NONE)   {
  ------------------
  |  |  150|     18|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (422:11): [True: 0, False: 18]
  ------------------
  423|      0|		rv = authentic_pkcs15_add_access_rule(object, rule_mode, NULL);
  424|      0|		LOG_TEST_RET(ctx, rv, "Fix file access rule 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  425|      0|	}
  426|     18|	else   {
  427|     18|		sc_log(ctx, "ACL(method:%X,ref:%X)", acl->method, acl->key_ref);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  428|     18|		if (acl->method == SC_AC_CHV)   {
  ------------------
  |  |  151|     18|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (428:7): [True: 0, False: 18]
  ------------------
  429|      0|			ref = acl->key_ref;
  430|      0|			authentic_reference_to_pkcs15_id (ref, &id);
  431|      0|		}
  432|     18|		else   {
  433|     18|			LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Fix file access 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  434|     18|		}
  435|       |
  436|      0|		sc_log(ctx, "ACL(method:%X,ref:%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__
  |  |  ------------------
  ------------------
  437|      0|		rv = authentic_pkcs15_add_access_rule(object, rule_mode, &id);
  438|      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__
  |  |  ------------------
  ------------------
  439|      0|		LOG_TEST_RET(ctx, rv, "Fix file access rule 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  440|      0|	}
  441|       |
  442|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  443|      0|}
pkcs15-authentic.c:authentic_free_sdo_data:
  497|     31|{
  498|     31|	int rsa_mechs_num = sizeof(authentic_v3_rsa_mechs)/sizeof(authentic_v3_rsa_mechs[0]);
  499|     31|	int ii;
  500|       |
  501|     31|	if (!sdo)
  ------------------
  |  Branch (501:6): [True: 0, False: 31]
  ------------------
  502|      0|		return;
  503|       |
  504|     31|	sc_file_free(sdo->file);
  505|       |
  506|     31|	for (ii=0; ii<rsa_mechs_num; ii++)
  ------------------
  |  Branch (506:13): [True: 31, False: 0]
  ------------------
  507|     31|		if (sdo->docp.mech == authentic_v3_rsa_mechs[ii])
  ------------------
  |  Branch (507:7): [True: 31, False: 0]
  ------------------
  508|     31|			break;
  509|     31|	if (ii<rsa_mechs_num)
  ------------------
  |  Branch (509:6): [True: 31, False: 0]
  ------------------
  510|     31|		sc_pkcs15_free_prkey(sdo->data.prvkey);
  511|     31|}
pkcs15-authentic.c:authentic_pkcs15_generate_key:
  606|      5|{
  607|      5|	struct sc_card *card = p15card->card;
  608|      5|	struct sc_context *ctx = card->ctx;
  609|      5|	struct sc_pkcs15_prkey_info *key_info = (struct sc_pkcs15_prkey_info *) object->data;
  610|      5|	size_t keybits = key_info->modulus_length;
  611|      5|	struct sc_authentic_sdo *sdo = NULL;
  612|      5|	unsigned char *tmp = NULL;
  613|      5|	size_t tmp_len;
  614|      5|	unsigned long caps;
  615|      5|	int rv;
  616|       |
  617|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  618|      5|	sc_log(ctx, "generate key(bits:%zu,path:%s,AuthID:%s",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  619|      5|			keybits, sc_print_path(&key_info->path), sc_pkcs15_print_id(&object->auth_id));
  620|       |
  621|      5|	if (!object->content.value || object->content.len != sizeof(struct sc_authentic_sdo))
  ------------------
  |  Branch (621:6): [True: 5, False: 0]
  |  Branch (621:32): [True: 0, False: 0]
  ------------------
  622|      5|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid PrKey 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  623|      0|	else if (keybits < 1024 || keybits > 2048 || (keybits % 256))
  ------------------
  |  Branch (623:11): [True: 0, False: 0]
  |  Branch (623:29): [True: 0, False: 0]
  |  Branch (623:47): [True: 0, False: 0]
  ------------------
  624|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  625|       |
  626|      0|	sdo = (struct sc_authentic_sdo *)object->content.value;
  627|      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 (627:6): [True: 0, False: 0]
  ------------------
  628|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  629|       |
  630|      0|	rv = sc_select_file(card, &key_info->path, NULL);
  631|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  632|       |
  633|      0|	caps = card->caps;
  634|      0|	card->caps &= ~SC_CARD_CAP_USE_FCI_AC;
  ------------------
  |  |  557|      0|#define SC_CARD_CAP_USE_FCI_AC		0x00000010
  ------------------
  635|      0|	rv = sc_pkcs15init_authenticate(profile, p15card, sdo->file, SC_AC_OP_GENERATE);
  ------------------
  |  |  192|      0|#define SC_AC_OP_GENERATE		26
  ------------------
  636|      0|	card->caps = caps;
  637|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  638|       |
  639|      0|	key_info->access_flags |= SC_PKCS15_PRKEY_ACCESS_LOCAL;
  ------------------
  |  |  320|      0|#define SC_PKCS15_PRKEY_ACCESS_LOCAL		0x10
  ------------------
  640|       |
  641|      0|	rv = sc_card_ctl(card, SC_CARDCTL_AUTHENTIC_SDO_GENERATE, sdo);
  642|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  643|       |
  644|      0|	pubkey->algorithm = SC_ALGORITHM_RSA;
  ------------------
  |  |   69|      0|#define SC_ALGORITHM_RSA		0
  ------------------
  645|       |	//FIXME: allocate/copy/free to reduce memory leakage
  646|      0|	pubkey->u.rsa.modulus = sdo->data.prvkey->u.rsa.modulus;
  647|      0|	pubkey->u.rsa.exponent = sdo->data.prvkey->u.rsa.exponent;
  648|      0|	sdo->data.prvkey = NULL;
  649|       |
  650|      0|	rv = sc_pkcs15_encode_pubkey(ctx, pubkey, &tmp, &tmp_len);
  651|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  652|       |
  653|       |	/*
  654|       |	 * Here algorithms supported by key have to be fixed, if it will be implemented
  655|       |	 * (see src/libopensc/pkcs15-prkey.c).
  656|       |	 */
  657|       |
  658|      0|	authentic_free_sdo_data(sdo);
  659|       |
  660|      0|	rv = sc_pkcs15_allocate_object_content(ctx, object, tmp, tmp_len);
  661|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  662|       |
  663|      0|	free(tmp);
  664|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  665|      0|}
pkcs15-authentic.c:authentic_emu_update_tokeninfo:
  844|     29|{
  845|     29|	struct sc_context *ctx = p15card->card->ctx;
  846|     29|	struct sc_file *file = NULL;
  847|     29|	struct sc_path path;
  848|     29|	unsigned char buffer[8];
  849|     29|	int rv;
  850|     29|	size_t len;
  851|       |
  852|     29|	sc_format_path(AUTHENTIC_CACHE_TIMESTAMP_PATH, &path);
  ------------------
  |  |   47|     29|#define AUTHENTIC_CACHE_TIMESTAMP_PATH "3F0050159999"
  ------------------
  853|     29|	rv = sc_select_file(p15card->card, &path, &file);
  854|     29|	if (!rv) {
  ------------------
  |  Branch (854:6): [True: 14, False: 15]
  ------------------
  855|     14|		rv = sc_get_challenge(p15card->card, buffer, sizeof(buffer));
  856|     14|		if (rv < 0) {
  ------------------
  |  Branch (856:7): [True: 8, False: 6]
  ------------------
  857|      8|			sc_file_free(file);
  858|      8|			LOG_TEST_RET(ctx, rv, "Get challenge 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  859|      8|		}
  860|       |
  861|      6|		len = file->size > sizeof(buffer) ? sizeof(buffer) : file->size;
  ------------------
  |  Branch (861:9): [True: 5, False: 1]
  ------------------
  862|      6|		rv = sc_update_binary(p15card->card, 0, buffer, len, 0);
  863|      6|		sc_file_free(file);
  864|      6|		LOG_TEST_RET(ctx, rv, "Update binary 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  865|      6|	}
  866|       |
  867|     17|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 17]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  868|     17|}
pkcs15-authentic.c:authentic_emu_store_data:
  825|    288|{
  826|    288|	struct sc_context *ctx = p15card->card->ctx;
  827|    288|	int rv = SC_ERROR_NOT_IMPLEMENTED;
  ------------------
  |  |   97|    288|#define SC_ERROR_NOT_IMPLEMENTED		-1416
  ------------------
  828|       |
  829|    288|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    288|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    288|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    288|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    288|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 288]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  830|       |
  831|    288|	switch (object->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|    288|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  |  Branch (831:10): [True: 0, False: 288]
  ------------------
  832|      0|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|      0|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (832:2): [True: 0, False: 288]
  ------------------
  833|      0|		rv = authentic_store_pubkey(p15card, profile, object, data, path);
  834|      0|		break;
  835|    288|	}
  836|       |
  837|    288|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    288|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    288|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    288|	int _ret = r; \
  |  |  |  |  155|    288|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 288, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    288|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    288|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 288, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    288|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    288|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    288|	return _ret; \
  |  |  |  |  163|    288|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  838|    288|}

sc_pkcs15init_get_cardos_ops:
  943|    500|{
  944|    500|	return &sc_pkcs15init_cardos_operations;
  945|    500|}
pkcs15-cardos.c:cardos_erase:
  126|    215|{
  127|    215|	return sc_pkcs15init_erase_card_recursively(p15card, profile);
  128|    215|}
pkcs15-cardos.c:cardos_create_dir:
  135|    105|{
  136|    105|	int	r;
  137|       |
  138|       |	/* Create the application DF */
  139|    105|	if ((r = sc_pkcs15init_create_file(profile, p15card, df)) < 0)
  ------------------
  |  Branch (139:6): [True: 84, False: 21]
  ------------------
  140|     84|		return r;
  141|       |
  142|     21|	if ((r = sc_select_file(p15card->card, &df->path, NULL)) < 0)
  ------------------
  |  Branch (142:6): [True: 2, False: 19]
  ------------------
  143|      2|		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|     19|	if ((r = cardos_create_sec_env(profile, p15card->card, 0x01, 0x00)) < 0)
  ------------------
  |  Branch (148:6): [True: 5, False: 14]
  ------------------
  149|      5|		return r;
  150|       |
  151|     14|	return 0;
  152|     19|}
pkcs15-cardos.c:cardos_create_sec_env:
  579|     19|{
  580|     19|	struct sc_cardctl_cardos_obj_info args;
  581|     19|	struct tlv	tlv;
  582|     19|	unsigned char	buffer[64];
  583|     19|	int		r;
  584|       |
  585|     19|	tlv_init(&tlv, buffer, sizeof(buffer));
  586|     19|	if (tlv_next(&tlv, 0x83) != SC_SUCCESS
  ------------------
  |  |   28|     38|#define SC_SUCCESS				0
  ------------------
  |  Branch (586:6): [True: 0, False: 19]
  ------------------
  587|     19|	    || tlv_add(&tlv, se_id) != SC_SUCCESS
  ------------------
  |  |   28|     38|#define SC_SUCCESS				0
  ------------------
  |  Branch (587:9): [True: 0, False: 19]
  ------------------
  588|     19|	    || tlv_next(&tlv, 0x86) != SC_SUCCESS
  ------------------
  |  |   28|     38|#define SC_SUCCESS				0
  ------------------
  |  Branch (588:9): [True: 0, False: 19]
  ------------------
  589|     19|	    || tlv_add(&tlv, 0) != SC_SUCCESS
  ------------------
  |  |   28|     38|#define SC_SUCCESS				0
  ------------------
  |  Branch (589:9): [True: 0, False: 19]
  ------------------
  590|     19|	    || tlv_add(&tlv, 0) != SC_SUCCESS
  ------------------
  |  |   28|     38|#define SC_SUCCESS				0
  ------------------
  |  Branch (590:9): [True: 0, False: 19]
  ------------------
  591|     19|	    || tlv_next(&tlv, 0x8f) != SC_SUCCESS
  ------------------
  |  |   28|     38|#define SC_SUCCESS				0
  ------------------
  |  Branch (591:9): [True: 0, False: 19]
  ------------------
  592|     19|	    || tlv_add(&tlv, key_id) != SC_SUCCESS
  ------------------
  |  |   28|     38|#define SC_SUCCESS				0
  ------------------
  |  Branch (592:9): [True: 0, False: 19]
  ------------------
  593|     19|	    || tlv_add(&tlv, key_id) != SC_SUCCESS
  ------------------
  |  |   28|     38|#define SC_SUCCESS				0
  ------------------
  |  Branch (593:9): [True: 0, False: 19]
  ------------------
  594|     19|	    || tlv_add(&tlv, key_id) != SC_SUCCESS
  ------------------
  |  |   28|     38|#define SC_SUCCESS				0
  ------------------
  |  Branch (594:9): [True: 0, False: 19]
  ------------------
  595|     19|	    || tlv_add(&tlv, key_id) != SC_SUCCESS
  ------------------
  |  |   28|     38|#define SC_SUCCESS				0
  ------------------
  |  Branch (595:9): [True: 0, False: 19]
  ------------------
  596|     19|	    || tlv_add(&tlv, key_id) != SC_SUCCESS
  ------------------
  |  |   28|     38|#define SC_SUCCESS				0
  ------------------
  |  Branch (596:9): [True: 0, False: 19]
  ------------------
  597|     19|	    || tlv_add(&tlv, key_id) != SC_SUCCESS)
  ------------------
  |  |   28|     19|#define SC_SUCCESS				0
  ------------------
  |  Branch (597:9): [True: 0, False: 19]
  ------------------
  598|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  599|       |
  600|     19|	args.data = buffer;
  601|     19|	args.len = tlv_len(&tlv);
  602|       |
  603|       |	/* ensure we are in the correct lifecycle */
  604|     19|	r = sc_pkcs15init_set_lifecycle(card, SC_CARDCTRL_LIFECYCLE_ADMIN);
  605|     19|	if (r < 0 && r != SC_ERROR_NOT_SUPPORTED)
  ------------------
  |  |   89|      3|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  |  Branch (605:6): [True: 3, False: 16]
  |  Branch (605:15): [True: 2, False: 1]
  ------------------
  606|      2|		return r;
  607|       |
  608|     17|	return sc_card_ctl(card, SC_CARDCTL_CARDOS_PUT_DATA_SECI, &args);
  609|     19|}
pkcs15-cardos.c:tlv_init:
   88|    135|{
   89|    135|	tlv->base = base;
   90|    135|	tlv->end = base + size;
   91|    135|	tlv->current = tlv->next = base;
   92|    135|}
pkcs15-cardos.c:tlv_next:
   95|    521|{
   96|    521|	if (tlv->next + 2 >= tlv->end)
  ------------------
  |  Branch (96:6): [True: 0, False: 521]
  ------------------
   97|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
   98|    521|	tlv->current = tlv->next;
   99|    521|	*(tlv->next++) = tag;
  100|    521|	*(tlv->next++) = 0;
  101|    521|	return SC_SUCCESS;
  ------------------
  |  |   28|    521|#define SC_SUCCESS				0
  ------------------
  102|    521|}
pkcs15-cardos.c:tlv_add:
  105|  3.17k|{
  106|  3.17k|	if (tlv->next + 1 >= tlv->end)
  ------------------
  |  Branch (106:6): [True: 2, False: 3.17k]
  ------------------
  107|      2|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      2|#define SC_ERROR_INTERNAL			-1400
  ------------------
  108|  3.17k|	*(tlv->next++) = val;
  109|  3.17k|	tlv->current[1]++;
  110|  3.17k|	return SC_SUCCESS;
  ------------------
  |  |   28|  3.17k|#define SC_SUCCESS				0
  ------------------
  111|  3.17k|}
pkcs15-cardos.c:tlv_len:
  115|    133|{
  116|    133|	return tlv->next - tlv->base;
  117|    133|}
pkcs15-cardos.c:cardos_select_pin_reference:
  161|    360|{
  162|    360|	int	preferred, current;
  163|       |
  164|    360|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|    360|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (164:6): [True: 0, False: 360]
  ------------------
  165|      0|		return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  166|       |
  167|    360|	if ((current = auth_info->attrs.pin.reference) < 0)
  ------------------
  |  Branch (167:6): [True: 314, False: 46]
  ------------------
  168|    314|		current = CARDOS_PIN_ID_MIN;
  ------------------
  |  |   71|    314|#define CARDOS_PIN_ID_MIN	1
  ------------------
  169|       |
  170|    360|	if (auth_info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN) {
  ------------------
  |  |   61|    360|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (170:6): [True: 26, False: 334]
  ------------------
  171|     26|		preferred = 1;
  172|     26|		if (current > preferred)
  ------------------
  |  Branch (172:7): [True: 17, False: 9]
  ------------------
  173|     17|			return SC_ERROR_TOO_MANY_OBJECTS;
  ------------------
  |  |   86|     17|#define SC_ERROR_TOO_MANY_OBJECTS		-1405
  ------------------
  174|    334|	} else {
  175|    334|		preferred = current;
  176|       |		/* PINs are even numbered, PUKs are odd */
  177|    334|		if (!(preferred & 1))
  ------------------
  |  Branch (177:7): [True: 15, False: 319]
  ------------------
  178|     15|			preferred++;
  179|    334|	}
  180|       |
  181|    343|	if (preferred > CARDOS_PIN_ID_MAX)
  ------------------
  |  |   72|    343|#define CARDOS_PIN_ID_MAX	15
  ------------------
  |  Branch (181:6): [True: 19, False: 324]
  ------------------
  182|     19|		return SC_ERROR_TOO_MANY_OBJECTS;
  ------------------
  |  |   86|     19|#define SC_ERROR_TOO_MANY_OBJECTS		-1405
  ------------------
  183|    324|	auth_info->attrs.pin.reference = preferred;
  184|       |
  185|    324|	return SC_SUCCESS;
  ------------------
  |  |   28|    324|#define SC_SUCCESS				0
  ------------------
  186|    343|}
pkcs15-cardos.c:cardos_create_pin:
  196|    228|{
  197|    228|	sc_pkcs15_auth_info_t *auth_info = (sc_pkcs15_auth_info_t *) pin_obj->data;
  198|    228|	struct sc_card *card = p15card->card;
  199|    228|	unsigned int	puk_id = CARDOS_AC_NEVER;
  ------------------
  |  |   75|    228|#define CARDOS_AC_NEVER		0xFF
  ------------------
  200|    228|	int		r;
  201|       |
  202|    228|	if (!pin || !pin_len)
  ------------------
  |  Branch (202:6): [True: 0, False: 228]
  |  Branch (202:14): [True: 0, False: 228]
  ------------------
  203|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  204|       |
  205|    228|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|    228|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (205:6): [True: 0, False: 228]
  ------------------
  206|      0|		return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  207|       |
  208|    228|	r = sc_select_file(card, auth_info->attrs.pin.reference & 0x80 ? &df->path : sc_get_mf_path(), NULL);
  ------------------
  |  Branch (208:27): [True: 0, False: 228]
  ------------------
  209|    228|	if (r < 0)
  ------------------
  |  Branch (209:6): [True: 127, False: 101]
  ------------------
  210|    127|		return r;
  211|       |
  212|    101|	if (puk && puk_len) {
  ------------------
  |  Branch (212:6): [True: 100, False: 1]
  |  Branch (212:13): [True: 100, False: 0]
  ------------------
  213|    100|		struct sc_pkcs15_auth_info puk_ainfo = {0};
  214|       |
  215|    100|		sc_profile_get_pin_info(profile,
  216|    100|				SC_PKCS15INIT_USER_PUK, &puk_ainfo);
  ------------------
  |  |  172|    100|#define SC_PKCS15INIT_USER_PUK		3
  ------------------
  217|    100|		puk_ainfo.attrs.pin.reference = puk_id = auth_info->attrs.pin.reference + 1;
  218|    100|		r = cardos_store_pin(profile, card,
  219|    100|				&puk_ainfo, CARDOS_AC_NEVER,
  ------------------
  |  |   75|    100|#define CARDOS_AC_NEVER		0xFF
  ------------------
  220|    100|				puk, puk_len);
  221|    100|	}
  222|       |
  223|    101|	if (r >= 0) {
  ------------------
  |  Branch (223:6): [True: 17, False: 84]
  ------------------
  224|     17|		r = cardos_store_pin(profile, card,
  225|     17|				auth_info, puk_id, pin, pin_len);
  226|     17|	}
  227|       |
  228|    101|	return r;
  229|    228|}
pkcs15-cardos.c:cardos_store_pin:
  476|    117|{
  477|    117|	struct sc_cardctl_cardos_obj_info args;
  478|    117|	unsigned char	buffer[256];
  479|    117|	unsigned char	pinpadded[256];
  480|    117|	struct tlv	tlv;
  481|    117|	unsigned int	attempts, maxlen;
  482|    117|	u8 minlen;
  483|    117|	int		r, hasverifyrc;
  484|       |
  485|    117|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|    117|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (485:6): [True: 0, False: 117]
  ------------------
  486|      0|		return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  487|       |
  488|       |	/* We need to do padding because pkcs15-lib.c does it.
  489|       |	 * Would be nice to have a flag in the profile that says
  490|       |	 * "no padding required". */
  491|    117|	maxlen = MIN(profile->pin_maxlen, sizeof(pinpadded));
  ------------------
  |  |   39|    117|# define MIN(a, b)	(((a) < (b))? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (39:21): [True: 115, False: 2]
  |  |  ------------------
  ------------------
  492|    117|	if (pin_len > maxlen) {
  ------------------
  |  Branch (492:6): [True: 1, False: 116]
  ------------------
  493|      1|		sc_log(card->ctx, "invalid pin length: %zu (max %u)", pin_len, maxlen);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  494|      1|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      1|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  495|      1|	}
  496|    116|	memcpy(pinpadded, pin, pin_len);
  497|    741|	while (pin_len < maxlen)
  ------------------
  |  Branch (497:9): [True: 625, False: 116]
  ------------------
  498|    625|		pinpadded[pin_len++] = profile->pin_pad_char;
  499|    116|	pin = pinpadded;
  500|       |
  501|    116|	attempts = auth_info->tries_left;
  502|    116|	minlen = (u8)auth_info->attrs.pin.min_length;
  503|       |
  504|    116|	tlv_init(&tlv, buffer, sizeof(buffer));
  505|       |
  506|       |	/* object address: class, id */
  507|    116|	if (tlv_next(&tlv, 0x83) != SC_SUCCESS
  ------------------
  |  |   28|    232|#define SC_SUCCESS				0
  ------------------
  |  Branch (507:6): [True: 0, False: 116]
  ------------------
  508|    116|	    || tlv_add(&tlv, 0x00) != SC_SUCCESS /* class byte: usage TEST, k=0 */
  ------------------
  |  |   28|    232|#define SC_SUCCESS				0
  ------------------
  |  Branch (508:9): [True: 0, False: 116]
  ------------------
  509|    116|	    || tlv_add(&tlv, auth_info->attrs.pin.reference & 0x7f) != SC_SUCCESS)
  ------------------
  |  |   28|    116|#define SC_SUCCESS				0
  ------------------
  |  Branch (509:9): [True: 0, False: 116]
  ------------------
  510|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  511|       |
  512|       |	/* parameters */
  513|    116|	if (tlv_next(&tlv, 0x85)
  ------------------
  |  Branch (513:6): [True: 0, False: 116]
  ------------------
  514|    116|	    || tlv_add(&tlv, 0x02) /* options byte */)
  ------------------
  |  Branch (514:9): [True: 0, False: 116]
  ------------------
  515|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  516|       |
  517|    116|	hasverifyrc = cardos_have_verifyrc_package(card);
  518|    116|	if (hasverifyrc == 1)
  ------------------
  |  Branch (518:6): [True: 0, False: 116]
  ------------------
  519|       |		/* Use 9 byte OCI parameters to be able to set VerifyRC bit	*/
  520|      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 (520:7): [True: 0, False: 0]
  ------------------
  521|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  522|       |
  523|    116|	if (tlv_add(&tlv, attempts & 0xf) != SC_SUCCESS /* flags byte */
  ------------------
  |  |   28|    232|#define SC_SUCCESS				0
  ------------------
  |  Branch (523:6): [True: 0, False: 116]
  ------------------
  524|    116|	    || tlv_add(&tlv, CARDOS_ALGO_PIN) != SC_SUCCESS /* algorithm = pin-test */
  ------------------
  |  |   85|    116|#define CARDOS_ALGO_PIN			0x87
  ------------------
              	    || tlv_add(&tlv, CARDOS_ALGO_PIN) != SC_SUCCESS /* algorithm = pin-test */
  ------------------
  |  |   28|    232|#define SC_SUCCESS				0
  ------------------
  |  Branch (524:9): [True: 0, False: 116]
  ------------------
  525|    116|	    || tlv_add(&tlv, attempts & 0xf) != SC_SUCCESS /* errcount = attempts */)
  ------------------
  |  |   28|    116|#define SC_SUCCESS				0
  ------------------
  |  Branch (525:9): [True: 0, False: 116]
  ------------------
  526|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  527|       |
  528|       |	/* usecount: not documented, but seems to work like this:
  529|       |	 *  -	value of 0xff means pin can be presented any number
  530|       |	 *	of times
  531|       |	 *  -	anything less: max # of times before BS object is blocked.
  532|       |	 */
  533|    116|	if (tlv_add(&tlv, 0xff) != SC_SUCCESS)
  ------------------
  |  |   28|    116|#define SC_SUCCESS				0
  ------------------
  |  Branch (533:6): [True: 0, False: 116]
  ------------------
  534|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  535|       |
  536|       |	/* DEK: not documented, no idea what it means */
  537|    116|	if (tlv_add(&tlv, 0xff) != SC_SUCCESS)
  ------------------
  |  |   28|    116|#define SC_SUCCESS				0
  ------------------
  |  Branch (537:6): [True: 0, False: 116]
  ------------------
  538|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  539|       |
  540|       |	/* ARA counter: number of times the test object can be used before
  541|       |	 *              another verification is required (~ user consent)
  542|       |	 *              (0x00 unlimited usage)
  543|       |	 */
  544|    116|	if (tlv_add(&tlv, 0x00) != SC_SUCCESS
  ------------------
  |  |   28|    232|#define SC_SUCCESS				0
  ------------------
  |  Branch (544:6): [True: 0, False: 116]
  ------------------
  545|    116|	    || tlv_add(&tlv, minlen) != SC_SUCCESS /* minlen */)
  ------------------
  |  |   28|    116|#define SC_SUCCESS				0
  ------------------
  |  Branch (545:9): [True: 0, False: 116]
  ------------------
  546|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  547|       |
  548|       |	/* AC conditions */
  549|    116|	if (tlv_next(&tlv, 0x86) != SC_SUCCESS
  ------------------
  |  |   28|    232|#define SC_SUCCESS				0
  ------------------
  |  Branch (549:6): [True: 0, False: 116]
  ------------------
  550|    116|	    || tlv_add(&tlv, 0x00) != SC_SUCCESS /* use: always */
  ------------------
  |  |   28|    232|#define SC_SUCCESS				0
  ------------------
  |  Branch (550:9): [True: 0, False: 116]
  ------------------
  551|    116|	    || tlv_add(&tlv, auth_info->attrs.pin.reference) != SC_SUCCESS /* change: PIN */
  ------------------
  |  |   28|    232|#define SC_SUCCESS				0
  ------------------
  |  Branch (551:9): [True: 0, False: 116]
  ------------------
  552|    116|	    || tlv_add(&tlv, puk_id) != SC_SUCCESS /* unblock: PUK */)
  ------------------
  |  |   28|    116|#define SC_SUCCESS				0
  ------------------
  |  Branch (552:9): [True: 0, False: 116]
  ------------------
  553|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  554|       |
  555|       |	/* data: PIN */
  556|    116|	if (tlv_next(&tlv, 0x8f) != SC_SUCCESS)
  ------------------
  |  |   28|    116|#define SC_SUCCESS				0
  ------------------
  |  Branch (556:6): [True: 0, False: 116]
  ------------------
  557|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  558|  1.60k|	while (pin_len--)
  ------------------
  |  Branch (558:9): [True: 1.49k, False: 114]
  ------------------
  559|  1.49k|		if (tlv_add(&tlv, *pin++) != SC_SUCCESS)
  ------------------
  |  |   28|  1.49k|#define SC_SUCCESS				0
  ------------------
  |  Branch (559:7): [True: 2, False: 1.49k]
  ------------------
  560|      2|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|    118|#define SC_ERROR_INTERNAL			-1400
  ------------------
  561|       |
  562|    114|	args.data = buffer;
  563|    114|	args.len = tlv_len(&tlv);
  564|       |
  565|       |	/* ensure we are in the correct lifecycle */
  566|    114|	r = sc_pkcs15init_set_lifecycle(card, SC_CARDCTRL_LIFECYCLE_ADMIN);
  567|    114|	if (r < 0 && r != SC_ERROR_NOT_SUPPORTED)
  ------------------
  |  |   89|     93|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  |  Branch (567:6): [True: 93, False: 21]
  |  Branch (567:15): [True: 84, False: 9]
  ------------------
  568|     84|		return r;
  569|       |
  570|     30|	return sc_card_ctl(card, SC_CARDCTL_CARDOS_PUT_DATA_OCI, &args);
  571|    114|}
pkcs15-cardos.c:cardos_have_verifyrc_package:
  874|    116|{
  875|    116|	sc_apdu_t apdu;
  876|    116|        u8        rbuf[SC_MAX_APDU_BUFFER_SIZE];
  877|    116|        int       r;
  878|    116|	const u8  *p = rbuf, *q, *pp;
  879|    116|	size_t    len, tlen = 0, ilen = 0;
  880|       |
  881|    116|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, 0x88);
  ------------------
  |  |  292|    116|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  882|    116|	apdu.resp    = rbuf;
  883|    116|	apdu.resplen = sizeof(rbuf);
  884|    116|	apdu.lc = 0;
  885|    116|	apdu.le = 256;
  886|    116|	r = sc_transmit_apdu(card, &apdu);
  887|    116|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    116|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    116|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    116|	int _ret = (r); \
  |  |  |  |  168|    116|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 110]
  |  |  |  |  ------------------
  |  |  |  |  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|    116|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 110]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  888|       |
  889|    110|	if ((len = apdu.resplen) == 0)
  ------------------
  |  Branch (889:6): [True: 55, False: 55]
  ------------------
  890|       |		/* looks like no package has been installed  */
  891|     55|		return 0;
  892|       |
  893|     55|	while (len != 0) {
  ------------------
  |  Branch (893:9): [True: 55, False: 0]
  ------------------
  894|     55|		pp = sc_asn1_find_tag(card->ctx, p, len, 0xe1, &tlen);
  895|     55|		if (pp == NULL)
  ------------------
  |  Branch (895:7): [True: 54, False: 1]
  ------------------
  896|     54|			return 0;
  897|      1|		if (card->type == SC_CARD_TYPE_CARDOS_M4_3)	{
  ------------------
  |  Branch (897:7): [True: 0, False: 1]
  ------------------
  898|       |			/* the verifyRC package on CardOS 4.3B use Manufacturer ID 0x01	*/
  899|       |			/* and Package Number 0x07					*/
  900|      0|			q = sc_asn1_find_tag(card->ctx, pp, tlen, 0x01, &ilen);
  901|      0|			if (q == NULL || ilen != 4)
  ------------------
  |  Branch (901:8): [True: 0, False: 0]
  |  Branch (901:21): [True: 0, False: 0]
  ------------------
  902|      0|				return 0;
  903|      0|			if (q[0] == 0x07)
  ------------------
  |  Branch (903:8): [True: 0, False: 0]
  ------------------
  904|      0|				return 1;
  905|      1|		} else if (card->type == SC_CARD_TYPE_CARDOS_M4_4)	{
  ------------------
  |  Branch (905:14): [True: 0, False: 1]
  ------------------
  906|       |			/* the verifyRC package on CardOS 4.4 use Manufacturer ID 0x03	*/
  907|       |			/* and Package Number 0x02					*/
  908|      0|			q = sc_asn1_find_tag(card->ctx, pp, tlen, 0x03, &ilen);
  909|      0|			if (q == NULL || ilen != 4)
  ------------------
  |  Branch (909:8): [True: 0, False: 0]
  |  Branch (909:21): [True: 0, False: 0]
  ------------------
  910|      0|				return 0;
  911|      0|			if (q[0] == 0x02)
  ------------------
  |  Branch (911:8): [True: 0, False: 0]
  ------------------
  912|      0|				return 1;
  913|      1|		} else	{
  914|      1|			return 0;
  915|      1|		}
  916|      0|		p   += tlen;
  917|      0|		len -= tlen + 2;
  918|      0|	}
  919|       |
  920|      0|	return 0;
  921|     55|}
pkcs15-cardos.c:cardos_select_key_reference:
  237|    132|{
  238|    132|	if (key_info->key_reference < CARDOS_KEY_ID_MIN)
  ------------------
  |  |   73|    132|#define CARDOS_KEY_ID_MIN	16
  ------------------
  |  Branch (238:6): [True: 132, False: 0]
  ------------------
  239|    132|		key_info->key_reference = CARDOS_KEY_ID_MIN;
  ------------------
  |  |   73|    132|#define CARDOS_KEY_ID_MIN	16
  ------------------
  240|    132|	if (key_info->key_reference > CARDOS_KEY_ID_MAX)
  ------------------
  |  |   74|    132|#define CARDOS_KEY_ID_MAX	31
  ------------------
  |  Branch (240:6): [True: 0, False: 132]
  ------------------
  241|      0|		return SC_ERROR_TOO_MANY_OBJECTS;
  ------------------
  |  |   86|      0|#define SC_ERROR_TOO_MANY_OBJECTS		-1405
  ------------------
  242|    132|	return 0;
  243|    132|}
pkcs15-cardos.c:cardos_create_key:
  252|    132|{
  253|    132|	return 0;
  254|    132|}
pkcs15-cardos.c:cardos_key_algorithm:
  622|    132|{
  623|       |	/* if it is sign and decipher, we use decipher and emulate sign */
  624|    132|	if (usage & USAGE_ANY_DECIPHER) {
  ------------------
  |  |  618|    132|#define USAGE_ANY_DECIPHER	(SC_PKCS15_PRKEY_USAGE_DECRYPT|\
  |  |  ------------------
  |  |  |  |  306|    132|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  |  |  ------------------
  |  |  619|    132|				 SC_PKCS15_PRKEY_USAGE_UNWRAP)
  |  |  ------------------
  |  |  |  |  310|    132|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  |  |  ------------------
  ------------------
  |  Branch (624:6): [True: 0, False: 132]
  ------------------
  625|      0|		if (keylen <= 1024)
  ------------------
  |  Branch (625:7): [True: 0, False: 0]
  ------------------
  626|      0|			*algop = CARDOS_ALGO_RSA_PURE;
  ------------------
  |  |   78|      0|#define CARDOS_ALGO_RSA_PURE		0x0C
  ------------------
  627|      0|		else
  628|      0|			*algop = CARDOS_ALGO_EXT_RSA_PURE;
  ------------------
  |  |   83|      0|#define CARDOS_ALGO_EXT_RSA_PURE	0x0a
  ------------------
  629|      0|		return 0;
  630|      0|	}
  631|    132|	if (usage & USAGE_ANY_SIGN) {
  ------------------
  |  |  616|    132|#define USAGE_ANY_SIGN		(SC_PKCS15_PRKEY_USAGE_SIGN|\
  |  |  ------------------
  |  |  |  |  307|    132|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  |  |  ------------------
  |  |  617|    132|				 SC_PKCS15_PRKEY_USAGE_NONREPUDIATION)
  |  |  ------------------
  |  |  |  |  314|    132|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  |  |  ------------------
  ------------------
  |  Branch (631:6): [True: 132, False: 0]
  ------------------
  632|    132|		if (keylen <= 1024)
  ------------------
  |  Branch (632:7): [True: 132, False: 0]
  ------------------
  633|    132|			*algop = CARDOS_ALGO_RSA_PURE_SIG;
  ------------------
  |  |   80|    132|#define CARDOS_ALGO_RSA_PURE_SIG	0x8C
  ------------------
  634|      0|		else
  635|      0|			*algop = CARDOS_ALGO_EXT_RSA_SIG_PURE;
  ------------------
  |  |   84|      0|#define CARDOS_ALGO_EXT_RSA_SIG_PURE	0x8a
  ------------------
  636|    132|		return 0;
  637|    132|	}
  638|      0|	return -1;
  639|    132|}
pkcs15-cardos.c:cardos_generate_key:
  327|    132|{
  328|    132|	struct sc_context *ctx = p15card->card->ctx;
  329|    132|	struct sc_pkcs15_prkey_info *key_info = (sc_pkcs15_prkey_info_t *) obj->data;
  330|    132|	struct sc_pkcs15_prkey_rsa key_obj;
  331|    132|	struct sc_cardctl_cardos_genkey_info args;
  332|    132|	struct sc_file	*temp;
  333|    132|	u8		abignum[256];
  334|    132|	int		algorithm = 0, r, delete_it = 0, use_ext_rsa = 0;
  335|    132|	size_t		keybits, rsa_max_size;
  336|    132|	int             pin_id = -1;
  337|       |
  338|    132|	if (obj->type != SC_PKCS15_TYPE_PRKEY_RSA)
  ------------------
  |  |  419|    132|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (338:6): [True: 0, False: 132]
  ------------------
  339|      0|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  340|       |
  341|    132|	rsa_max_size = (sc_card_find_rsa_alg(p15card->card, 2048) != NULL) ? 2048 : 1024;
  ------------------
  |  Branch (341:17): [True: 19, False: 113]
  ------------------
  342|    132|	keybits = key_info->modulus_length & ~7UL;
  343|    132|	if (keybits > rsa_max_size) {
  ------------------
  |  Branch (343:6): [True: 0, False: 132]
  ------------------
  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|    132|	if (keybits > 1024)
  ------------------
  |  Branch (349:6): [True: 0, False: 132]
  ------------------
  350|      0|		use_ext_rsa = 1;
  351|       |
  352|    132|	if (cardos_key_algorithm(key_info->usage, keybits, &algorithm) < 0) {
  ------------------
  |  Branch (352:6): [True: 0, False: 132]
  ------------------
  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|    132|	if (sc_profile_get_file(profile, "tempfile", &temp) < 0) {
  ------------------
  |  Branch (358:6): [True: 132, False: 0]
  ------------------
  359|    132|		sc_log(ctx,  "Profile doesn't define temporary file "
  ------------------
  |  |   71|    132|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  360|    132|				"for key generation.");
  361|    132|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    132|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  362|    132|	}
  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:
  953|    192|{
  954|    192|	return &sc_pkcs15init_cryptoflex_operations;
  955|    192|}
sc_pkcs15init_get_cyberflex_ops:
  959|    199|{
  960|    199|	return &sc_pkcs15init_cyberflex_operations;
  961|    199|}
pkcs15-cflex.c:cflex_erase_card:
   87|     89|{
   88|     89|	struct sc_context *ctx = p15card->card->ctx;
   89|     89|	sc_file_t  *df = profile->df_info->file, *dir, *userpinfile = NULL;
   90|     89|	int             r;
   91|       |
   92|     89|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     89|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     89|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     89|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     89|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 89]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   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|     89|        if (sc_profile_get_file(profile, "DIR", &dir) >= 0) {
  ------------------
  |  Branch (99:13): [True: 10, False: 79]
  ------------------
  100|     10|                r = cflex_delete_file(profile, p15card, dir);
  101|     10|                sc_file_free(dir);
  102|     10|                if (r < 0 && r != SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|      5|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (102:21): [True: 5, False: 5]
  |  Branch (102:30): [True: 3, False: 2]
  ------------------
  103|      3|                        goto out;
  104|     10|        }
  105|       |
  106|     86|	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|     86|	if (sc_profile_get_file(profile, "pinfile-1", &userpinfile) >= 0 &&
  ------------------
  |  Branch (109:6): [True: 0, False: 86]
  ------------------
  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|     89|out:	/* Forget all cached keys, the pin files on card are all gone. */
  120|     89|	sc_file_free(userpinfile);
  121|       |
  122|     89|        sc_free_apps(p15card->card);
  123|     89|        if (r == SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|     89|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (123:13): [True: 1, False: 88]
  ------------------
  124|      1|                r=0;
  125|       |
  126|     89|	SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|     89|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|     89|	int _ret = r; \
  |  |  155|     89|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 89, False: 0]
  |  |  ------------------
  |  |  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|     89|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|     89|	return _ret; \
  |  |  163|     89|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  127|     89|}
pkcs15-cflex.c:cflex_delete_file:
   53|     96|{
   54|     96|        sc_path_t  path;
   55|     96|        sc_file_t  *parent;
   56|     96|        int             r = 0;
   57|       |        /* Select the parent DF */
   58|     96|        path = df->path;
   59|     96|		if (path.len < 2) {
  ------------------
  |  Branch (59:7): [True: 32, False: 64]
  ------------------
   60|     32|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|     32|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   61|     32|		}
   62|     64|        path.len -= 2;
   63|     64|        r = sc_select_file(p15card->card, &path, &parent);
   64|     64|        if (r < 0)
  ------------------
  |  Branch (64:13): [True: 52, False: 12]
  ------------------
   65|     52|                return r;
   66|       |
   67|     12|        r = sc_pkcs15init_authenticate(profile, p15card, parent, SC_AC_OP_DELETE);
  ------------------
  |  |  168|     12|#define SC_AC_OP_DELETE			2
  ------------------
   68|     12|        sc_file_free(parent);
   69|     12|        if (r < 0)
  ------------------
  |  Branch (69:13): [True: 1, False: 11]
  ------------------
   70|      1|                return r;
   71|       |
   72|       |	/* cryptoflex has no ERASE AC */
   73|     11|        memset(&path, 0, sizeof(path));
   74|     11|        path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|     11|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
   75|     11|        path.value[0] = df->id >> 8;
   76|     11|        path.value[1] = df->id & 0xFF;
   77|     11|        path.len = 2;
   78|       |
   79|     11|	r = sc_delete_file(p15card->card, &path);
   80|     11|	return r;
   81|     12|}
pkcs15-cflex.c:cryptoflex_init_card:
  135|    110|{
  136|    110|	sc_path_t	path;
  137|    110|	sc_file_t	*file;
  138|    110|	u8		buf[32];
  139|    110|	char		serial[128];
  140|    110|	size_t		len;
  141|    110|	int		r;
  142|       |
  143|    110|	sc_format_path("3F000002", &path);
  144|    110|	if ((r = sc_select_file(p15card->card, &path, &file)) < 0) {
  ------------------
  |  Branch (144:6): [True: 13, False: 97]
  ------------------
  145|     13|		if (r == SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|     13|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (145:7): [True: 1, False: 12]
  ------------------
  146|      1|			return 0;
  147|     12|		return r;
  148|     13|	}
  149|       |
  150|     97|	if ((len = file->size) > sizeof(buf))
  ------------------
  |  Branch (150:6): [True: 58, False: 39]
  ------------------
  151|     58|		len = sizeof(buf);
  152|     97|	sc_file_free(file);
  153|     97|	if ((r = sc_read_binary(p15card->card, 0, buf, len, 0)) < 0)
  ------------------
  |  Branch (153:6): [True: 12, False: 85]
  ------------------
  154|     12|		return r;
  155|     85|	len = r;
  156|     85|	if (len == 0)
  ------------------
  |  Branch (156:6): [True: 38, False: 47]
  ------------------
  157|     38|		return 0;
  158|       |
  159|     47|	if ((r = sc_bin_to_hex(buf, len, serial, sizeof(serial), '\0')) < 0)
  ------------------
  |  Branch (159:6): [True: 0, False: 47]
  ------------------
  160|      0|		return r;
  161|     47|	sc_pkcs15init_set_serial(profile, serial);
  162|     47|	return 0;
  163|     47|}
pkcs15-cflex.c:cflex_create_dir:
  170|    103|{
  171|       |	/* Create the application DF */
  172|    103|	return sc_pkcs15init_create_file(profile, p15card, df);
  173|    103|}
pkcs15-cflex.c:cflex_create_domain:
  181|      1|{
  182|      1|	return sc_pkcs15_create_pin_domain(profile, p15card, id, ret);
  183|      1|}
pkcs15-cflex.c:cflex_select_pin_reference:
  191|    249|{
  192|    249|	int	preferred;
  193|       |
  194|    249|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|    249|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (194:6): [True: 0, False: 249]
  ------------------
  195|      0|		return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  196|       |
  197|    249|	if (auth_info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN) {
  ------------------
  |  |   61|    249|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (197:6): [True: 5, False: 244]
  ------------------
  198|      5|		preferred = 2;
  199|    244|	} else {
  200|    244|		preferred = 1;
  201|    244|	}
  202|    249|	if (auth_info->attrs.pin.reference <= preferred) {
  ------------------
  |  Branch (202:6): [True: 217, False: 32]
  ------------------
  203|    217|		auth_info->attrs.pin.reference = preferred;
  204|    217|		return 0;
  205|    217|	}
  206|       |
  207|     32|	if (auth_info->attrs.pin.reference > 2)
  ------------------
  |  Branch (207:6): [True: 29, False: 3]
  ------------------
  208|     29|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|     29|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  209|       |
  210|       |	/* Caller, please select a different PIN reference */
  211|      3|	return SC_ERROR_INVALID_PIN_REFERENCE;
  ------------------
  |  |  111|      3|#define SC_ERROR_INVALID_PIN_REFERENCE		-1509
  ------------------
  212|     32|}
pkcs15-cflex.c:cflex_create_pin:
  223|     94|{
  224|     94|	struct sc_context *ctx = p15card->card->ctx;
  225|     94|	sc_pkcs15_auth_info_t *auth_info = (sc_pkcs15_auth_info_t *) pin_obj->data;
  226|     94|	struct sc_pkcs15_pin_attributes *pin_attrs = &auth_info->attrs.pin;
  227|     94|	sc_file_t	*dummies[2];
  228|     94|	int		ndummies, pin_type, puk_type, r;
  229|     94|	sc_file_t       *file = NULL;
  230|       |
  231|     94|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     94|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     94|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     94|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     94|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 94]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  232|       |
  233|     94|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|     94|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (233:6): [True: 0, False: 94]
  ------------------
  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|     94|	if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_SO_PIN) {
  ------------------
  |  |   61|     94|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (237:6): [True: 1, False: 93]
  ------------------
  238|      1|		pin_type = SC_PKCS15INIT_SO_PIN;
  ------------------
  |  |  169|      1|#define SC_PKCS15INIT_SO_PIN		0
  ------------------
  239|      1|		puk_type = SC_PKCS15INIT_SO_PUK;
  ------------------
  |  |  170|      1|#define SC_PKCS15INIT_SO_PUK		1
  ------------------
  240|      1|		if (pin_attrs->reference != 2)
  ------------------
  |  Branch (240:7): [True: 0, False: 1]
  ------------------
  241|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  242|     93|	} else {
  243|     93|		pin_type = SC_PKCS15INIT_USER_PIN;
  ------------------
  |  |  171|     93|#define SC_PKCS15INIT_USER_PIN		2
  ------------------
  244|     93|		puk_type = SC_PKCS15INIT_USER_PUK;
  ------------------
  |  |  172|     93|#define SC_PKCS15INIT_USER_PUK		3
  ------------------
  245|     93|		if (pin_attrs->reference != 1)
  ------------------
  |  Branch (245:7): [True: 0, False: 93]
  ------------------
  246|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  247|     93|	}
  248|       |
  249|       |	/* Get file definition from the profile */
  250|     94|	if (sc_profile_get_file(profile, (pin_attrs->reference == 1)? "CHV1" : "CHV2", &file) < 0
  ------------------
  |  Branch (250:6): [True: 94, False: 0]
  |  Branch (250:35): [True: 93, False: 1]
  ------------------
  251|     94|			&& sc_profile_get_file(profile, "CHV", &file) < 0)
  ------------------
  |  Branch (251:7): [True: 83, False: 11]
  ------------------
  252|     94|		LOG_TEST_RET(ctx, SC_ERROR_FILE_NOT_FOUND, "profile does not define pin file ACLs");
  ------------------
  |  |  174|     83|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     83|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     83|	int _ret = (r); \
  |  |  |  |  168|     83|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 83, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|     83|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  253|       |
  254|     11|	ndummies = cflex_create_dummy_chvs(profile, p15card, file, SC_AC_OP_CREATE, dummies);
  ------------------
  |  |  169|     11|#define SC_AC_OP_CREATE			3
  ------------------
  255|     11|	sc_file_free(file);
  256|     11|	LOG_TEST_RET(ctx, ndummies, "Unable to create dummy CHV file");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  257|       |
  258|     11|	r = cflex_create_pin_file(profile, p15card, &df->path, pin_attrs->reference,
  259|     11|			pin, pin_len, sc_profile_get_pin_retries(profile, pin_type),
  260|     11|			puk, puk_len, sc_profile_get_pin_retries(profile, puk_type),
  261|     11|			NULL, 0);
  262|       |
  263|     11|	cflex_delete_dummy_chvs(profile, p15card, ndummies, dummies);
  264|     11|	SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, 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: 10, False: 1]
  |  |  ------------------
  |  |  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|      1|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      1|			"returning with: %d\n", _ret); \
  |  |  161|      1|	} \
  |  |  162|     11|	return _ret; \
  |  |  163|     11|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  265|     11|}
pkcs15-cflex.c:cflex_create_dummy_chvs:
  438|     21|{
  439|     21|	struct sc_context *ctx = p15card->card->ctx;
  440|     21|	const sc_acl_entry_t *acl;
  441|     21|	int		r = 0, ndummies = 0;
  442|       |
  443|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  444|       |	/* See if the DF is supposed to be PIN protected, and if
  445|       |	 * it is, whether that CHV file actually exists. If it doesn't,
  446|       |	 * create it.
  447|       |	 */
  448|     21|	acl = sc_file_get_acl_entry(file, op);
  449|     42|	for (; acl; acl = acl->next) {
  ------------------
  |  Branch (449:9): [True: 21, False: 21]
  ------------------
  450|     21|		sc_path_t	parent, ef;
  451|       |
  452|     21|		if (acl->method != SC_AC_CHV)
  ------------------
  |  |  151|     21|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (452:7): [True: 21, False: 0]
  ------------------
  453|     21|			continue;
  454|       |
  455|      0|		parent = file->path;
  456|      0|		parent.len -= 2;
  457|       |
  458|      0|		r = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  459|      0|		while (parent.len >= 2 && r == SC_ERROR_FILE_NOT_FOUND) {
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (459:10): [True: 0, False: 0]
  |  Branch (459:29): [True: 0, False: 0]
  ------------------
  460|      0|			ef = parent;
  461|      0|			ef.value[ef.len++] = acl->key_ref - 1;
  462|      0|			ef.value[ef.len++] = 0;
  463|      0|			parent.len -= 2;
  464|       |
  465|      0|			if (ef.len == parent.len
  ------------------
  |  Branch (465:8): [True: 0, False: 0]
  ------------------
  466|      0|			 && !memcmp(ef.value, parent.value, ef.len))
  ------------------
  |  Branch (466:8): [True: 0, False: 0]
  ------------------
  467|      0|				continue;
  468|       |
  469|      0|			r = sc_select_file(p15card->card, &ef, NULL);
  470|      0|		}
  471|       |
  472|       |		/* If a valid EF(CHVx) was found, we're fine */
  473|      0|		if (r == 0)
  ------------------
  |  Branch (473:7): [True: 0, False: 0]
  ------------------
  474|      0|			continue;
  475|      0|		if (r != SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (475:7): [True: 0, False: 0]
  ------------------
  476|      0|			break;
  477|       |
  478|       |		/* Create a CHV file in the MF */
  479|      0|		parent = file->path;
  480|      0|		parent.len = 2;
  481|      0|		r = cflex_create_empty_pin_file(profile, p15card, &parent,
  482|      0|				acl->key_ref, &dummies[ndummies]);
  483|      0|		if (r < 0)
  ------------------
  |  Branch (483:7): [True: 0, False: 0]
  ------------------
  484|      0|			break;
  485|      0|		ndummies++;
  486|      0|	}
  487|       |
  488|     21|	if (r < 0) {
  ------------------
  |  Branch (488:6): [True: 0, False: 21]
  ------------------
  489|      0|		cflex_delete_dummy_chvs(profile, p15card, ndummies, dummies);
  490|      0|		return r;
  491|      0|	}
  492|       |
  493|     21|	SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, ndummies);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 21]
  |  |  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  494|     21|}
pkcs15-cflex.c:cflex_create_pin_file:
  526|     11|{
  527|     11|	struct sc_context *ctx = p15card->card->ctx;
  528|     11|	struct sc_pkcs15_object *pin_obj = NULL;
  529|     11|	unsigned char	buffer[23];
  530|     11|	sc_path_t	path;
  531|     11|	sc_file_t	*dummies[2], *file;
  532|     11|	int		r, ndummies;
  533|       |
  534|     11|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  535|     11|	if (file_ret)
  ------------------
  |  Branch (535:6): [True: 0, False: 11]
  ------------------
  536|      0|		*file_ret = NULL;
  537|       |
  538|       |	/* Build the CHV path */
  539|     11|	path = *df_path;
  540|     11|	if (path.len > SC_MAX_PATH_SIZE - 2) {
  ------------------
  |  |   47|     11|#define SC_MAX_PATH_SIZE		16
  ------------------
  |  Branch (540:6): [True: 0, False: 11]
  ------------------
  541|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  542|      0|	}
  543|     11|	path.value[path.len++] = ref - 1;
  544|     11|	path.value[path.len++] = 0;
  545|       |
  546|       |	/* See if the CHV already exists */
  547|     11|	r = sc_select_file(p15card->card, &path, NULL);
  548|     11|	if (r >= 0)
  ------------------
  |  Branch (548:6): [True: 1, False: 10]
  ------------------
  549|      1|		return SC_ERROR_FILE_ALREADY_EXISTS;
  ------------------
  |  |   65|      1|#define SC_ERROR_FILE_ALREADY_EXISTS		-1215
  ------------------
  550|       |
  551|       |	/* Get the file definition from the profile */
  552|     10|	if (sc_profile_get_file_by_path(profile, &path, &file) < 0
  ------------------
  |  Branch (552:6): [True: 10, False: 0]
  ------------------
  553|     10|			&& sc_profile_get_file(profile, (ref == 1)? "CHV1" : "CHV2", &file) < 0
  ------------------
  |  Branch (553:7): [True: 10, False: 0]
  |  Branch (553:36): [True: 10, False: 0]
  ------------------
  554|     10|			&& sc_profile_get_file(profile, "CHV", &file) < 0)
  ------------------
  |  Branch (554:7): [True: 0, False: 10]
  ------------------
  555|     10|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  556|       |
  557|     10|	file->path = path;
  558|     10|	file->size = 23;
  559|     10|	file->id = (ref == 1)? 0x0000 : 0x0100;
  ------------------
  |  Branch (559:13): [True: 10, False: 0]
  ------------------
  560|       |
  561|     10|	if (unprotected)   {
  ------------------
  |  Branch (561:6): [True: 0, False: 10]
  ------------------
  562|      0|		sc_file_add_acl_entry(file, SC_AC_OP_UPDATE,
  ------------------
  |  |  189|      0|#define SC_AC_OP_UPDATE			23
  ------------------
  563|      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
  ------------------
  564|      0|	}
  565|       |
  566|       |	/* Build the contents of the file */
  567|     10|	buffer[0] = buffer[1] = buffer[2] = 0xFF;
  568|     10|	put_pin(profile, buffer + 3, pin, pin_len, pin_tries);
  569|     10|	put_pin(profile, buffer + 13, puk, puk_len, puk_tries);
  570|       |
  571|       |	/* For updating the file, create a dummy CHV files if
  572|       |	 * necessary */
  573|     10|	ndummies = cflex_create_dummy_chvs(profile, p15card,
  574|     10|				file, SC_AC_OP_UPDATE, dummies);
  ------------------
  |  |  189|     10|#define SC_AC_OP_UPDATE			23
  ------------------
  575|     10|	if (ndummies < 0)
  ------------------
  |  Branch (575:6): [True: 0, False: 10]
  ------------------
  576|      0|		sc_file_free(file);
  577|     10|	LOG_TEST_RET(ctx, ndummies, "Unable to create dummy CHV file");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  578|       |
  579|     10|	if (!unprotected)   {
  ------------------
  |  Branch (579:6): [True: 10, False: 0]
  ------------------
  580|     10|		struct sc_pin_cmd_data pin_cmd;
  581|       |
  582|     10|		memset(&pin_cmd, 0, sizeof(pin_cmd));
  583|     10|		pin_cmd.cmd = SC_PIN_CMD_VERIFY;
  ------------------
  |  |  415|     10|#define SC_PIN_CMD_VERIFY	0
  ------------------
  584|     10|		pin_cmd.pin_type = SC_AC_CHV;
  ------------------
  |  |  151|     10|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  585|     10|		pin_cmd.pin_reference = ref;
  586|     10|		pin_cmd.pin1.data = dummy_pin_value;
  587|     10|		pin_cmd.pin1.len = sizeof(dummy_pin_value);
  588|       |
  589|     10|		r = sc_pin_cmd(p15card->card, &pin_cmd);
  590|     10|		if (r < 0)
  ------------------
  |  Branch (590:7): [True: 2, False: 8]
  ------------------
  591|      2|			sc_file_free(file);
  592|     10|		LOG_TEST_RET(ctx, r, "Cannot verify dummy PIN");
  ------------------
  |  |  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: 2, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  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|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  593|     10|	};
  594|       |
  595|      8|	if (ref == 2)   {
  ------------------
  |  Branch (595:6): [True: 0, False: 8]
  ------------------
  596|       |		/* Cache dummy SOPIN value */
  597|      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. */
  ------------------
  598|      0|		if (!r && pin_obj)
  ------------------
  |  Branch (598:7): [True: 0, False: 0]
  |  Branch (598:13): [True: 0, False: 0]
  ------------------
  599|      0|			sc_pkcs15_pincache_add(p15card, pin_obj, dummy_pin_value, sizeof(dummy_pin_value));
  600|      0|	}
  601|       |
  602|      8|	r = sc_pkcs15init_create_file(profile, p15card, file);
  603|      8|	if (r < 0)
  ------------------
  |  Branch (603:6): [True: 6, False: 2]
  ------------------
  604|      6|		sc_file_free(file);
  605|      8|	LOG_TEST_RET(ctx, r, "Failed to create PIN file");
  ------------------
  |  |  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: 6, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  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|      8|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  606|       |
  607|      2|	r = sc_update_binary(p15card->card, 0, buffer, 23, 0);
  608|      2|	if (r < 0 || file_ret == NULL)
  ------------------
  |  Branch (608:6): [True: 1, False: 1]
  |  Branch (608:15): [True: 1, False: 0]
  ------------------
  609|      2|		sc_file_free(file);
  610|      0|	else
  611|      0|		*file_ret = file;
  612|      2|	LOG_TEST_RET(ctx, r, "Failed to update 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  613|       |
  614|       |	/* Delete the dummy CHV files */
  615|      1|	cflex_delete_dummy_chvs(profile, p15card, ndummies, dummies);
  616|       |
  617|      1|	if (pin_obj)   {
  ------------------
  |  Branch (617:6): [True: 0, False: 1]
  ------------------
  618|       |		/* Cache new SOPIN value */
  619|      0|		sc_pkcs15_pincache_add(p15card, pin_obj, pin, pin_len);
  620|      0|	}
  621|       |
  622|      1|	SC_FUNC_RETURN(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: 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]
  |  |  ------------------
  ------------------
  623|      1|}
pkcs15-cflex.c:put_pin:
  511|     20|{
  512|     20|	if (len > 8)
  ------------------
  |  Branch (512:6): [True: 0, False: 20]
  ------------------
  513|      0|		len = 8;
  514|     20|	memset(buf, profile->pin_pad_char, 8);
  515|     20|	memcpy(buf, pin, len);
  516|     20|	buf[8] = retry;
  517|     20|	buf[9] = retry;
  518|     20|}
pkcs15-cflex.c:cflex_delete_dummy_chvs:
  499|     12|{
  500|     12|	while (ndummies--) {
  ------------------
  |  Branch (500:9): [True: 0, False: 12]
  ------------------
  501|      0|		cflex_delete_file(profile, p15card, dummies[ndummies]);
  502|      0|		sc_file_free(dummies[ndummies]);
  503|      0|	}
  504|     12|}
pkcs15-cflex.c:cflex_create_key:
  272|    302|{
  273|    302|	sc_pkcs15_prkey_info_t *key_info = (sc_pkcs15_prkey_info_t *) obj->data;
  274|    302|	sc_file_t	*prkf = NULL, *pukf = NULL;
  275|    302|	size_t		size;
  276|    302|	int		r;
  277|       |
  278|    302|	if (obj->type != SC_PKCS15_TYPE_PRKEY_RSA) {
  ------------------
  |  |  419|    302|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (278:6): [True: 264, False: 38]
  ------------------
  279|    264|		sc_log(p15card->card->ctx,  "Cryptoflex supports only RSA keys.");
  ------------------
  |  |   71|    264|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  280|    264|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    264|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  281|    264|	}
  282|       |
  283|       |	/* Get the public and private key file */
  284|     38|	r = cflex_get_keyfiles(profile, p15card->card,  &key_info->path, &prkf, &pukf);
  285|     38|	if (r < 0)
  ------------------
  |  Branch (285:6): [True: 38, False: 0]
  ------------------
  286|     38|		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, "Unsupported key size %zu", key_info->modulus_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__
  |  |  ------------------
  ------------------
  296|      0|		r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  297|      0|		goto out;
  298|      0|	}
  299|       |
  300|      0|	if (prkf && prkf->size < size)
  ------------------
  |  Branch (300:6): [True: 0, False: 0]
  |  Branch (300:14): [True: 0, False: 0]
  ------------------
  301|      0|		prkf->size = size;
  302|      0|	if (pukf && pukf->size < size + 4)
  ------------------
  |  Branch (302:6): [True: 0, False: 0]
  |  Branch (302:14): [True: 0, False: 0]
  ------------------
  303|      0|		pukf->size = size + 4;
  304|       |
  305|       |	/* Now create the files */
  306|      0|	if ((r = sc_pkcs15init_create_file(profile, p15card, prkf)) < 0
  ------------------
  |  Branch (306:6): [True: 0, False: 0]
  ------------------
  307|      0|	 || (r = sc_pkcs15init_create_file(profile, p15card, pukf)) < 0)
  ------------------
  |  Branch (307:6): [True: 0, False: 0]
  ------------------
  308|      0|		goto out;
  309|       |
  310|      0|	key_info->key_reference = 0;
  311|       |
  312|      0|out:	sc_file_free(prkf);
  313|      0|	sc_file_free(pukf);
  314|      0|	return r;
  315|      0|}
pkcs15-cflex.c:cflex_get_keyfiles:
  652|     38|{
  653|     38|	sc_path_t	path = *df_path;
  654|     38|	int		r;
  655|       |
  656|     38|	if (path.len <= 2) {
  ------------------
  |  Branch (656:6): [True: 13, False: 25]
  ------------------
  657|     13|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|     13|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     13|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     13|	int _ret = r; \
  |  |  |  |  155|     13|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 13, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     13|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     13|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 13, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     13|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     13|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     13|	return _ret; \
  |  |  |  |  163|     13|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  658|     13|	}
  659|       |
  660|       |	/* Get the private key file */
  661|     25|	r = sc_profile_get_file_by_path(profile, &path, prkf);
  662|     25|	if (r < 0) {
  ------------------
  |  Branch (662:6): [True: 0, False: 25]
  ------------------
  663|      0|		char pbuf[SC_MAX_PATH_STRING_SIZE];
  664|       |
  665|      0|		r = sc_path_print(pbuf, sizeof(pbuf), &path);
  666|      0|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (666:7): [True: 0, False: 0]
  ------------------
  667|      0|			pbuf[0] = '\0';
  668|       |
  669|      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__
  |  |  ------------------
  ------------------
  670|      0|				"in profile (path=%s).", pbuf);
  671|      0|		return r;
  672|      0|	}
  673|       |
  674|       |	/* Get the public key file */
  675|     25|	path.len -= 2;
  676|     25|	sc_append_file_id(&path, 0x1012);
  677|     25|	r = sc_profile_get_file_by_path(profile, &path, pukf);
  678|     25|	if (r < 0) {
  ------------------
  |  Branch (678:6): [True: 25, False: 0]
  ------------------
  679|     25|		sc_log(card->ctx,  "Cannot find public key file info in profile.");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  680|     25|		sc_file_free(*prkf);
  681|     25|		return r;
  682|     25|	}
  683|       |
  684|      0|	return 0;
  685|     25|}

sc_pkcs15init_get_entersafe_ops:
  532|    253|{
  533|    253|	return &sc_pkcs15init_entersafe_operations;
  534|    253|}
pkcs15-entersafe.c:entersafe_erase_card:
   64|     96|{
   65|     96|	SC_FUNC_CALLED(p15card->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]
  |  |  ------------------
  ------------------
   66|       |
   67|     96|	if (sc_select_file(p15card->card, sc_get_mf_path(), NULL) < 0)
  ------------------
  |  Branch (67:6): [True: 88, False: 8]
  ------------------
   68|     88|		return SC_SUCCESS;
  ------------------
  |  |   28|     88|#define SC_SUCCESS				0
  ------------------
   69|       |
   70|      8|	return sc_card_ctl(p15card->card,SC_CARDCTL_ERASE_CARD,0);
   71|     96|}
pkcs15-entersafe.c:entersafe_init_card:
   74|     74|{
   75|     74|	struct sc_card *card = p15card->card;
   76|     74|	int ret;
   77|       |
   78|     74|	{/* MF */
   79|     74|		 sc_file_t *mf_file;
   80|     74|		 sc_entersafe_create_data mf_data = {0};
   81|       |
   82|     74|		 SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     74|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     74|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     74|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 74]
  |  |  ------------------
  ------------------
   83|       |
   84|     74|		 ret = sc_profile_get_file(profile, "MF", &mf_file);
   85|     74|		 LOG_TEST_RET(card->ctx,ret,"Get MF info failed");
  ------------------
  |  |  174|     74|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     74|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     74|	int _ret = (r); \
  |  |  |  |  168|     74|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 74]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|     74|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 74]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   86|       |
   87|     74|		 mf_data.type = SC_ENTERSAFE_MF_DATA;
  ------------------
  |  |  665|     74|#define	SC_ENTERSAFE_MF_DATA	0x01
  ------------------
   88|     74|		 mf_data.data.df.file_id[0]=0x3F;
   89|     74|		 mf_data.data.df.file_id[1]=0x00;
   90|     74|		 mf_data.data.df.file_count=0x04;
   91|     74|		 mf_data.data.df.flag=0x11;
   92|     74|		 mf_data.data.df.ikf_size[0]=(mf_file->size>>8)&0xFF;
   93|     74|		 mf_data.data.df.ikf_size[1]=mf_file->size&0xFF;
   94|     74|		 mf_data.data.df.create_ac=0x10;
   95|     74|		 mf_data.data.df.append_ac=0xC0;
   96|     74|		 mf_data.data.df.lock_ac=0x10;
   97|     74|		 memcpy(mf_data.data.df.aid,mf_file->name,mf_file->namelen);
   98|     74|		 sc_file_free(mf_file);
   99|       |
  100|     74|		 ret = sc_card_ctl(card, SC_CARDCTL_ENTERSAFE_CREATE_FILE, &mf_data);
  101|     74|		 LOG_TEST_RET(card->ctx,ret,"Create MF failed");
  ------------------
  |  |  174|     74|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     74|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     74|	int _ret = (r); \
  |  |  |  |  168|     74|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 19, False: 55]
  |  |  |  |  ------------------
  |  |  |  |  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|     74|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 55]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  102|     74|	}
  103|       |
  104|     55|	{/* EF(DIR) */
  105|     55|		 sc_file_t *dir_file;
  106|     55|		 size_t fid,size;
  107|     55|		 sc_entersafe_create_data ef_data;
  108|     55|		 u8 *buff=0;
  109|       |
  110|       |		 /* get dir profile */
  111|     55|		 ret = sc_profile_get_file(profile, "dir", &dir_file);
  112|     55|		 LOG_TEST_RET(card->ctx,ret,"Get EF(DIR) info 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  113|     53|		 fid=dir_file->id;
  114|     53|		 size=dir_file->size;
  115|     53|		 sc_file_free(dir_file);
  116|       |
  117|     53|		 ef_data.type=SC_ENTERSAFE_EF_DATA;
  ------------------
  |  |  667|     53|#define SC_ENTERSAFE_EF_DATA	0x04
  ------------------
  118|     53|		 ef_data.data.ef.file_id[0]=(fid>>8)&0xFF;
  119|     53|		 ef_data.data.ef.file_id[1]=fid&0xFF;
  120|     53|		 ef_data.data.ef.size[0]=(size>>8)&0xFF;
  121|     53|		 ef_data.data.ef.size[1]=size&0xFF;
  122|     53|		 ef_data.data.ef.attr[0]=0x00;
  123|     53|		 ef_data.data.ef.attr[1]=0x00;
  124|     53|		 ef_data.data.ef.name=0x00;
  125|     53|		 memset(ef_data.data.ef.ac,0x10,sizeof(ef_data.data.ef.ac));
  126|     53|		 memset(ef_data.data.ef.sm,0x00,sizeof(ef_data.data.ef.sm));
  127|       |
  128|     53|		 ret = sc_card_ctl(card, SC_CARDCTL_ENTERSAFE_CREATE_FILE, &ef_data);
  129|     53|		 LOG_TEST_RET(card->ctx,ret,"Create EF(DIR) failed");
  ------------------
  |  |  174|     53|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     53|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     53|	int _ret = (r); \
  |  |  |  |  168|     53|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 50]
  |  |  |  |  ------------------
  |  |  |  |  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|     53|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 50]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  130|       |
  131|       |
  132|       |		 /* fill file by 0 */
  133|     50|		 if (size > MAX_FILE_SIZE)
  ------------------
  |  |  220|     50|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (133:8): [True: 1, False: 49]
  ------------------
  134|     50|			 LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_DATA, "Initialize EF(DIR) failed with file size too large");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  135|     49|		 buff = calloc(1,size);
  136|     49|		 if(!buff)
  ------------------
  |  Branch (136:7): [True: 0, False: 49]
  ------------------
  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|     49|		 memset(buff,0,size);
  139|       |
  140|     49|		 ret = sc_update_binary(card,0,buff,size,0);
  141|     49|		 free(buff);
  142|     49|		 LOG_TEST_RET(card->ctx,ret,"Initialize EF(DIR) 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: 36, False: 13]
  |  |  |  |  ------------------
  |  |  |  |  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|     49|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 13]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  143|     49|	}
  144|       |
  145|     13|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  146|       |
  147|     13|}
pkcs15-entersafe.c:entersafe_create_dir:
  151|     13|{
  152|     13|	struct sc_card *card = p15card->card;
  153|     13|	int             ret;
  154|       |
  155|     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]
  |  |  ------------------
  ------------------
  156|       |
  157|     13|	{/* df */
  158|     13|		 sc_entersafe_create_data df_data;
  159|       |
  160|     13|		 df_data.type = SC_ENTERSAFE_DF_DATA;
  ------------------
  |  |  666|     13|#define SC_ENTERSAFE_DF_DATA	0x02
  ------------------
  161|     13|		 df_data.data.df.file_id[0]=(df->id >> 8) & 0xFF;
  162|     13|		 df_data.data.df.file_id[1]=df->id & 0xFF;
  163|     13|		 df_data.data.df.file_count=0x30;
  164|     13|		 df_data.data.df.flag=0x01;
  165|     13|		 df_data.data.df.ikf_size[0]=(df->size>>8)&0xFF;
  166|     13|		 df_data.data.df.ikf_size[1]=df->size&0xFF;
  167|     13|		 df_data.data.df.create_ac=0x10;
  168|     13|		 df_data.data.df.append_ac=0xC0;
  169|     13|		 df_data.data.df.lock_ac=0x10;
  170|     13|		 memcpy(df_data.data.df.aid,df->name,df->namelen);
  171|       |
  172|     13|		 ret = sc_card_ctl(card, SC_CARDCTL_ENTERSAFE_CREATE_FILE, &df_data);
  173|     13|		 LOG_TEST_RET(card->ctx,ret,"Create DF failed");
  ------------------
  |  |  174|     13|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     13|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     13|	int _ret = (r); \
  |  |  |  |  168|     13|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 9, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  169|      9|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      9|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      9|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      9|		return _ret; \
  |  |  |  |  172|      9|	} \
  |  |  |  |  173|     13|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  174|     13|	}
  175|       |
  176|      4|	{/* GPKF */
  177|      4|		 sc_file_t *gpkf_file;
  178|      4|		 sc_entersafe_create_data ef_data;
  179|       |
  180|       |		 /* get p15_gpkf profile */
  181|      4|		 ret = sc_profile_get_file(profile, "p15_gpkf", &gpkf_file);
  182|      4|		 LOG_TEST_RET(card->ctx,ret,"Get GPKF info 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  183|       |
  184|      0|		 ef_data.type=SC_ENTERSAFE_EF_DATA;
  ------------------
  |  |  667|      0|#define SC_ENTERSAFE_EF_DATA	0x04
  ------------------
  185|      0|		 ef_data.data.ef.file_id[0]=(gpkf_file->id>>8)&0xFF;
  186|      0|		 ef_data.data.ef.file_id[1]=gpkf_file->id&0xFF;
  187|      0|		 ef_data.data.ef.size[0]=(gpkf_file->size>>8)&0xFF;
  188|      0|		 ef_data.data.ef.size[1]=gpkf_file->size&0xFF;
  189|      0|		 ef_data.data.ef.attr[0]=0x15;
  190|      0|		 ef_data.data.ef.attr[1]=0x80;
  191|      0|		 ef_data.data.ef.name=0x00;
  192|      0|		 memset(ef_data.data.ef.ac,0x10,sizeof(ef_data.data.ef.ac));
  193|      0|		 memset(ef_data.data.ef.sm,0x00,sizeof(ef_data.data.ef.sm));
  194|       |
  195|      0|		 sc_file_free(gpkf_file);
  196|       |
  197|      0|		 ret = sc_card_ctl(card, SC_CARDCTL_ENTERSAFE_CREATE_FILE, &ef_data);
  198|      0|		 LOG_TEST_RET(card->ctx,ret,"Create GPKF 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  199|      0|	}
  200|       |
  201|      0|	{/* p15 efs */
  202|      0|		 const char * create_efs[]={
  203|      0|			  "PKCS15-ODF",
  204|      0|			  "PKCS15-TokenInfo",
  205|      0|			  "PKCS15-UnusedSpace",
  206|      0|			  "PKCS15-AODF",
  207|      0|			  "PKCS15-PrKDF",
  208|      0|			  "PKCS15-PuKDF",
  209|      0|			  "PKCS15-CDF",
  210|      0|			  "PKCS15-DODF",
  211|      0|			  NULL,
  212|      0|		 };
  213|      0|		 int i;
  214|      0|		 sc_file_t *file=0;
  215|      0|		 sc_entersafe_create_data tmp;
  216|       |
  217|      0|		 for(i = 0; create_efs[i]; ++i)   {
  ------------------
  |  Branch (217:15): [True: 0, False: 0]
  ------------------
  218|      0|			  if (sc_profile_get_file(profile, create_efs[i], &file))   {
  ------------------
  |  Branch (218:10): [True: 0, False: 0]
  ------------------
  219|      0|				   sc_log(card->ctx,  "Inconsistent profile: cannot find %s", create_efs[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__
  |  |  ------------------
  ------------------
  220|      0|				   SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,SC_ERROR_INCONSISTENT_PROFILE);
  ------------------
  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      0|	int _ret = r; \
  |  |  155|      0|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  ------------------
  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      0|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|      0|	return _ret; \
  |  |  163|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  221|      0|			  }
  222|       |
  223|      0|			  tmp.type=SC_ENTERSAFE_EF_DATA;
  ------------------
  |  |  667|      0|#define SC_ENTERSAFE_EF_DATA	0x04
  ------------------
  224|      0|			  tmp.data.ef.file_id[0]=(file->id>>8)&0xFF;
  225|      0|			  tmp.data.ef.file_id[1]=file->id&0xFF;
  226|      0|			  tmp.data.ef.size[0]=(file->size>>8)&0xFF;
  227|      0|			  tmp.data.ef.size[1]=file->size&0xFF;
  228|      0|			  tmp.data.ef.attr[0]=0x00;
  229|      0|			  tmp.data.ef.attr[1]=0x00;
  230|      0|			  tmp.data.ef.name=0x00;
  231|      0|			  memset(tmp.data.ef.ac,ENTERSAFE_AC_ALWAYS,sizeof(tmp.data.ef.ac));
  ------------------
  |  |  678|      0|#define ENTERSAFE_AC_ALWAYS 0x10
  ------------------
  232|      0|			  tmp.data.ef.ac[0]=process_acl_entry(file,SC_AC_OP_READ,ENTERSAFE_AC_ALWAYS); /* read */
  ------------------
  |  |  188|      0|#define SC_AC_OP_READ			22
  ------------------
              			  tmp.data.ef.ac[0]=process_acl_entry(file,SC_AC_OP_READ,ENTERSAFE_AC_ALWAYS); /* read */
  ------------------
  |  |  678|      0|#define ENTERSAFE_AC_ALWAYS 0x10
  ------------------
  233|      0|			  tmp.data.ef.ac[1]=process_acl_entry(file,SC_AC_OP_UPDATE,ENTERSAFE_AC_ALWAYS); /* update */
  ------------------
  |  |  189|      0|#define SC_AC_OP_UPDATE			23
  ------------------
              			  tmp.data.ef.ac[1]=process_acl_entry(file,SC_AC_OP_UPDATE,ENTERSAFE_AC_ALWAYS); /* update */
  ------------------
  |  |  678|      0|#define ENTERSAFE_AC_ALWAYS 0x10
  ------------------
  234|      0|			  memset(tmp.data.ef.sm,0x00,sizeof(tmp.data.ef.sm));
  235|       |
  236|      0|			  sc_file_free(file);
  237|       |
  238|      0|			  ret = sc_card_ctl(card, SC_CARDCTL_ENTERSAFE_CREATE_FILE, &tmp);
  239|      0|			  LOG_TEST_RET(card->ctx,ret,"Create pkcs15 file 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  240|      0|		 }
  241|      0|	}
  242|       |
  243|      0|	{/* Preinstall keys */
  244|      0|		 ret = sc_card_ctl(card, SC_CARDCTL_ENTERSAFE_PREINSTALL_KEYS, 0);
  245|      0|		 LOG_TEST_RET(card->ctx,ret,"Preinstall keys 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  246|      0|	}
  247|       |
  248|      0|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,ret);
  ------------------
  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      0|	int _ret = r; \
  |  |  155|      0|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  ------------------
  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      0|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|      0|	return _ret; \
  |  |  163|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  249|      0|}
pkcs15-entersafe.c:entersafe_pin_reference:
  253|    195|{
  254|    195|	SC_FUNC_CALLED(p15card->card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  255|       |
  256|    195|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|    195|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (256:6): [True: 0, False: 195]
  ------------------
  257|      0|		return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  258|       |
  259|    195|	if (auth_info->attrs.pin.reference < ENTERSAFE_USER_PIN_ID)
  ------------------
  |  |  669|    195|#define ENTERSAFE_USER_PIN_ID  0x01
  ------------------
  |  Branch (259:6): [True: 169, False: 26]
  ------------------
  260|    169|		 auth_info->attrs.pin.reference = ENTERSAFE_USER_PIN_ID;
  ------------------
  |  |  669|    169|#define ENTERSAFE_USER_PIN_ID  0x01
  ------------------
  261|    195|	if (auth_info->attrs.pin.reference > ENTERSAFE_USER_PIN_ID)
  ------------------
  |  |  669|    195|#define ENTERSAFE_USER_PIN_ID  0x01
  ------------------
  |  Branch (261:6): [True: 24, False: 171]
  ------------------
  262|     24|		 return SC_ERROR_TOO_MANY_OBJECTS;
  ------------------
  |  |   86|     24|#define SC_ERROR_TOO_MANY_OBJECTS		-1405
  ------------------
  263|       |
  264|    171|	SC_FUNC_RETURN(p15card->card->ctx, SC_LOG_DEBUG_VERBOSE,SC_SUCCESS);
  ------------------
  |  |  153|    171|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    171|	int _ret = r; \
  |  |  155|    171|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 171, False: 0]
  |  |  ------------------
  |  |  156|    171|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 171]
  |  |  ------------------
  |  |  157|    171|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    171|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|    171|	return _ret; \
  |  |  163|    171|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  265|    171|}
pkcs15-entersafe.c:entersafe_create_pin:
  271|     95|{
  272|     95|	struct sc_card *card = p15card->card;
  273|     95|	int	r;
  274|     95|	sc_pkcs15_auth_info_t *auth_info = (sc_pkcs15_auth_info_t *) pin_obj->data;
  275|       |
  276|     95|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     95|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     95|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     95|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 95]
  |  |  ------------------
  ------------------
  277|       |
  278|     95|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|     95|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (278:6): [True: 0, False: 95]
  ------------------
  279|      0|		return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  280|       |
  281|     95|	{/*pin*/
  282|     95|		 sc_entersafe_wkey_data  data;
  283|       |
  284|     95|		 if (!pin || !pin_len || pin_len > 16)
  ------------------
  |  Branch (284:8): [True: 0, False: 95]
  |  Branch (284:16): [True: 0, False: 95]
  |  Branch (284:28): [True: 0, False: 95]
  ------------------
  285|      0|			  return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  286|       |
  287|     95|		 data.key_id = auth_info->attrs.pin.reference;
  288|     95|		 data.usage=0x0B;
  289|     95|		 data.key_data.symmetric.EC=0x33;
  290|     95|		 data.key_data.symmetric.ver=0x00;
  291|       |		 /* pad pin with 0 */
  292|     95|		 memset(data.key_data.symmetric.key_val, 0, sizeof(data.key_data.symmetric.key_val));
  293|     95|		 memcpy(data.key_data.symmetric.key_val, pin, pin_len);
  294|     95|		 data.key_data.symmetric.key_len=16;
  295|       |
  296|     95|		 r = sc_card_ctl(card, SC_CARDCTL_ENTERSAFE_WRITE_KEY, &data);
  297|     95|		 if (r < 0)
  ------------------
  |  Branch (297:8): [True: 79, False: 16]
  ------------------
  298|     79|			 SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|     79|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|     79|	int _ret = r; \
  |  |  155|     79|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 79, False: 0]
  |  |  ------------------
  |  |  156|     79|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|     79|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 79, False: 0]
  |  |  ------------------
  |  |  157|     79|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|     79|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|     79|	return _ret; \
  |  |  163|     79|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  299|       |
  300|       |		 /* Cache new PIN value. */
  301|     16|		 sc_pkcs15_pincache_add(p15card, pin_obj, pin, pin_len);
  302|     16|	}
  303|       |
  304|      0|	{/*puk*/
  305|     16|		 sc_entersafe_wkey_data  data;
  306|       |
  307|     16|		 if (!puk || !puk_len || puk_len > 16)
  ------------------
  |  Branch (307:8): [True: 0, False: 16]
  |  Branch (307:16): [True: 0, False: 16]
  |  Branch (307:28): [True: 0, False: 16]
  ------------------
  308|      0|			  return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  309|       |
  310|     16|		 data.key_id = auth_info->attrs.pin.reference+1;
  311|     16|		 data.usage=0x0B;
  312|     16|		 data.key_data.symmetric.EC=0x33;
  313|     16|		 data.key_data.symmetric.ver=0x00;
  314|       |		 /* pad pin with 0 */
  315|     16|		 memset(data.key_data.symmetric.key_val, 0, sizeof(data.key_data.symmetric.key_val));
  316|     16|		 memcpy(data.key_data.symmetric.key_val, puk, puk_len);
  317|     16|		 data.key_data.symmetric.key_len=16;
  318|       |
  319|     16|		 r = sc_card_ctl(card, SC_CARDCTL_ENTERSAFE_WRITE_KEY, &data);
  320|     16|	}
  321|       |
  322|       |
  323|     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|      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]
  |  |  ------------------
  ------------------
  324|     16|}
pkcs15-entersafe.c:entersafe_key_reference:
  328|     96|{
  329|     96|	SC_FUNC_CALLED(p15card->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]
  |  |  ------------------
  ------------------
  330|     96|	if (prkey->key_reference < ENTERSAFE_MIN_KEY_ID)
  ------------------
  |  |  671|     96|#define ENTERSAFE_MIN_KEY_ID 0x01
  ------------------
  |  Branch (330:6): [True: 96, False: 0]
  ------------------
  331|     96|		prkey->key_reference = ENTERSAFE_MIN_KEY_ID;
  ------------------
  |  |  671|     96|#define ENTERSAFE_MIN_KEY_ID 0x01
  ------------------
  332|     96|	if (prkey->key_reference > ENTERSAFE_MAX_KEY_ID)
  ------------------
  |  |  672|     96|#define ENTERSAFE_MAX_KEY_ID 0x09
  ------------------
  |  Branch (332:6): [True: 0, False: 96]
  ------------------
  333|      0|		return SC_ERROR_TOO_MANY_OBJECTS;
  ------------------
  |  |   86|      0|#define SC_ERROR_TOO_MANY_OBJECTS		-1405
  ------------------
  334|     96|	SC_FUNC_RETURN(p15card->card->ctx, SC_LOG_DEBUG_VERBOSE,SC_SUCCESS);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 96]
  |  |  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  335|     96|}
pkcs15-entersafe.c:entersafe_create_key:
  339|     96|{
  340|     96|	SC_FUNC_CALLED(p15card->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]
  |  |  ------------------
  ------------------
  341|     96|	SC_FUNC_RETURN(p15card->card->ctx, SC_LOG_DEBUG_VERBOSE,SC_SUCCESS);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 96]
  |  |  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  342|     96|}
pkcs15-entersafe.c:entersafe_generate_key:
  394|     96|{
  395|     96|	int r;
  396|     96|	sc_entersafe_gen_key_data	gendat;
  397|     96|	sc_pkcs15_prkey_info_t *kinfo = (sc_pkcs15_prkey_info_t *) obj->data;
  398|     96|	sc_card_t *card = p15card->card;
  399|     96|	sc_file_t              *tfile;
  400|     96|	const sc_acl_entry_t   *acl_entry;
  401|       |
  402|     96|	struct sc_pkcs15_prkey_info *key_info = (struct sc_pkcs15_prkey_info *)obj->data;
  403|     96|	size_t keybits = key_info->modulus_length;
  404|       |
  405|     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]
  |  |  ------------------
  ------------------
  406|       |
  407|     96|	if ( obj->type != SC_PKCS15_TYPE_PRKEY_RSA )
  ------------------
  |  |  419|     96|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (407:7): [True: 0, False: 96]
  ------------------
  408|      0|	{
  409|      0|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  410|      0|	}
  411|       |
  412|       |	/* Disable RSA:512bits */
  413|     96|	if ( ( keybits < 1024 ) ||
  ------------------
  |  Branch (413:7): [True: 0, False: 96]
  ------------------
  414|     96|		 ( keybits > 2048 ) ||
  ------------------
  |  Branch (414:4): [True: 0, False: 96]
  ------------------
  415|     96|		 ( keybits % 0x20 ) )
  ------------------
  |  Branch (415:4): [True: 0, False: 96]
  ------------------
  416|      0|	{
  417|      0|		sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Unsupported key size %zu", keybits);
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  418|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  419|      0|	}
  420|       |
  421|     96|	r = sc_profile_get_file(profile, "PKCS15-AODF", &tfile);
  422|     96|	if (r < 0)
  ------------------
  |  Branch (422:6): [True: 60, False: 36]
  ------------------
  423|     60|		 return r;
  424|     36|	acl_entry = sc_file_get_acl_entry(tfile, SC_AC_OP_UPDATE);
  ------------------
  |  |  189|     36|#define SC_AC_OP_UPDATE			23
  ------------------
  425|     36|	if (acl_entry->method  != SC_AC_NONE) {
  ------------------
  |  |  150|     36|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (425:6): [True: 3, False: 33]
  ------------------
  426|      3|		 r = sc_pkcs15init_authenticate(profile, p15card, tfile, SC_AC_OP_UPDATE);
  ------------------
  |  |  189|      3|#define SC_AC_OP_UPDATE			23
  ------------------
  427|      3|		 if(r<0)
  ------------------
  |  Branch (427:7): [True: 2, False: 1]
  ------------------
  428|      2|			  r = SC_ERROR_SECURITY_STATUS_NOT_SATISFIED;
  ------------------
  |  |   61|      2|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
  429|      3|	}
  430|     36|	sc_file_free(tfile);
  431|     36|	LOG_TEST_RET(card->ctx, r, "can't verify pin");
  ------------------
  |  |  174|     36|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     36|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     36|	int _ret = (r); \
  |  |  |  |  168|     36|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 34]
  |  |  |  |  ------------------
  |  |  |  |  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|     36|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 34]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  432|       |
  433|       |	/* generate key pair */
  434|     34|	gendat.key_id     = (u8) kinfo->key_reference;
  435|     34|	gendat.key_length = (size_t) kinfo->modulus_length;
  436|     34|	gendat.modulus    = NULL;
  437|     34|	r = sc_card_ctl(card, SC_CARDCTL_ENTERSAFE_GENERATE_KEY, &gendat);
  438|     34|	LOG_TEST_RET(card->ctx, r, "EnterSafe generate RSA key pair 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: 33, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  169|     33|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     33|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     33|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     33|		return _ret; \
  |  |  |  |  172|     33|	} \
  |  |  |  |  173|     34|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  439|       |
  440|       |	/* get the modulus via READ PUBLIC KEY */
  441|      1|	if (pubkey) {
  ------------------
  |  Branch (441:6): [True: 1, False: 0]
  ------------------
  442|      1|		u8 *buf;
  443|      1|		struct sc_pkcs15_pubkey_rsa *rsa = &pubkey->u.rsa;
  444|       |		/* set the modulus */
  445|      1|		rsa->modulus.data = gendat.modulus;
  446|      1|		rsa->modulus.len  = kinfo->modulus_length >> 3;
  447|       |		/* set the exponent (always 0x10001) */
  448|      1|		buf = malloc(3);
  449|      1|		if (!buf)
  ------------------
  |  Branch (449:7): [True: 0, False: 1]
  ------------------
  450|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  451|      1|		buf[0] = 0x01;
  452|      1|		buf[1] = 0x00;
  453|      1|		buf[2] = 0x01;
  454|      1|		rsa->exponent.data = buf;
  455|      1|		rsa->exponent.len  = 3;
  456|       |
  457|      1|		pubkey->algorithm = SC_ALGORITHM_RSA;
  ------------------
  |  |   69|      1|#define SC_ALGORITHM_RSA		0
  ------------------
  458|      1|	} else
  459|       |		/* free public key */
  460|      0|		free(gendat.modulus);
  461|       |
  462|      1|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,SC_SUCCESS);
  ------------------
  |  |  153|      1|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      1|	int _ret = r; \
  |  |  155|      1|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 1, False: 0]
  |  |  ------------------
  |  |  156|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 1]
  |  |  ------------------
  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      1|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|      1|	return _ret; \
  |  |  163|      1|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  463|      1|}
pkcs15-entersafe.c:entersafe_sanity_check:
  467|     96|{
  468|     96|	struct sc_context *ctx = p15card->card->ctx;
  469|     96|	struct sc_pkcs15_auth_info profile_auth = {0};
  470|     96|	struct sc_pkcs15_object *objs[32];
  471|     96|	int rv, nn, ii, update_df = 0;
  472|       |
  473|     96|	SC_FUNC_CALLED(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]
  |  |  ------------------
  ------------------
  474|       |
  475|     96|	sc_log(ctx,  "Check and if needed update PinFlags");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  476|     96|	rv = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_AUTH_PIN, objs, 32);
  ------------------
  |  |  445|     96|#define SC_PKCS15_TYPE_AUTH_PIN			0x601
  ------------------
  477|     96|	LOG_TEST_RET(ctx, rv, "Failed to get PINs");
  ------------------
  |  |  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: 0, False: 96]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|     96|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 96]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  478|     96|	nn = rv;
  479|       |
  480|     96|	sc_profile_get_pin_info(profile, SC_PKCS15INIT_USER_PIN, &profile_auth);
  ------------------
  |  |  171|     96|#define SC_PKCS15INIT_USER_PIN		2
  ------------------
  481|     96|	LOG_TEST_RET(ctx, rv, "Failed to get PIN info");
  ------------------
  |  |  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: 0, False: 96]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|     96|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 96]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  482|       |
  483|     96|	for (ii=0; ii<nn; ii++) {
  ------------------
  |  Branch (483:13): [True: 0, False: 96]
  ------------------
  484|      0|		struct sc_pkcs15_auth_info *ainfo = (struct sc_pkcs15_auth_info *) objs[ii]->data;
  485|      0|		struct sc_pkcs15_pin_attributes *pin_attrs = &ainfo->attrs.pin;
  486|       |
  487|      0|		if (ainfo->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|      0|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (487:7): [True: 0, False: 0]
  ------------------
  488|      0|			continue;
  489|       |
  490|      0|		if (pin_attrs->reference == profile_auth.attrs.pin.reference
  ------------------
  |  Branch (490:7): [True: 0, False: 0]
  ------------------
  491|      0|				&& pin_attrs->flags != profile_auth.attrs.pin.flags)   {
  ------------------
  |  Branch (491:8): [True: 0, False: 0]
  ------------------
  492|      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__
  |  |  ------------------
  ------------------
  493|      0|					pin_attrs->flags, pin_attrs->reference, sc_pkcs15_print_id(&ainfo->auth_id),
  494|      0|					profile_auth.attrs.pin.flags);
  495|      0|			pin_attrs->flags = profile_auth.attrs.pin.flags;
  496|      0|			update_df = 1;
  497|      0|		}
  498|      0|	}
  499|     96|	if (update_df)   {
  ------------------
  |  Branch (499:6): [True: 0, False: 96]
  ------------------
  500|      0|		struct sc_pkcs15_df *df = p15card->df_list;
  501|       |
  502|      0|		while (df != NULL && df->type != SC_PKCS15_AODF)
  ------------------
  |  |  496|      0|#define SC_PKCS15_AODF			8
  ------------------
  |  Branch (502:10): [True: 0, False: 0]
  |  Branch (502:24): [True: 0, False: 0]
  ------------------
  503|      0|			df = df->next;
  504|      0|		if (!df)
  ------------------
  |  Branch (504:7): [True: 0, False: 0]
  ------------------
  505|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  506|      0|		rv = sc_pkcs15init_update_any_df(p15card, profile, df, 0);
  507|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  508|      0|	}
  509|       |
  510|     96|	SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, rv);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 96]
  |  |  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  511|     96|}

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

sc_pkcs15init_get_gids_ops:
  190|    126|{
  191|    126|	return &sc_pkcs15init_gids_operations;
  192|    126|}
pkcs15-gids.c:gids_select_key_reference:
   46|     83|{
   47|     83|	sc_card_t *card = p15card->card;
   48|     83|	LOG_FUNC_RETURN(card->ctx, sc_card_ctl(card, SC_CARDCTL_GIDS_SELECT_KEY_REFERENCE, key_info));
  ------------------
  |  |  164|     83|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     83|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     83|	int _ret = r; \
  |  |  |  |  155|     83|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 83, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     83|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     83|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 83, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     83|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     83|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     83|	return _ret; \
  |  |  |  |  163|     83|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   49|     83|}
pkcs15-gids.c:gids_emu_update_any_df:
  108|     21|{
  109|     21|	LOG_FUNC_CALLED(p15card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  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|     21|	LOG_FUNC_RETURN(p15card->card->ctx, SC_SUCCESS);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 21]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  113|     21|}
pkcs15-gids.c:gids_emu_store_data:
  133|     84|                              struct sc_path *path) {
  134|     84|	sc_card_t *card = p15card->card;
  135|     84|	int r;
  136|       |
  137|     84|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     84|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  138|       |
  139|     84|	switch (object->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|     84|#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: 84]
  ------------------
  141|      0|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|      0|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (141:2): [True: 0, False: 84]
  ------------------
  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: 84]
  ------------------
  147|      0|		r = gids_save_certificate(p15card, object, path);
  148|      0|		break;
  149|     84|	default:
  ------------------
  |  Branch (149:2): [True: 84, False: 0]
  ------------------
  150|     84|		r = SC_ERROR_NOT_IMPLEMENTED;
  ------------------
  |  |   97|     84|#define SC_ERROR_NOT_IMPLEMENTED		-1416
  ------------------
  151|     84|		break;
  152|     84|	}
  153|     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|     84|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 84, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  154|     84|}

iasecc_pkcs15_delete_file:
   75|     38|{
   76|     38|	struct sc_context *ctx = p15card->card->ctx;
   77|     38|	struct sc_card *card = p15card->card;
   78|     38|	struct sc_path  path;
   79|     38|	unsigned long caps = card->caps;
   80|     38|	int rv = 0;
   81|       |
   82|     38|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     38|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   83|       |
   84|     38|	sc_log(ctx, "iasecc_pkcs15_delete_file() id %04X\n", df->id);
  ------------------
  |  |   71|     38|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   85|       |
   86|     38|	card->caps |= SC_CARD_CAP_USE_FCI_AC;
  ------------------
  |  |  557|     38|#define SC_CARD_CAP_USE_FCI_AC		0x00000010
  ------------------
   87|     38|	rv = sc_pkcs15init_authenticate(profile, p15card, df, SC_AC_OP_DELETE);
  ------------------
  |  |  168|     38|#define SC_AC_OP_DELETE			2
  ------------------
   88|     38|	card->caps = caps;
   89|       |
   90|     38|	LOG_TEST_RET(ctx, rv, "Cannot authenticate SC_AC_OP_DELETE");
  ------------------
  |  |  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: 9, False: 29]
  |  |  |  |  ------------------
  |  |  |  |  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|     38|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 29]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   91|       |
   92|     29|	memset(&path, 0, sizeof(path));
   93|     29|	path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|     29|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
   94|     29|	path.value[0] = df->id >> 8;
   95|     29|	path.value[1] = df->id & 0xFF;
   96|     29|	path.len = 2;
   97|       |
   98|     29|	rv = sc_delete_file(card, &path);
   99|     29|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|     29|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     29|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     29|	int _ret = r; \
  |  |  |  |  155|     29|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 29, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     29|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     10|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 10, False: 19]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  100|     29|}
sc_pkcs15init_get_iasecc_ops:
 1896|    469|{
 1897|    469|	return &sc_pkcs15init_iasecc_operations;
 1898|    469|}
pkcs15-iasecc.c:iasecc_pkcs15_erase_card:
  109|    249|{
  110|    249|	struct sc_context *ctx = p15card->card->ctx;
  111|    249|	struct sc_file  *file = NULL;
  112|    249|	struct sc_path  path;
  113|    249|	struct sc_pkcs15_df *df;
  114|    249|	int rv;
  115|       |
  116|    249|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    249|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    249|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    249|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    249|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 249]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  117|       |
  118|    249|	if (p15card->app && p15card->app->ddo.aid.len)   {
  ------------------
  |  Branch (118:6): [True: 0, False: 249]
  |  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|    249|	for (df = p15card->df_list; df; df = df->next)   {
  ------------------
  |  Branch (129:30): [True: 0, False: 249]
  ------------------
  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|    249|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    249|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    249|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    249|	int _ret = r; \
  |  |  |  |  155|    249|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 249, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    249|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 249]
  |  |  |  |  ------------------
  |  |  |  |  157|    249|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    249|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    249|	return _ret; \
  |  |  |  |  163|    249|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  182|    249|}
pkcs15-iasecc.c:iasecc_pkcs15_select_key_reference:
  258|    247|{
  259|    247|	struct sc_context *ctx = p15card->card->ctx;
  260|    247|	struct sc_card *card = p15card->card;
  261|    247|	struct sc_file  *file = NULL;
  262|    247|	int rv = 0, idx = key_info->key_reference & ~IASECC_OBJECT_REF_LOCAL;
  ------------------
  |  |   59|    247|#define IASECC_OBJECT_REF_LOCAL		0x80
  ------------------
  263|       |
  264|    247|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    247|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    247|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    247|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    247|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 247]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  265|    247|	sc_log(ctx, "'seed' key reference %i; path %s", key_info->key_reference & ~IASECC_OBJECT_REF_LOCAL,
  ------------------
  |  |   71|    247|#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)
  |  |  ------------------
  |  |  |  |  265|    247|	sc_log(ctx, "'seed' key reference %i; path %s", key_info->key_reference & ~IASECC_OBJECT_REF_LOCAL,
  |  |  |  |  ------------------
  |  |  |  |  |  |   59|    247|#define IASECC_OBJECT_REF_LOCAL		0x80
  |  |  |  |  ------------------
  |  |  |  |  266|    247|			sc_print_path(&key_info->path));
  |  |  ------------------
  ------------------
  266|    247|			sc_print_path(&key_info->path));
  267|       |
  268|    247|	rv = sc_select_file(card, &key_info->path, &file);
  269|    247|	sc_file_free(file);
  270|    247|	LOG_TEST_RET(ctx, rv, "Cannot select DF to select key reference in");
  ------------------
  |  |  174|    247|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    247|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    247|	int _ret = (r); \
  |  |  |  |  168|    247|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 231, False: 16]
  |  |  |  |  ------------------
  |  |  |  |  169|    231|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    231|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    231|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    231|		return _ret; \
  |  |  |  |  172|    231|	} \
  |  |  |  |  173|    247|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 16]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  271|       |
  272|       |	/* 1 <= ObjReference <= 31 */
  273|     16|	if (idx < IASECC_OBJECT_REF_MIN)
  ------------------
  |  |   62|     16|#define IASECC_OBJECT_REF_MIN	0x01
  ------------------
  |  Branch (273:6): [True: 16, False: 0]
  ------------------
  274|     16|		idx = IASECC_OBJECT_REF_MIN;
  ------------------
  |  |   62|     16|#define IASECC_OBJECT_REF_MIN	0x01
  ------------------
  275|       |
  276|       |	/* Look for the suitable slot */
  277|     16|	if (idx <= IASECC_OBJECT_REF_MAX)   {
  ------------------
  |  |   63|     16|#define IASECC_OBJECT_REF_MAX	0x1F
  ------------------
  |  Branch (277:6): [True: 16, False: 0]
  ------------------
  278|     16|		struct iasecc_ctl_get_free_reference ctl_data;
  279|       |
  280|     16|		ctl_data.key_size = key_info->modulus_length;
  281|     16|		ctl_data.usage = key_info->usage;
  282|     16|		ctl_data.access = key_info->access_flags;
  283|     16|		ctl_data.index = idx;
  284|       |
  285|     16|		rv = sc_card_ctl(card, SC_CARDCTL_IASECC_GET_FREE_KEY_REFERENCE, &ctl_data);
  286|     16|		if (!rv)
  ------------------
  |  Branch (286:7): [True: 7, False: 9]
  ------------------
  287|      7|			sc_log(ctx, "found allocated slot %i", idx);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  288|      9|		else if (rv == SC_ERROR_DATA_OBJECT_NOT_FOUND && idx <= IASECC_OBJECT_REF_MAX)
  ------------------
  |  |   66|     18|#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 (288:12): [True: 0, False: 9]
  |  Branch (288:52): [True: 0, False: 0]
  ------------------
  289|      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__
  |  |  ------------------
  ------------------
  290|      9|		else
  291|      9|			LOG_TEST_RET(ctx, rv, "Cannot select key reference");
  ------------------
  |  |  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: 9, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|      9|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  292|       |
  293|      7|		idx = ctl_data.index;
  294|      7|	}
  295|       |
  296|       |	/* All card objects but PINs are locals */
  297|      7|	key_info->key_reference = idx | IASECC_OBJECT_REF_LOCAL;
  ------------------
  |  |   59|      7|#define IASECC_OBJECT_REF_LOCAL		0x80
  ------------------
  298|      7|	sc_log(ctx, "selected key reference %i", key_info->key_reference);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  299|       |
  300|      7|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|      7|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      7|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      7|	int _ret = r; \
  |  |  |  |  155|      7|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 7, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      7|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  157|      7|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      7|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      7|	return _ret; \
  |  |  |  |  163|      7|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  301|      7|}
pkcs15-iasecc.c:iasecc_pkcs15_create_key:
 1061|      7|{
 1062|      7|	struct sc_card *card = p15card->card;
 1063|      7|	struct sc_context *ctx = card->ctx;
 1064|      7|	struct sc_pkcs15_prkey_info *key_info = (struct sc_pkcs15_prkey_info *) object->data;
 1065|      7|	struct iasecc_sdo *sdo_prvkey = NULL, *sdo_pubkey = NULL;
 1066|      7|	size_t keybits = key_info->modulus_length;
 1067|      7|	unsigned char zeros[0x200];
 1068|      7|	int	 rv;
 1069|       |
 1070|      7|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1071|      7|	sc_log(ctx, "create private key(keybits:%zu,usage:%X,access:%X,ref:%X)",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1072|      7|			keybits, key_info->usage, key_info->access_flags, key_info->key_reference);
 1073|      7|	if (keybits < 1024 || keybits > 2048 || (keybits % 256))   {
  ------------------
  |  Branch (1073:6): [True: 0, False: 7]
  |  Branch (1073:24): [True: 0, False: 7]
  |  Branch (1073:42): [True: 0, False: 7]
  ------------------
 1074|      0|		sc_log(ctx, "Unsupported key size %zu", keybits);
  ------------------
  |  |   71|      0|#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|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1076|      0|	}
 1077|       |
 1078|      7|	memset(zeros, 0, sizeof(zeros));
 1079|       |
 1080|      7|	rv = iasecc_sdo_allocate_pubkey(profile, card, (struct sc_pkcs15_pubkey_info *)key_info, &sdo_pubkey);
 1081|      7|	LOG_TEST_RET(ctx, rv, "IasEcc: allocate SDO public key failed");
  ------------------
  |  |  174|      7|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      7|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      7|	int _ret = (r); \
  |  |  |  |  168|      7|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  169|      3|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      3|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      3|		return _ret; \
  |  |  |  |  172|      3|	} \
  |  |  |  |  173|      7|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1082|      4|	sc_log(ctx, "iasecc_pkcs15_create_key() sdo_pubkey->not_on_card %i", sdo_pubkey->not_on_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__
  |  |  ------------------
  ------------------
 1083|       |
 1084|      4|	rv = iasecc_sdo_allocate_prvkey(profile, card, key_info, &sdo_prvkey);
 1085|      4|	LOG_TEST_GOTO_ERR(ctx, rv, "IasEcc: init SDO private key 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1086|      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__
  |  |  ------------------
  ------------------
 1087|       |
 1088|      0|	if (!sdo_prvkey->not_on_card && !sdo_pubkey->not_on_card)   {
  ------------------
  |  Branch (1088:6): [True: 0, False: 0]
  |  Branch (1088:34): [True: 0, False: 0]
  ------------------
 1089|      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__
  |  |  ------------------
  ------------------
 1090|      0|	}
 1091|      0|	else   {
 1092|      0|		rv = iasecc_pkcs15_create_key_slot(profile, p15card, sdo_prvkey, sdo_pubkey, key_info);
 1093|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1094|      0|	}
 1095|       |
 1096|      0|	rv = sc_pkcs15_allocate_object_content(ctx, object, (unsigned char *)sdo_prvkey, sizeof(struct iasecc_sdo));
 1097|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1098|       |
 1099|      0|	rv = iasecc_pkcs15_fix_private_key_attributes(profile, p15card, object, (struct iasecc_sdo *)object->content.value);
 1100|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1101|       |
 1102|      0|	key_info->path.len = 0;
 1103|       |
 1104|      4|err:
 1105|      4|	iasecc_sdo_free(card, sdo_pubkey);
 1106|      4|	iasecc_sdo_free(card, sdo_prvkey);
 1107|       |
 1108|      4|	LOG_FUNC_RETURN(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|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1109|      4|}
pkcs15-iasecc.c:iasecc_sdo_allocate_pubkey:
  530|      7|{
  531|      7|	struct sc_context *ctx = card->ctx;
  532|      7|	struct iasecc_sdo *sdo = NULL;
  533|      7|	size_t sz = key_info->modulus_length / 8;
  534|      7|	int rv;
  535|       |
  536|      7|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  537|      7|	sdo = calloc(1, sizeof(struct iasecc_sdo));
  538|      7|	if (!sdo)
  ------------------
  |  Branch (538:6): [True: 0, False: 7]
  ------------------
  539|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  540|       |
  541|      7|	sdo->magic = SC_CARDCTL_IASECC_SDO_MAGIC;
  542|      7|	sdo->sdo_ref = key_info->key_reference & 0x3F;
  543|      7|	sdo->sdo_class = IASECC_SDO_CLASS_RSA_PUBLIC;
  ------------------
  |  |  101|      7|#define IASECC_SDO_CLASS_RSA_PUBLIC	0x20
  ------------------
  544|       |
  545|      7|	rv = iasecc_sdo_get_data(card, sdo);
  546|      7|	sc_log(ctx, "get Public Key SDO(class:%X) data returned %i", sdo->sdo_class, rv);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  547|      7|	if (rv == SC_ERROR_DATA_OBJECT_NOT_FOUND)   {
  ------------------
  |  |   66|      7|#define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
  ------------------
  |  Branch (547:6): [True: 5, False: 2]
  ------------------
  548|      5|		sdo->not_on_card = 1;
  549|       |
  550|      5|		rv = iasecc_sdo_set_key_acls_from_profile(profile, card, "public-key", sdo);
  551|      5|		if (rv != SC_SUCCESS)
  ------------------
  |  |   28|      5|#define SC_SUCCESS				0
  ------------------
  |  Branch (551:7): [True: 1, False: 4]
  ------------------
  552|      1|			iasecc_sdo_free(card, sdo);
  553|      5|		LOG_TEST_RET(ctx, rv, "iasecc_sdo_allocate_pubkey() cannot set ACLs for SDO from the 'public-key'");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  554|       |
  555|      4|		sdo->docp.size.value = calloc(1, 2);
  556|      4|		if (!sdo->docp.size.value)   {
  ------------------
  |  Branch (556:7): [True: 0, False: 4]
  ------------------
  557|      0|			iasecc_sdo_free(card, sdo);
  558|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  559|      0|		}
  560|      4|		sdo->docp.size.size = 2;
  561|      4|		sdo->docp.size.tag = IASECC_DOCP_TAG_SIZE;
  ------------------
  |  |   38|      4|#define IASECC_DOCP_TAG_SIZE			0x80
  ------------------
  562|      4|		*(sdo->docp.size.value + 0) = (sz >> 8) & 0xFF;
  563|      4|		*(sdo->docp.size.value + 1) = sz & 0xFF;
  564|       |
  565|      4|		if (card->type == SC_CARD_TYPE_IASECC_OBERTHUR)   {
  ------------------
  |  Branch (565:7): [True: 0, False: 4]
  ------------------
  566|       |			/* TODO: Disabled for the tests of the Oberthur card */
  567|      0|		}
  568|      4|		else   {
  569|      4|			sdo->data.pub_key.cha.value = calloc(1, 2);
  570|      4|			if (!sdo->data.pub_key.cha.value)   {
  ------------------
  |  Branch (570:8): [True: 0, False: 4]
  ------------------
  571|      0|				iasecc_sdo_free(card, sdo);
  572|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  573|      0|			}
  574|      4|			sdo->data.pub_key.cha.size = 2;
  575|      4|			sdo->data.pub_key.cha.tag = IASECC_SDO_PUBKEY_TAG_CHA;
  ------------------
  |  |   81|      4|#define IASECC_SDO_PUBKEY_TAG_CHA		0x5F4C
  ------------------
  576|      4|		}
  577|       |
  578|      4|		sdo->data.pub_key.compulsory.value = calloc(1, 1);
  579|      4|		if (!sdo->data.pub_key.compulsory.value)   {
  ------------------
  |  Branch (579:7): [True: 0, False: 4]
  ------------------
  580|      0|			iasecc_sdo_free(card, sdo);
  581|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  582|      0|		}
  583|      4|		sdo->data.pub_key.compulsory.tag = IASECC_SDO_PUBKEY_TAG_COMPULSORY;
  ------------------
  |  |   79|      4|#define IASECC_SDO_PUBKEY_TAG_COMPULSORY	0x80
  ------------------
  584|      4|		sdo->data.pub_key.compulsory.size = 1;
  585|      4|	}
  586|      2|	else if (rv < 0) {
  ------------------
  |  Branch (586:11): [True: 2, False: 0]
  ------------------
  587|      2|		iasecc_sdo_free(card, sdo);
  588|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  589|      2|	}
  590|       |
  591|      4|	if (out)
  ------------------
  |  Branch (591:6): [True: 4, False: 0]
  ------------------
  592|      4|		*out = sdo;
  593|      0|	else
  594|      0|		iasecc_sdo_free(card, sdo);
  595|       |
  596|      4|	LOG_FUNC_RETURN(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  597|      4|}
pkcs15-iasecc.c:iasecc_sdo_get_data:
  306|     11|{
  307|     11|	struct sc_context *ctx = card->ctx;
  308|     11|	int rv;
  309|       |
  310|     11|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  311|     11|	rv = sc_card_ctl(card, SC_CARDCTL_IASECC_SDO_GET_DATA, sdo);
  312|     11|	LOG_TEST_RET(ctx, rv, "IasEcc: GET DATA error");
  ------------------
  |  |  174|     11|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     11|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     11|	int _ret = (r); \
  |  |  |  |  168|     11|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 11, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     11|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     11|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     11|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     11|		return _ret; \
  |  |  |  |  172|     11|	} \
  |  |  |  |  173|     11|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  313|       |
  314|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  315|      0|}
pkcs15-iasecc.c:iasecc_sdo_set_key_acls_from_profile:
  353|      6|{
  354|      6|	struct sc_context *ctx = card->ctx;
  355|      6|	struct sc_file  *file = NULL;
  356|      6|	unsigned char ops_prvkey[7] = {
  357|      6|		SC_AC_OP_PSO_COMPUTE_SIGNATURE, SC_AC_OP_INTERNAL_AUTHENTICATE, SC_AC_OP_PSO_DECRYPT,
  ------------------
  |  |  177|      6|#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|      6|#define SC_AC_OP_INTERNAL_AUTHENTICATE	15
  ------------------
              		SC_AC_OP_PSO_COMPUTE_SIGNATURE, SC_AC_OP_INTERNAL_AUTHENTICATE, SC_AC_OP_PSO_DECRYPT,
  ------------------
  |  |  175|      6|#define SC_AC_OP_PSO_DECRYPT		9
  ------------------
  358|      6|		SC_AC_OP_GENERATE, 0xFF, SC_AC_OP_UPDATE, SC_AC_OP_READ
  ------------------
  |  |  192|      6|#define SC_AC_OP_GENERATE		26
  ------------------
              		SC_AC_OP_GENERATE, 0xFF, SC_AC_OP_UPDATE, SC_AC_OP_READ
  ------------------
  |  |  189|      6|#define SC_AC_OP_UPDATE			23
  ------------------
              		SC_AC_OP_GENERATE, 0xFF, SC_AC_OP_UPDATE, SC_AC_OP_READ
  ------------------
  |  |  188|      6|#define SC_AC_OP_READ			22
  ------------------
  359|      6|	};
  360|      6|	unsigned char ops_pubkey[7] = {
  361|      6|		0xFF, SC_AC_OP_EXTERNAL_AUTHENTICATE, 0xFF,
  ------------------
  |  |  182|      6|#define SC_AC_OP_EXTERNAL_AUTHENTICATE	16
  ------------------
  362|      6|		SC_AC_OP_GENERATE, 0xFF, SC_AC_OP_UPDATE, SC_AC_OP_READ
  ------------------
  |  |  192|      6|#define SC_AC_OP_GENERATE		26
  ------------------
              		SC_AC_OP_GENERATE, 0xFF, SC_AC_OP_UPDATE, SC_AC_OP_READ
  ------------------
  |  |  189|      6|#define SC_AC_OP_UPDATE			23
  ------------------
              		SC_AC_OP_GENERATE, 0xFF, SC_AC_OP_UPDATE, SC_AC_OP_READ
  ------------------
  |  |  188|      6|#define SC_AC_OP_READ			22
  ------------------
  363|      6|	};
  364|      6|	unsigned char amb, scb[16], mask;
  365|      6|	int rv, ii, cntr;
  366|       |
  367|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  368|       |
  369|       |	/* Get ACLs from profile template */
  370|      6|	rv = sc_profile_get_file(profile, template, &file);
  371|      6|	LOG_TEST_RET(ctx, rv, "IasEcc: cannot instantiate private key file");
  ------------------
  |  |  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: 2, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  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|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  372|       |
  373|       |	/* Convert PKCS15 ACLs to SE ACLs */
  374|      4|	rv = iasecc_file_convert_acls(ctx, profile, file);
  375|      4|	if (rv < 0)
  ------------------
  |  Branch (375:6): [True: 0, False: 4]
  ------------------
  376|      0|		sc_file_free(file);
  377|      4|	LOG_TEST_RET(ctx, rv, "Cannot convert profile ACLs");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  378|       |
  379|      4|	memset(scb, 0, sizeof(scb));
  380|     32|	for (ii = 0, mask = 0x80, amb = 0x80, cntr = 0; ii < 7; ii++) {
  ------------------
  |  Branch (380:50): [True: 28, False: 4]
  ------------------
  381|     28|		const sc_acl_entry_t *acl;
  382|     28|		unsigned char op = sdo->sdo_class == IASECC_SDO_CLASS_RSA_PRIVATE ? ops_prvkey[ii] : ops_pubkey[ii];
  ------------------
  |  |  100|     28|#define IASECC_SDO_CLASS_RSA_PRIVATE	0x10
  ------------------
  |  Branch (382:22): [True: 0, False: 28]
  ------------------
  383|       |
  384|     28|		mask >>= 1;
  385|       |
  386|     28|		if (op == 0xFF)
  ------------------
  |  Branch (386:7): [True: 12, False: 16]
  ------------------
  387|     12|			continue;
  388|       |
  389|     16|		acl = sc_file_get_acl_entry(file, op);
  390|     16|		sc_log(ctx, "ACL: 0x%X:0x%X", acl->method, acl->key_ref);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  391|       |
  392|     16|		if (acl->method == SC_AC_NEVER)   {
  ------------------
  |  |  163|     16|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (392:7): [True: 0, False: 16]
  ------------------
  393|      0|		}
  394|     16|		else if (acl->method == SC_AC_NONE)   {
  ------------------
  |  |  150|     16|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (394:12): [True: 16, False: 0]
  ------------------
  395|     16|			amb |= mask;
  396|     16|			scb[cntr++] = 0x00;
  397|     16|		}
  398|      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 (398:12): [True: 0, False: 0]
  |  Branch (398:40): [True: 0, False: 0]
  |  Branch (398:68): [True: 0, False: 0]
  ------------------
  399|      0|			if ((acl->key_ref & 0xF) == 0 || (acl->key_ref & 0xF) == 0xF)   {
  ------------------
  |  Branch (399:8): [True: 0, False: 0]
  |  Branch (399:37): [True: 0, False: 0]
  ------------------
  400|      0|				sc_file_free(file);
  401|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  402|      0|			}
  403|       |
  404|      0|			amb |= mask;
  405|       |
  406|      0|			if (acl->method == SC_AC_SEN)
  ------------------
  |  |  156|      0|#define SC_AC_SEN                       0x00000020 /* Security Environment. */
  ------------------
  |  Branch (406:8): [True: 0, False: 0]
  ------------------
  407|      0|				scb[cntr++] = acl->key_ref | IASECC_SCB_METHOD_USER_AUTH;
  ------------------
  |  |   93|      0|#define IASECC_SCB_METHOD_USER_AUTH	0x10
  ------------------
  408|      0|			else if (acl->method == SC_AC_PRO)
  ------------------
  |  |  153|      0|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  |  Branch (408:13): [True: 0, False: 0]
  ------------------
  409|      0|				scb[cntr++] = acl->key_ref | IASECC_SCB_METHOD_SM;
  ------------------
  |  |   91|      0|#define IASECC_SCB_METHOD_SM		0x40
  ------------------
  410|      0|			else
  411|      0|				scb[cntr++] = acl->key_ref | IASECC_SCB_METHOD_EXT_AUTH;
  ------------------
  |  |   92|      0|#define IASECC_SCB_METHOD_EXT_AUTH	0x20
  ------------------
  412|      0|		}
  413|      0|		else   {
  414|      0|			sc_file_free(file);
  415|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  416|      0|		}
  417|     16|	}
  418|       |
  419|      4|	sc_file_free(file);
  420|       |
  421|       |	/* Copy ACLs into the DOCP*/
  422|      4|	sdo->docp.acls_contact.tag = IASECC_DOCP_TAG_ACLS_CONTACT;
  ------------------
  |  |   40|      4|#define IASECC_DOCP_TAG_ACLS_CONTACT		0x8C
  ------------------
  423|      4|	sdo->docp.acls_contact.size = cntr + 1;
  424|      4|	sdo->docp.acls_contact.value = calloc(1, sdo->docp.acls_contact.size);
  425|      4|	if (!sdo->docp.acls_contact.value)
  ------------------
  |  Branch (425:6): [True: 0, False: 4]
  ------------------
  426|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  427|      4|	*(sdo->docp.acls_contact.value + 0) = amb;
  428|      4|	memcpy(sdo->docp.acls_contact.value + 1, scb, cntr);
  429|       |
  430|      4|	sc_log(ctx, "AMB: %X, CNTR %i, %x %x %x %x %x %x %x",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  431|      4|	       amb, cntr, scb[0], scb[1], scb[2], scb[3], scb[4], scb[5], scb[6]);
  432|      4|	LOG_FUNC_RETURN(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  433|      4|}
pkcs15-iasecc.c:iasecc_file_convert_acls:
  320|     71|{
  321|     71|	int ii;
  322|       |
  323|  2.27k|	for (ii=0; ii<SC_MAX_AC_OPS;ii++)   {
  ------------------
  |  |  198|  2.27k|#define SC_MAX_AC_OPS			31
  ------------------
  |  Branch (323:13): [True: 2.20k, False: 71]
  ------------------
  324|       |		/* FIXME the acl object must not be modified, it is only defined in
  325|       |		 * sc_file_get_acl_entry. Accessing it here means we have a race
  326|       |		 * condition. */
  327|  2.20k|		struct sc_acl_entry *acl = (struct sc_acl_entry *) sc_file_get_acl_entry(file, ii);
  328|       |
  329|  2.20k|		if (acl)   {
  ------------------
  |  Branch (329:7): [True: 2.20k, False: 0]
  ------------------
  330|  2.20k|			switch (acl->method)   {
  ------------------
  |  Branch (330:12): [True: 0, False: 2.20k]
  ------------------
  331|      0|			case SC_AC_IDA:
  ------------------
  |  |  158|      0|#define SC_AC_IDA                       0x00000080 /* PKCS#15 authentication ID */
  ------------------
  |  Branch (331:4): [True: 0, False: 2.20k]
  ------------------
  332|      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__
  |  |  ------------------
  ------------------
  333|      0|				return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  334|      0|			case SC_AC_SCB:
  ------------------
  |  |  157|      0|#define SC_AC_SCB                       0x00000040 /* IAS/ECC SCB byte. */
  ------------------
  |  Branch (334:4): [True: 0, False: 2.20k]
  ------------------
  335|      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 (335:9): [True: 0, False: 0]
  ------------------
  336|      0|					acl->method = SC_AC_SEN;
  ------------------
  |  |  156|      0|#define SC_AC_SEN                       0x00000020 /* Security Environment. */
  ------------------
  337|      0|					acl->key_ref &= IASECC_SCB_METHOD_MASK_REF;
  ------------------
  |  |   90|      0|#define IASECC_SCB_METHOD_MASK_REF	0x0F
  ------------------
  338|      0|				}
  339|      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 (339:14): [True: 0, False: 0]
  ------------------
  340|      0|					acl->method = SC_AC_PRO;
  ------------------
  |  |  153|      0|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  341|      0|					acl->key_ref &= IASECC_SCB_METHOD_MASK_REF;
  ------------------
  |  |   90|      0|#define IASECC_SCB_METHOD_MASK_REF	0x0F
  ------------------
  342|      0|				}
  343|  2.20k|			}
  344|  2.20k|		}
  345|  2.20k|	}
  346|       |
  347|     71|	return 0;
  348|     71|}
pkcs15-iasecc.c:iasecc_sdo_allocate_prvkey:
  439|      4|{
  440|      4|	struct sc_context *ctx = card->ctx;
  441|      4|	struct iasecc_sdo *sdo = NULL;
  442|      4|	size_t sz = key_info->modulus_length / 8;
  443|      4|	int rv;
  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|       |
  447|      4|	sdo = calloc(1, sizeof(struct iasecc_sdo));
  448|      4|	if (!sdo)
  ------------------
  |  Branch (448:6): [True: 0, False: 4]
  ------------------
  449|      4|		LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "Cannot allocate 'iasecc_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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  450|       |
  451|      4|	sdo->magic = SC_CARDCTL_IASECC_SDO_MAGIC;
  452|      4|	sdo->sdo_ref = key_info->key_reference & 0x3F;
  453|      4|	sdo->sdo_class = IASECC_SDO_CLASS_RSA_PRIVATE;
  ------------------
  |  |  100|      4|#define IASECC_SDO_CLASS_RSA_PRIVATE	0x10
  ------------------
  454|      4|	sdo->usage = key_info->usage;
  455|       |
  456|      4|	sc_log(ctx, "sdo->sdo_class 0x%X; sdo->usage 0x%X", sdo->sdo_class, sdo->usage);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  457|       |
  458|      4|	rv = iasecc_sdo_get_data(card, sdo);
  459|      4|	if (rv == SC_ERROR_DATA_OBJECT_NOT_FOUND)   {
  ------------------
  |  |   66|      4|#define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
  ------------------
  |  Branch (459:6): [True: 1, False: 3]
  ------------------
  460|      1|		sdo->not_on_card = 1;
  461|       |
  462|      1|		rv = iasecc_sdo_set_key_acls_from_profile(profile, card, "private-key", sdo);
  463|      1|		if (rv != SC_SUCCESS)
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
  |  Branch (463:7): [True: 1, False: 0]
  ------------------
  464|      1|			iasecc_sdo_free(card, sdo);
  465|      1|		LOG_TEST_RET(ctx, rv, "IasEcc: cannot set ACLs for SDO from the 'private-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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  466|       |
  467|       |		/* FIXME: set here sdo->docp.name and sdo->docp.idata */
  468|       |
  469|      0|		sdo->docp.non_repudiation.value = calloc(1, 1);
  470|      0|		if (!sdo->docp.non_repudiation.value)   {
  ------------------
  |  Branch (470:7): [True: 0, False: 0]
  ------------------
  471|      0|			iasecc_sdo_free(card, sdo);
  472|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  473|      0|		}
  474|      0|		sdo->docp.non_repudiation.tag = IASECC_DOCP_TAG_NON_REPUDIATION;
  ------------------
  |  |   37|      0|#define IASECC_DOCP_TAG_NON_REPUDIATION 		0x9E
  ------------------
  475|      0|		sdo->docp.non_repudiation.size = 1;
  476|       |
  477|      0|		sdo->data.prv_key.compulsory.value = calloc(1, 1);
  478|      0|		if (!sdo->data.prv_key.compulsory.value)   {
  ------------------
  |  Branch (478:7): [True: 0, False: 0]
  ------------------
  479|      0|			iasecc_sdo_free(card, sdo);
  480|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  481|      0|		}
  482|      0|		sdo->data.prv_key.compulsory.tag = IASECC_SDO_PRVKEY_TAG_COMPULSORY;
  ------------------
  |  |   74|      0|#define IASECC_SDO_PRVKEY_TAG_COMPULSORY	0x80
  ------------------
  483|      0|		sdo->data.prv_key.compulsory.size = 1;
  484|       |
  485|      0|		sdo->docp.size.value = calloc(1, 2);
  486|      0|		if (!sdo->docp.size.value)   {
  ------------------
  |  Branch (486:7): [True: 0, False: 0]
  ------------------
  487|      0|			iasecc_sdo_free(card, sdo);
  488|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  489|      0|		}
  490|      0|		sdo->docp.size.tag = IASECC_DOCP_TAG_SIZE;
  ------------------
  |  |   38|      0|#define IASECC_DOCP_TAG_SIZE			0x80
  ------------------
  491|      0|		sdo->docp.size.size = 2;
  492|      0|		*(sdo->docp.size.value + 0) = (sz >> 8) & 0xFF;
  493|      0|		*(sdo->docp.size.value + 1) = sz & 0xFF;
  494|       |/*
  495|       |  		FIXME: Manage CRT key types: IASECC_GEN_KEY_TYPE_*: X509_usage
  496|       |		Optional PRIVATE KEY SDO attribute 'Algorithm to compulsorily use' can have one of the three values:
  497|       |		0(any usage), B6(Sign), A4(Authentication), B8(Confidentiality).
  498|       |		If present, this attribute has to be the same in the 'GENERATE KEY' template data.
  499|       |*/
  500|      0|		if (!(key_info->access_flags & SC_PKCS15_PRKEY_ACCESS_LOCAL) && (key_info->usage & SC_PKCS15_PRKEY_USAGE_NONREPUDIATION))
  ------------------
  |  |  320|      0|#define SC_PKCS15_PRKEY_ACCESS_LOCAL		0x10
  ------------------
              		if (!(key_info->access_flags & SC_PKCS15_PRKEY_ACCESS_LOCAL) && (key_info->usage & SC_PKCS15_PRKEY_USAGE_NONREPUDIATION))
  ------------------
  |  |  314|      0|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  ------------------
  |  Branch (500:7): [True: 0, False: 0]
  |  Branch (500:67): [True: 0, False: 0]
  ------------------
  501|      0|			sc_log(ctx, "Non fatal error: NON_REPUDIATION can be used only for the locally generated 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__
  |  |  ------------------
  ------------------
  502|       |
  503|      0|		if ((key_info->access_flags & SC_PKCS15_PRKEY_ACCESS_LOCAL)
  ------------------
  |  |  320|      0|#define SC_PKCS15_PRKEY_ACCESS_LOCAL		0x10
  ------------------
  |  Branch (503:7): [True: 0, False: 0]
  ------------------
  504|      0|				&& (key_info->usage & SC_PKCS15_PRKEY_USAGE_SIGN)
  ------------------
  |  |  307|      0|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
  |  Branch (504:8): [True: 0, False: 0]
  ------------------
  505|      0|				&& (key_info->usage & SC_PKCS15_PRKEY_USAGE_NONREPUDIATION))   {
  ------------------
  |  |  314|      0|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  ------------------
  |  Branch (505:8): [True: 0, False: 0]
  ------------------
  506|      0|			*(sdo->docp.non_repudiation.value + 0) = 1;
  507|      0|			*(sdo->data.prv_key.compulsory.value + 0) = IASECC_CRT_TAG_DST;
  ------------------
  |  |  107|      0|#define IASECC_CRT_TAG_DST	0xB6
  ------------------
  508|      0|		}
  509|       |
  510|      0|		sc_log(ctx, "non_repudiation %i", *(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__
  |  |  ------------------
  ------------------
  511|      0|		sc_log(ctx, "compulsory 0x%X", *(sdo->data.prv_key.compulsory.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__
  |  |  ------------------
  ------------------
  512|      0|	}
  513|      3|	else if (rv < 0) {
  ------------------
  |  Branch (513:11): [True: 3, False: 0]
  ------------------
  514|      3|		iasecc_sdo_free(card, sdo);
  515|      3|		LOG_TEST_RET(ctx, rv, "IasEcc: error while getting private key 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  516|      3|	}
  517|       |
  518|      0|	if (out)
  ------------------
  |  Branch (518:6): [True: 0, False: 0]
  ------------------
  519|      0|		*out = sdo;
  520|      0|	else
  521|      0|		iasecc_sdo_free(card, sdo);
  522|       |
  523|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  524|      0|}
pkcs15-iasecc.c:iasecc_pkcs15_new_file:
  191|    249|{
  192|    249|	struct sc_context *ctx = card->ctx;
  193|    249|	struct sc_file	*file = NULL;
  194|    249|	const char *_template = NULL;
  195|    249|	int rv;
  196|       |
  197|    249|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    249|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    249|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    249|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    249|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 249]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  198|    249|	sc_log(ctx, "type %X; num %i\n", type, num);
  ------------------
  |  |   71|    249|#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|    249|	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: 249]
  ------------------
  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: 249]
  ------------------
  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: 249]
  ------------------
  207|      0|			_template = "certificate";
  208|      0|			break;
  209|    249|		case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|    249|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (209:3): [True: 249, False: 0]
  ------------------
  210|    249|			_template = "public-data";
  211|    249|			break;
  212|      0|		default:
  ------------------
  |  Branch (212:3): [True: 0, False: 249]
  ------------------
  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|    249|	}
  215|       |
  216|    249|	sc_log(ctx, "df_info path '%s'\n", sc_print_path(&profile->df_info->file->path));
  ------------------
  |  |   71|    249|#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|    249|	rv = sc_profile_get_file(profile, _template, &file);
  218|    249|	if (rv == SC_ERROR_FILE_NOT_FOUND)   {
  ------------------
  |  |   51|    249|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (218:6): [True: 183, False: 66]
  ------------------
  219|    183|		struct sc_pkcs15_id     id;
  220|       |
  221|    183|		id.len = 1;
  222|    183|		id.value[0] = num & 0xFF;
  223|    183|		rv = sc_profile_instantiate_template(profile, "key-domain", &profile->df_info->file->path,
  224|    183|				_template, &id, &file);
  225|    183|	}
  226|    249|	LOG_TEST_RET(ctx, rv, "Error when getting file from template");
  ------------------
  |  |  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: 182, False: 67]
  |  |  |  |  ------------------
  |  |  |  |  169|    182|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    182|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    182|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    182|		return _ret; \
  |  |  |  |  172|    182|	} \
  |  |  |  |  173|    249|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 67]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  227|       |
  228|     67|	sc_log(ctx, "path(type:%X;path:%s)\n", file->path.type, sc_print_path(&file->path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  229|       |
  230|     67|	file->id = (file->id & 0xFF00) | (num & 0xFF);
  231|     67|	if (file->path.len == 0)   {
  ------------------
  |  Branch (231:6): [True: 61, False: 6]
  ------------------
  232|     61|		file->path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|     61|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  233|     61|		file->path.len = 2;
  234|     61|	}
  235|     67|	file->path.value[file->path.len - 2] = (file->id >> 8) & 0xFF;
  236|     67|	file->path.value[file->path.len - 1] = file->id & 0xFF;
  237|     67|	file->path.count = -1;
  238|       |
  239|     67|	sc_log(ctx, "file size %zu; ef type %i/%i; id %04X",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  240|     67|			file->size, file->type, file->ef_structure, file->id);
  241|     67|	sc_log(ctx, "path type %X; path '%s'", file->path.type, sc_print_path(&file->path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  242|       |
  243|     67|	if (out)
  ------------------
  |  Branch (243:6): [True: 67, False: 0]
  ------------------
  244|     67|		*out = file;
  245|      0|	else
  246|      0|		sc_file_free(file);
  247|       |
  248|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  249|     67|}
pkcs15-iasecc.c:iasecc_emu_store_data:
 1841|    249|{
 1842|    249|	struct sc_context *ctx = p15card->card->ctx;
 1843|    249|	int rv = SC_ERROR_NOT_IMPLEMENTED;
  ------------------
  |  |   97|    249|#define SC_ERROR_NOT_IMPLEMENTED		-1416
  ------------------
 1844|       |
 1845|    249|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    249|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    249|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    249|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    249|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 249]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1846|       |
 1847|    249|	switch (object->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|    249|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
 1848|      0|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|      0|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (1848:2): [True: 0, False: 249]
  ------------------
 1849|      0|		rv = iasecc_store_prvkey(p15card, profile, object, data, path);
 1850|      0|		break;
 1851|      0|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|      0|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (1851:2): [True: 0, False: 249]
  ------------------
 1852|      0|		rv = iasecc_store_pubkey(p15card, profile, object, data, path);
 1853|      0|		break;
 1854|      0|	case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (1854:2): [True: 0, False: 249]
  ------------------
 1855|      0|		rv = iasecc_store_cert(p15card, profile, object, data, path);
 1856|      0|		break;
 1857|    249|	case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|    249|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (1857:2): [True: 249, False: 0]
  ------------------
 1858|    249|		rv = iasecc_store_data_object(p15card, profile, object, data, path);
 1859|    249|		break;
 1860|      0|	default:
  ------------------
  |  Branch (1860:2): [True: 0, False: 249]
  ------------------
 1861|      0|		rv = SC_ERROR_NOT_IMPLEMENTED;
  ------------------
  |  |   97|      0|#define SC_ERROR_NOT_IMPLEMENTED		-1416
  ------------------
 1862|      0|		break;
 1863|    249|	}
 1864|       |
 1865|    249|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    249|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    249|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    249|	int _ret = r; \
  |  |  |  |  155|    249|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 248, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  156|    248|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    248|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 248, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    248|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    248|	} 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|    249|	return _ret; \
  |  |  |  |  163|    249|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1866|    249|}
pkcs15-iasecc.c:iasecc_store_data_object:
 1729|    249|{
 1730|    249|#define MAX_DATA_OBJS 32
 1731|    249|	struct sc_context *ctx = p15card->card->ctx;
 1732|    249|	struct sc_card *card = p15card->card;
 1733|    249|	struct sc_pkcs15_object *p15objects[MAX_DATA_OBJS];
 1734|    249|	struct sc_file *cfile = NULL, *file = NULL, *parent = NULL;
 1735|    249|	int rv, nn_objs, index, ii;
 1736|       |
 1737|    249|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    249|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    249|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    249|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    249|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 249]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1738|    249|	sc_log(ctx, "iasecc_store_data_object() authID '%s'", sc_pkcs15_print_id(&object->auth_id));
  ------------------
  |  |   71|    249|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1739|    249|	nn_objs = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_DATA_OBJECT, p15objects, MAX_DATA_OBJS);
  ------------------
  |  |  442|    249|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
              	nn_objs = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_DATA_OBJECT, p15objects, MAX_DATA_OBJS);
  ------------------
  |  | 1730|    249|#define MAX_DATA_OBJS 32
  ------------------
 1740|    249|	LOG_TEST_RET(ctx, nn_objs, "IasEcc get pkcs15 DATA objects error");
  ------------------
  |  |  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: 0, False: 249]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|    249|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 249]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1741|       |
 1742|    249|	for(index = 1; index < MAX_DATA_OBJS; index++)   {
  ------------------
  |  | 1730|    249|#define MAX_DATA_OBJS 32
  ------------------
  |  Branch (1742:17): [True: 249, False: 0]
  ------------------
 1743|    249|		rv = iasecc_pkcs15_new_file(profile, card, SC_PKCS15_TYPE_DATA_OBJECT, index, &file);
  ------------------
  |  |  442|    249|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
 1744|    249|		LOG_TEST_RET(ctx, rv, "iasecc_store_data_object() pkcs15 new DATA file error");
  ------------------
  |  |  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: 182, False: 67]
  |  |  |  |  ------------------
  |  |  |  |  169|    182|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    182|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    182|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    182|		return _ret; \
  |  |  |  |  172|    182|	} \
  |  |  |  |  173|    249|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 67]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1745|       |
 1746|     67|		for (ii=0; ii<nn_objs; ii++)   {
  ------------------
  |  Branch (1746:14): [True: 0, False: 67]
  ------------------
 1747|      0|			struct sc_pkcs15_data_info *info = (struct sc_pkcs15_data_info *)p15objects[ii]->data;
 1748|      0|			int file_id = info->path.value[info->path.len - 2] * 0x100 + info->path.value[info->path.len - 1];
 1749|       |
 1750|      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__
  |  |  ------------------
  ------------------
 1751|      0|			if (file->id == file_id)
  ------------------
  |  Branch (1751:8): [True: 0, False: 0]
  ------------------
 1752|      0|			   break;
 1753|      0|		}
 1754|       |
 1755|     67|		if (ii == nn_objs)
  ------------------
  |  Branch (1755:7): [True: 67, False: 0]
  ------------------
 1756|     67|			break;
 1757|      0|		sc_file_free(file);
 1758|      0|		file = NULL;
 1759|      0|	}
 1760|       |
 1761|     67|	if (index == MAX_DATA_OBJS)
  ------------------
  |  | 1730|     67|#define MAX_DATA_OBJS 32
  ------------------
  |  Branch (1761:6): [True: 0, False: 67]
  ------------------
 1762|     67|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1763|       |
 1764|     67|	do  {
 1765|     67|		const struct sc_acl_entry *acl;
 1766|       |
 1767|     67|		memset(object->access_rules, 0, sizeof(object->access_rules));
 1768|       |
 1769|     67|		object->access_rules[0].access_mode = SC_PKCS15_ACCESS_RULE_MODE_READ;
  ------------------
  |  |  335|     67|#define SC_PKCS15_ACCESS_RULE_MODE_READ         0x01
  ------------------
 1770|     67|		acl = sc_file_get_acl_entry(file, SC_AC_OP_READ);
  ------------------
  |  |  188|     67|#define SC_AC_OP_READ			22
  ------------------
 1771|     67|		sc_log(ctx, "iasecc_store_data_object() READ method %i", acl->method);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1772|     67|		if (acl->method == SC_AC_IDA)
  ------------------
  |  |  158|     67|#define SC_AC_IDA                       0x00000080 /* PKCS#15 authentication ID */
  ------------------
  |  Branch (1772:7): [True: 0, False: 67]
  ------------------
 1773|      0|			iasecc_reference_to_pkcs15_id (acl->key_ref, &object->access_rules[0].auth_id);
 1774|       |
 1775|     67|		object->access_rules[1].access_mode = SC_PKCS15_ACCESS_RULE_MODE_UPDATE;
  ------------------
  |  |  336|     67|#define SC_PKCS15_ACCESS_RULE_MODE_UPDATE       0x02
  ------------------
 1776|     67|		acl = sc_file_get_acl_entry(file, SC_AC_OP_UPDATE);
  ------------------
  |  |  189|     67|#define SC_AC_OP_UPDATE			23
  ------------------
 1777|     67|		sc_log(ctx, "iasecc_store_data_object() UPDATE method %i", acl->method);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1778|     67|		if (acl->method == SC_AC_IDA)
  ------------------
  |  |  158|     67|#define SC_AC_IDA                       0x00000080 /* PKCS#15 authentication ID */
  ------------------
  |  Branch (1778:7): [True: 0, False: 67]
  ------------------
 1779|      0|			iasecc_reference_to_pkcs15_id (acl->key_ref, &object->access_rules[1].auth_id);
 1780|       |
 1781|     67|		object->access_rules[2].access_mode = SC_PKCS15_ACCESS_RULE_MODE_DELETE;
  ------------------
  |  |  338|     67|#define SC_PKCS15_ACCESS_RULE_MODE_DELETE       0x08
  ------------------
 1782|     67|		acl = sc_file_get_acl_entry(file, SC_AC_OP_DELETE);
  ------------------
  |  |  168|     67|#define SC_AC_OP_DELETE			2
  ------------------
 1783|     67|		sc_log(ctx, "iasecc_store_data_object() UPDATE method %i", acl->method);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1784|     67|		if (acl->method == SC_AC_IDA)
  ------------------
  |  |  158|     67|#define SC_AC_IDA                       0x00000080 /* PKCS#15 authentication ID */
  ------------------
  |  Branch (1784:7): [True: 0, False: 67]
  ------------------
 1785|      0|			iasecc_reference_to_pkcs15_id (acl->key_ref, &object->access_rules[2].auth_id);
 1786|       |
 1787|     67|	} while(0);
  ------------------
  |  Branch (1787:10): [Folded, False: 67]
  ------------------
 1788|       |
 1789|     67|	rv = iasecc_file_convert_acls(ctx, profile, file);
 1790|     67|	LOG_TEST_GOTO_ERR(ctx, rv, "iasecc_store_data_object() cannot convert profile ACLs");
  ------------------
  |  |  184|     67|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     67|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     67|	int _ret = (r); \
  |  |  |  |  178|     67|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 67]
  |  |  |  |  ------------------
  |  |  |  |  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|     67|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 67]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1791|       |
 1792|     67|	rv = sc_profile_get_parent(profile, "public-data", &parent);
 1793|     67|	LOG_TEST_GOTO_ERR(ctx, rv, "iasecc_store_data_object() cannot get object parent");
  ------------------
  |  |  184|     67|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     67|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     67|	int _ret = (r); \
  |  |  |  |  178|     67|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 1, False: 66]
  |  |  |  |  ------------------
  |  |  |  |  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|     67|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 66]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1794|     66|	sc_log(ctx, "iasecc_store_data_object() parent path '%s'\n", sc_print_path(&parent->path));
  ------------------
  |  |   71|     66|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1795|       |
 1796|     66|	rv = sc_select_file(card, &parent->path, NULL);
 1797|     66|	LOG_TEST_GOTO_ERR(ctx, rv, "iasecc_store_data_object() cannot select parent");
  ------------------
  |  |  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: 6, False: 60]
  |  |  |  |  ------------------
  |  |  |  |  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|     66|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 60]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1798|       |
 1799|     60|	rv = sc_select_file(card, &file->path, &cfile);
 1800|     60|	if (!rv)   {
  ------------------
  |  Branch (1800:6): [True: 47, False: 13]
  ------------------
 1801|     47|		rv = sc_pkcs15init_authenticate(profile, p15card, cfile, SC_AC_OP_DELETE);
  ------------------
  |  |  168|     47|#define SC_AC_OP_DELETE			2
  ------------------
 1802|     47|		LOG_TEST_GOTO_ERR(ctx, rv, "iasecc_store_data_object() DELETE authentication failed");
  ------------------
  |  |  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: 9, False: 38]
  |  |  |  |  ------------------
  |  |  |  |  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|     47|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 38]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1803|       |
 1804|     38|		rv = iasecc_pkcs15_delete_file(p15card, profile, cfile);
 1805|     38|		LOG_TEST_GOTO_ERR(ctx, rv, "s_pkcs15init_store_data_object() delete pkcs15 file error");
  ------------------
  |  |  184|     38|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     38|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     38|	int _ret = (r); \
  |  |  |  |  178|     38|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 19, False: 19]
  |  |  |  |  ------------------
  |  |  |  |  179|     19|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     19|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     19|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     19|		goto err; \
  |  |  |  |  182|     19|	} \
  |  |  |  |  183|     38|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 19]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1806|     38|	}
 1807|     13|	else if (rv != SC_ERROR_FILE_NOT_FOUND)   {
  ------------------
  |  |   51|     13|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (1807:11): [True: 10, False: 3]
  ------------------
 1808|     10|		LOG_TEST_GOTO_ERR(ctx, rv, "iasecc_store_data_object() select file error");
  ------------------
  |  |  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: 10, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|     10|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     10|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     10|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     10|		goto err; \
  |  |  |  |  182|     10|	} \
  |  |  |  |  183|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1809|     10|	}
 1810|       |
 1811|     22|	rv = sc_pkcs15init_authenticate(profile, p15card, parent, SC_AC_OP_CREATE);
  ------------------
  |  |  169|     22|#define SC_AC_OP_CREATE			3
  ------------------
 1812|     22|	LOG_TEST_GOTO_ERR(ctx, rv, "iasecc_store_data_object() parent CREATE 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: 7, False: 15]
  |  |  |  |  ------------------
  |  |  |  |  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|     22|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 15]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1813|       |
 1814|     15|	file->size = data->len;
 1815|     15|	rv = sc_create_file(card, file);
 1816|     15|	LOG_TEST_GOTO_ERR(ctx, rv, "iasecc_store_data_object() cannot create DATA file");
  ------------------
  |  |  184|     15|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     15|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     15|	int _ret = (r); \
  |  |  |  |  178|     15|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 8, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      8|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      8|		goto err; \
  |  |  |  |  182|      8|	} \
  |  |  |  |  183|     15|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1817|       |
 1818|      7|	rv = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_UPDATE);
  ------------------
  |  |  189|      7|#define SC_AC_OP_UPDATE			23
  ------------------
 1819|      7|	LOG_TEST_GOTO_ERR(ctx, rv, "iasecc_store_data_object() data file UPDATE authentication failed");
  ------------------
  |  |  184|      7|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      7|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      7|	int _ret = (r); \
  |  |  |  |  178|      7|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 3, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  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|      7|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1820|       |
 1821|      4|	rv = sc_update_binary(card, 0, data->value, data->len, 0);
 1822|      4|	LOG_TEST_GOTO_ERR(ctx, rv, "iasecc_store_data_object() update DATA file 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: 3, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  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|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1823|       |
 1824|      1|	if (path)
  ------------------
  |  Branch (1824:6): [True: 1, False: 0]
  ------------------
 1825|      1|		*path = file->path;
 1826|     67|err:
 1827|     67|	sc_file_free(parent);
 1828|     67|	sc_file_free(file);
 1829|     67|	sc_file_free(cfile);
 1830|       |
 1831|     67|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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: 66, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  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|     66|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 66, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     66|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     66|	} 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|     67|	return _ret; \
  |  |  |  |  163|     67|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1832|     67|#undef MAX_DATA_OBJS
 1833|     67|}

sc_pkcs15init_get_isoApplet_ops:
  804|    173|{
  805|    173|	return &sc_pkcs15init_isoApplet_operations;
  806|    173|}
pkcs15-isoApplet.c:isoApplet_create_dir:
  183|     64|{
  184|     64|	sc_card_t *card = p15card->card;
  185|     64|	int r = SC_SUCCESS;
  ------------------
  |  |   28|     64|#define SC_SUCCESS				0
  ------------------
  186|       |
  187|     64|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     64|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     64|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     64|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     64|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 64]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  188|       |
  189|     64|	if(!profile || !df || !p15card->card->ctx)
  ------------------
  |  Branch (189:5): [True: 0, False: 64]
  |  Branch (189:17): [True: 0, False: 64]
  |  Branch (189:24): [True: 0, False: 64]
  ------------------
  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|     64|	r = sc_pkcs15init_create_file(profile, p15card, df);
  194|     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|     18|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 18, False: 46]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  195|     64|}
pkcs15-isoApplet.c:isoApplet_select_pin_reference:
  209|    151|{
  210|    151|	sc_card_t *card = p15card->card;
  211|    151|	int	preferred;
  212|    151|	int current;
  213|       |
  214|    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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  215|       |
  216|    151|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|    151|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (216:6): [True: 0, False: 151]
  ------------------
  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|    151|	current = auth_info->attrs.pin.reference;
  222|    151|	if (current < 0)
  ------------------
  |  Branch (222:6): [True: 99, False: 52]
  ------------------
  223|     99|	{
  224|     99|		current = 0;
  225|     99|	}
  226|       |
  227|    151|	if(current > 2)
  ------------------
  |  Branch (227:5): [True: 25, False: 126]
  ------------------
  228|     25|	{
  229|       |		/* Only two PINs supported: User PIN and PUK. */
  230|     25|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_TOO_MANY_OBJECTS);
  ------------------
  |  |  164|     25|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     25|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     25|	int _ret = r; \
  |  |  |  |  155|     25|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 25, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     25|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     25|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 25, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     25|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     25|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     25|	return _ret; \
  |  |  |  |  163|     25|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  231|     25|	}
  232|    126|	else
  233|    126|	{
  234|    126|		if(auth_info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN)
  ------------------
  |  |   60|    126|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  ------------------
  |  Branch (234:6): [True: 6, False: 120]
  ------------------
  235|      6|		{
  236|       |			/* PUK */
  237|      6|			preferred = 2;
  238|      6|		}
  239|    120|		else
  240|    120|		{
  241|       |			/* PIN */
  242|    120|			preferred = 1;
  243|    120|		}
  244|    126|	}
  245|       |
  246|    126|	auth_info->attrs.pin.reference = preferred;
  247|    126|	LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  248|    126|}
pkcs15-isoApplet.c:isoApplet_create_pin:
  260|    101|{
  261|    101|	sc_card_t *card = p15card->card;
  262|    101|	sc_pkcs15_auth_info_t *auth_info = (sc_pkcs15_auth_info_t *) pin_obj->data;
  263|    101|	struct sc_pkcs15_pin_attributes *pin_attrs = &auth_info->attrs.pin;
  264|    101|	int r;
  265|       |
  266|    101|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    101|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    101|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    101|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    101|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 101]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  267|       |
  268|    101|	if(!pin || !pin_len || !df)
  ------------------
  |  Branch (268:5): [True: 0, False: 101]
  |  Branch (268:13): [True: 0, False: 101]
  |  Branch (268:25): [True: 0, False: 101]
  ------------------
  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|    101|	if(pin_attrs->reference != 1 &&	pin_attrs->reference != 2)
  ------------------
  |  Branch (273:5): [True: 2, False: 99]
  |  Branch (273:34): [True: 0, False: 2]
  ------------------
  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|    101|	if(puk && puk_len)
  ------------------
  |  Branch (280:5): [True: 99, False: 2]
  |  Branch (280:12): [True: 99, False: 0]
  ------------------
  281|     99|	{
  282|       |		/* The PUK has a incremented reference, i.e. pins are odd, puks are equal (+1). */
  283|     99|		r = sc_change_reference_data(p15card->card, SC_AC_CHV,
  ------------------
  |  |  151|     99|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  284|     99|		                             pin_attrs->reference+1,
  285|     99|		                             NULL, 0,
  286|     99|		                             puk, puk_len, NULL);
  287|     99|		if(r < 0)
  ------------------
  |  Branch (287:6): [True: 45, False: 54]
  ------------------
  288|     45|		{
  289|     45|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  290|     45|		}
  291|     99|	}
  292|       |
  293|       |	/* Store PIN: (use CHANGE REFERENCE DATA). */
  294|     56|	r = sc_change_reference_data(p15card->card, SC_AC_CHV,
  ------------------
  |  |  151|     56|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  295|     56|	                             pin_attrs->reference,
  296|     56|	                             NULL, 0,
  297|     56|	                             pin, pin_len, NULL);
  298|     56|	LOG_TEST_RET(card->ctx, r, "Failed to set PIN");
  ------------------
  |  |  174|     56|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     56|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     56|	int _ret = (r); \
  |  |  |  |  168|     56|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 5, False: 51]
  |  |  |  |  ------------------
  |  |  |  |  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|     56|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 51]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  299|       |
  300|     51|	sc_pkcs15_pincache_add(p15card, pin_obj, pin, pin_len);
  301|     51|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|     51|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     51|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     51|	int _ret = r; \
  |  |  |  |  155|     51|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 51, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     51|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 51]
  |  |  |  |  ------------------
  |  |  |  |  157|     51|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     51|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     51|	return _ret; \
  |  |  |  |  163|     51|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  302|     51|}
pkcs15-isoApplet.c:isoApplet_select_key_reference:
  668|     55|{
  669|     55|	int rv = SC_SUCCESS;
  ------------------
  |  |   28|     55|#define SC_SUCCESS				0
  ------------------
  670|     55|	sc_card_t *card = p15card->card;
  671|       |
  672|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  673|       |
  674|     55|	if(key_info->key_reference < ISOAPPLET_KEY_ID_MIN)
  ------------------
  |  |   37|     55|#define ISOAPPLET_KEY_ID_MIN 0
  ------------------
  |  Branch (674:5): [True: 0, False: 55]
  ------------------
  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|     55|	if(key_info->key_reference > ISOAPPLET_KEY_ID_MAX)
  ------------------
  |  |   38|     55|#define ISOAPPLET_KEY_ID_MAX 15
  ------------------
  |  Branch (679:5): [True: 0, False: 55]
  ------------------
  680|      0|	{
  681|      0|		rv = SC_ERROR_TOO_MANY_OBJECTS;
  ------------------
  |  |   86|      0|#define SC_ERROR_TOO_MANY_OBJECTS		-1405
  ------------------
  682|      0|	}
  683|     55|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  684|     55|}
pkcs15-isoApplet.c:isoApplet_create_key:
  657|     55|{
  658|     55|	sc_card_t *card = p15card->card;
  659|     55|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  660|     55|}
pkcs15-isoApplet.c:isoApplet_get_curve:
  317|     42|{
  318|     42|	int i;
  319|       |
  320|     42|	if(!oid)
  ------------------
  |  Branch (320:5): [True: 0, False: 42]
  ------------------
  321|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  322|       |
  323|       |	/* Search the curve parameters. */
  324|    294|	for (i = 0; curves[i].oid.value; i++)
  ------------------
  |  Branch (324:14): [True: 294, False: 0]
  ------------------
  325|    294|	{
  326|    294|		if (oid_len == curves[i].oid.len && memcmp(oid, curves[i].oid.value, curves[i].oid.len) == 0)
  ------------------
  |  Branch (326:7): [True: 84, False: 210]
  |  Branch (326:39): [True: 42, False: 42]
  ------------------
  327|     42|		{
  328|     42|			*curve_out = &curves[i];
  329|     42|			return SC_SUCCESS;
  ------------------
  |  |   28|     42|#define SC_SUCCESS				0
  ------------------
  330|     42|		}
  331|    294|	}
  332|       |
  333|      0|	return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  334|     42|}
pkcs15-isoApplet.c:isoApplet_generate_key:
  610|     55|{
  611|     55|	int r;
  612|     55|	sc_pkcs15_prkey_info_t *key_info = (sc_pkcs15_prkey_info_t *) obj->data;
  613|     55|	sc_file_t *privKeyFile=NULL;
  614|     55|	sc_card_t *card = p15card->card;
  615|       |
  616|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  617|       |
  618|       |	/* Authentication stuff. */
  619|     55|	r = sc_profile_get_file_by_path(profile, &key_info->path, &privKeyFile);
  620|     55|	if(r < 0 || !privKeyFile)
  ------------------
  |  Branch (620:5): [True: 12, False: 43]
  |  Branch (620:14): [True: 0, False: 43]
  ------------------
  621|     12|	{
  622|     12|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  623|     12|	}
  624|     43|	r = sc_pkcs15init_authenticate(profile, p15card, privKeyFile, SC_AC_OP_CREATE_EF);
  ------------------
  |  |  193|     43|#define SC_AC_OP_CREATE_EF		27
  ------------------
  625|     43|	if(r < 0)
  ------------------
  |  Branch (625:5): [True: 1, False: 42]
  ------------------
  626|      1|	{
  627|      1|		sc_file_free(privKeyFile);
  628|      1|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  629|      1|	}
  630|     42|	sc_file_free(privKeyFile);
  631|       |
  632|       |	/* Generate the key. */
  633|     42|	switch(obj->type)
  634|     42|	{
  635|      0|	case SC_PKCS15_TYPE_PRKEY_RSA:
  ------------------
  |  |  419|      0|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (635:2): [True: 0, False: 42]
  ------------------
  636|      0|		r = isoApplet_generate_key_rsa(key_info, card, pubkey);
  637|      0|		break;
  638|       |
  639|     42|	case SC_PKCS15_TYPE_PRKEY_EC:
  ------------------
  |  |  421|     42|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  |  Branch (639:2): [True: 42, False: 0]
  ------------------
  640|     42|		r = isoApplet_generate_key_ec(key_info, card, pubkey);
  641|     42|		break;
  642|       |
  643|      0|	default:
  ------------------
  |  Branch (643:2): [True: 0, False: 42]
  ------------------
  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|     42|	}
  647|       |
  648|     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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  649|     42|}
pkcs15-isoApplet.c:isoApplet_generate_key_ec:
  447|     42|{
  448|     42|	int	r;
  449|     42|	const struct ec_curve *curve = NULL;
  450|     42|	struct sc_ec_parameters *alg_id_params = NULL;
  451|     42|	sc_cardctl_isoApplet_genkey_t args;
  452|     42|	const struct sc_ec_parameters *info_ecp =
  453|     42|	    (struct sc_ec_parameters *) key_info->params.data;
  454|       |
  455|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  456|       |
  457|     42|	memset(&args, 0, sizeof(args));
  458|       |
  459|       |	/* Check key size: */
  460|     42|	if(key_info->field_length == 0)
  ------------------
  |  Branch (460:5): [True: 0, False: 42]
  ------------------
  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|     42|	r = isoApplet_get_curve(info_ecp->der.value, info_ecp->der.len, &curve);
  468|     42|	if(r < 0)
  ------------------
  |  Branch (468:5): [True: 0, False: 42]
  ------------------
  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|     42|	args.pubkey.ec.params.prime.value			= curve->prime.value;
  478|     42|	args.pubkey.ec.params.prime.len				= curve->prime.len;
  479|     42|	args.pubkey.ec.params.coefficientA.value	= curve->coefficientA.value;
  480|     42|	args.pubkey.ec.params.coefficientA.len		= curve->coefficientA.len;
  481|     42|	args.pubkey.ec.params.coefficientB.value	= curve->coefficientB.value;
  482|     42|	args.pubkey.ec.params.coefficientB.len		= curve->coefficientB.len;
  483|     42|	args.pubkey.ec.params.basePointG.value 		= curve->basePointG.value;
  484|     42|	args.pubkey.ec.params.basePointG.len		= curve->basePointG.len;
  485|     42|	args.pubkey.ec.params.order.value 			= curve->order.value;
  486|     42|	args.pubkey.ec.params.order.len				= curve->order.len;
  487|     42|	args.pubkey.ec.params.coFactor.value 		= curve->coFactor.value;
  488|     42|	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|     42|	args.pubkey.ec.ecPointQ.len = 1 + BYTES4BITS(key_info->field_length) * 2;
  ------------------
  |  |  146|     42|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  492|     42|	args.pubkey.ec.ecPointQ.value = malloc(args.pubkey.ec.ecPointQ.len);
  493|     42|	if(!args.pubkey.ec.ecPointQ.value)
  ------------------
  |  Branch (493:5): [True: 0, False: 42]
  ------------------
  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|     42|	args.algorithm_ref = SC_ISOAPPLET_ALG_REF_EC_GEN;
  ------------------
  |  |  993|     42|#define SC_ISOAPPLET_ALG_REF_EC_GEN 0xEC
  ------------------
  500|     42|	args.priv_key_ref = key_info->key_reference;
  501|       |
  502|       |	/* On-card key generation */
  503|     42|	r = sc_card_ctl(card, SC_CARDCTL_ISOAPPLET_GENERATE_KEY, &args);
  504|     42|	if (r < 0)
  ------------------
  |  Branch (504:6): [True: 42, False: 0]
  ------------------
  505|     42|	{
  506|     42|		sc_log(card->ctx, "%s: Error in card_ctl.", sc_strerror(r));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  507|     42|		goto out;
  508|     42|	}
  509|       |
  510|       |	/* Extract and compose the public key. */
  511|      0|	pubkey->algorithm = SC_ALGORITHM_EC;
  ------------------
  |  |   70|      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;
  ------------------
  |  |   70|      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|     42|out:
  562|     42|	if(args.pubkey.ec.ecPointQ.value)
  ------------------
  |  Branch (562:5): [True: 42, False: 0]
  ------------------
  563|     42|	{
  564|     42|		free(args.pubkey.ec.ecPointQ.value);
  565|     42|		args.pubkey.ec.ecPointQ.value = NULL;
  566|     42|	}
  567|     42|	if(r < 0 && pubkey)
  ------------------
  |  Branch (567:5): [True: 42, False: 0]
  |  Branch (567:14): [True: 42, False: 0]
  ------------------
  568|     42|	{
  569|     42|		if(pubkey->alg_id)
  ------------------
  |  Branch (569:6): [True: 0, False: 42]
  ------------------
  570|      0|		{
  571|      0|			free(pubkey->alg_id);
  572|      0|			pubkey->alg_id = NULL;
  573|      0|		}
  574|     42|		if(pubkey->u.ec.params.der.value)
  ------------------
  |  Branch (574:6): [True: 42, False: 0]
  ------------------
  575|     42|		{
  576|     42|			free(pubkey->u.ec.params.der.value);
  577|     42|			pubkey->u.ec.params.der.value = NULL;
  578|     42|			pubkey->u.ec.params.der.len = 0;
  579|     42|		}
  580|     42|		if(pubkey->u.ec.params.named_curve)
  ------------------
  |  Branch (580:6): [True: 42, False: 0]
  ------------------
  581|     42|		{
  582|     42|			free(pubkey->u.ec.params.named_curve);
  583|     42|			pubkey->u.ec.params.named_curve = NULL;
  584|     42|		}
  585|     42|		if(pubkey->u.ec.ecpointQ.value)
  ------------------
  |  Branch (585:6): [True: 0, False: 42]
  ------------------
  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|     42|		memset(pubkey, 0, sizeof(sc_pkcs15_pubkey_t));
  592|     42|	}
  593|     42|	if(r < 0 && alg_id_params)
  ------------------
  |  Branch (593:5): [True: 42, False: 0]
  |  Branch (593:14): [True: 0, False: 42]
  ------------------
  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|     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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  604|     42|}

sc_pkcs15init_unbind:
  428|  6.63k|{
  429|  6.63k|	int r;
  430|  6.63k|	struct sc_context *ctx = profile->card->ctx;
  431|       |
  432|  6.63k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  6.63k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  6.63k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  6.63k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  6.63k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 6.63k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  433|  6.63k|	sc_log(ctx, "Pksc15init Unbind: %i:%p:%i", profile->dirty, profile->p15_data, profile->pkcs15.do_last_update);
  ------------------
  |  |   71|  6.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__
  |  |  ------------------
  ------------------
  434|  6.63k|	if (profile->dirty != 0 && profile->p15_data != NULL && profile->pkcs15.do_last_update) {
  ------------------
  |  Branch (434:6): [True: 884, False: 5.74k]
  |  Branch (434:29): [True: 708, False: 176]
  |  Branch (434:58): [True: 707, False: 1]
  ------------------
  435|    707|		r = sc_pkcs15init_update_lastupdate(profile->p15_data, profile);
  436|    707|		if (r < 0)
  ------------------
  |  Branch (436:7): [True: 129, False: 578]
  ------------------
  437|    129|			sc_log(ctx, "Failed to update TokenInfo: %s", sc_strerror(r));
  ------------------
  |  |   71|    129|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  438|    707|	}
  439|  6.63k|	sc_profile_free(profile);
  440|  6.63k|}
sc_pkcs15init_set_p15card:
  445|  3.97k|{
  446|  3.97k|	struct sc_context *ctx = p15card->card->ctx;
  447|  3.97k|	struct sc_pkcs15_object *p15objects[10];
  448|  3.97k|	int i, r, nn_objs;
  449|       |
  450|  3.97k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  3.97k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.97k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.97k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.97k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.97k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  451|       |
  452|       |	/* Prepare pin-domain instantiation:
  453|       |	 * for every present local User PIN, add to the profile EF list the named PIN path. */
  454|  3.97k|	nn_objs = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_AUTH_PIN, p15objects, 10);
  ------------------
  |  |  445|  3.97k|#define SC_PKCS15_TYPE_AUTH_PIN			0x601
  ------------------
  455|  5.14k|	for (i = 0; i < nn_objs; i++) {
  ------------------
  |  Branch (455:14): [True: 1.16k, False: 3.97k]
  ------------------
  456|  1.16k|		struct sc_pkcs15_auth_info *auth_info = (struct sc_pkcs15_auth_info *) p15objects[i]->data;
  457|  1.16k|		struct sc_pkcs15_pin_attributes *pin_attrs = &auth_info->attrs.pin;
  458|  1.16k|		struct sc_file *file = NULL;
  459|       |
  460|  1.16k|		if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_SO_PIN)
  ------------------
  |  |   61|  1.16k|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (460:7): [True: 28, False: 1.13k]
  ------------------
  461|     28|			continue;
  462|  1.13k|		if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN)
  ------------------
  |  |   60|  1.13k|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  ------------------
  |  Branch (462:7): [True: 554, False: 580]
  ------------------
  463|    554|			continue;
  464|    580|		if (!auth_info->path.len)
  ------------------
  |  Branch (464:7): [True: 554, False: 26]
  ------------------
  465|    554|			continue;
  466|       |
  467|     26|		r = sc_profile_get_file_by_path(profile, &auth_info->path, &file);
  468|     26|                if (r == SC_ERROR_FILE_NOT_FOUND)   {
  ------------------
  |  |   51|     26|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (468:21): [True: 24, False: 2]
  ------------------
  469|     24|			if (!sc_select_file(p15card->card, &auth_info->path, &file))   {
  ------------------
  |  Branch (469:8): [True: 13, False: 11]
  ------------------
  470|     13|				char pin_name[16];
  471|       |
  472|     13|				sprintf(pin_name, "pin-dir-%02X%02X", file->path.value[file->path.len - 2],
  473|     13|						file->path.value[file->path.len - 1]);
  474|     13|				sc_log(ctx, "add '%s' to profile file list", pin_name);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  475|     13|				sc_profile_add_file(profile, pin_name, file);
  476|     13|			}
  477|     24|		}
  478|       |
  479|     26|		sc_file_free(file);
  480|     26|	}
  481|       |
  482|  3.97k|	profile->p15_data = p15card;
  483|  3.97k|	sc_log(ctx, "sc_pkcs15init_set_p15card() returns");
  ------------------
  |  |   71|  3.97k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  484|  3.97k|}
sc_pkcs15init_set_lifecycle:
  492|  16.0k|{
  493|  16.0k|	return sc_card_ctl(card, SC_CARDCTL_LIFECYCLE_SET, &lcycle);
  494|  16.0k|}
sc_pkcs15init_erase_card:
  503|  3.97k|{
  504|  3.97k|	struct sc_context *ctx = NULL;
  505|  3.97k|	int rv;
  506|       |
  507|  3.97k|	if (!p15card)
  ------------------
  |  Branch (507:6): [True: 0, False: 3.97k]
  ------------------
  508|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  509|       |
  510|  3.97k|	ctx = p15card->card->ctx;
  511|  3.97k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  3.97k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.97k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.97k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.97k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.97k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  512|       |	/* Needs the 'SOPIN' AUTH pkcs15 object.
  513|       |	 * So that, SOPIN can be found by it's reference. */
  514|  3.97k|	if (sc_pkcs15_bind(p15card->card, aid, &p15card) >= 0)
  ------------------
  |  Branch (514:6): [True: 580, False: 3.39k]
  ------------------
  515|    580|		profile->p15_data = p15card;
  516|       |
  517|  3.97k|	if (profile->ops->erase_card == NULL)
  ------------------
  |  Branch (517:6): [True: 364, False: 3.61k]
  ------------------
  518|  3.97k|		LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|    364|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    364|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    364|	int _ret = r; \
  |  |  |  |  155|    364|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 364, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    364|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    364|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 364, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    364|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    364|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    364|	return _ret; \
  |  |  |  |  163|    364|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  519|       |
  520|  3.61k|	rv = profile->ops->erase_card(profile, p15card);
  521|       |
  522|  3.61k|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|  3.61k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.61k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.61k|	int _ret = r; \
  |  |  |  |  155|  3.61k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.61k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.61k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  2.56k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.56k, False: 1.05k]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.61k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.61k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|  3.61k|	return _ret; \
  |  |  |  |  163|  3.61k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  523|  3.61k|}
sc_pkcs15init_erase_card_recursively:
  529|    215|{
  530|    215|	struct sc_file	*df = profile->df_info->file, *dir;
  531|    215|	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|    215|	if (sc_profile_get_file(profile, "DIR", &dir) >= 0) {
  ------------------
  |  Branch (540:6): [True: 29, False: 186]
  ------------------
  541|     29|		r = sc_pkcs15init_rmdir(p15card, profile, dir);
  542|     29|		sc_file_free(dir);
  543|     29|		if (r < 0 && r != SC_ERROR_FILE_NOT_FOUND)   {
  ------------------
  |  |   51|     28|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (543:7): [True: 28, False: 1]
  |  Branch (543:16): [True: 21, False: 7]
  ------------------
  544|     21|			sc_free_apps(p15card->card);
  545|     21|			return r;
  546|     21|		}
  547|     29|	}
  548|       |
  549|    194|	r = sc_select_file(p15card->card, &df->path, &df);
  550|    194|	if (r >= 0) {
  ------------------
  |  Branch (550:6): [True: 11, False: 183]
  ------------------
  551|     11|		r = sc_pkcs15init_rmdir(p15card, profile, df);
  552|     11|		sc_file_free(df);
  553|     11|	}
  554|    194|	if (r == SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|    194|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (554:6): [True: 3, False: 191]
  ------------------
  555|      3|		r = 0;
  556|       |
  557|    194|	sc_free_apps(p15card->card);
  558|    194|	return r;
  559|    215|}
sc_pkcs15init_delete_by_path:
  565|  1.38k|{
  566|  1.38k|	struct sc_context *ctx = p15card->card->ctx;
  567|  1.38k|	struct sc_file *parent = NULL, *file = NULL;
  568|  1.38k|	struct sc_path path;
  569|  1.38k|	int rv;
  570|       |	/*int file_type = SC_FILE_TYPE_DF;*/
  571|       |
  572|  1.38k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  1.38k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.38k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.38k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.38k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.38k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  573|  1.38k|	sc_log(ctx, "trying to delete '%s'", sc_print_path(file_path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  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|  1.38k|	path = *file_path;
  584|  1.38k|	rv = sc_select_file(p15card->card, &path, &file);
  585|  1.38k|	LOG_TEST_RET(ctx, rv, "cannot select file to delete");
  ------------------
  |  |  174|  1.38k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.38k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.38k|	int _ret = (r); \
  |  |  |  |  168|  1.38k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 815, False: 573]
  |  |  |  |  ------------------
  |  |  |  |  169|    815|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    815|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    815|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    815|		return _ret; \
  |  |  |  |  172|    815|	} \
  |  |  |  |  173|  1.38k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 573]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  586|       |
  587|    573|	if (sc_file_get_acl_entry(file, SC_AC_OP_DELETE_SELF))   {
  ------------------
  |  |  174|    573|#define SC_AC_OP_DELETE_SELF		8
  ------------------
  |  Branch (587:6): [True: 2, False: 571]
  ------------------
  588|      2|		sc_log(ctx, "Found 'DELETE-SELF' acl");
  ------------------
  |  |   71|      2|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  589|      2|		rv = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_DELETE_SELF);
  ------------------
  |  |  174|      2|#define SC_AC_OP_DELETE_SELF		8
  ------------------
  590|      2|		sc_file_free(file);
  591|      2|	}
  592|    571|	else if (sc_file_get_acl_entry(file, SC_AC_OP_DELETE))   {
  ------------------
  |  |  168|    571|#define SC_AC_OP_DELETE			2
  ------------------
  |  Branch (592:11): [True: 195, False: 376]
  ------------------
  593|    195|		sc_log(ctx, "Found 'DELETE' acl");
  ------------------
  |  |   71|    195|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  594|    195|	        rv = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_DELETE);
  ------------------
  |  |  168|    195|#define SC_AC_OP_DELETE			2
  ------------------
  595|    195|		sc_file_free(file);
  596|    195|	}
  597|    376|	else    {
  598|    376|		sc_log(ctx, "Try to get the parent's 'DELETE' access");
  ------------------
  |  |   71|    376|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  599|       |		/*file_type = file->type;*/
  600|    376|		if (file_path->len >= 2) {
  ------------------
  |  Branch (600:7): [True: 352, False: 24]
  ------------------
  601|       |			/* Select the parent DF */
  602|    352|			path.len -= 2;
  603|    352|			rv = sc_select_file(p15card->card, &path, &parent);
  604|    352|			if (rv < 0)
  ------------------
  |  Branch (604:8): [True: 71, False: 281]
  ------------------
  605|     71|				sc_file_free(file);
  606|    352|			LOG_TEST_RET(ctx, rv, "Cannot select parent");
  ------------------
  |  |  174|    352|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    352|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    352|	int _ret = (r); \
  |  |  |  |  168|    352|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 71, False: 281]
  |  |  |  |  ------------------
  |  |  |  |  169|     71|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     71|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     71|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     71|		return _ret; \
  |  |  |  |  172|     71|	} \
  |  |  |  |  173|    352|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 281]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  607|       |
  608|    281|			rv = sc_pkcs15init_authenticate(profile, p15card, parent, SC_AC_OP_DELETE);
  ------------------
  |  |  168|    281|#define SC_AC_OP_DELETE			2
  ------------------
  609|    281|			sc_file_free(parent);
  610|    281|			sc_file_free(file);
  611|    281|			LOG_TEST_RET(ctx, rv, "parent 'DELETE' authentication failed");
  ------------------
  |  |  174|    281|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    281|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    281|	int _ret = (r); \
  |  |  |  |  168|    281|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 21, False: 260]
  |  |  |  |  ------------------
  |  |  |  |  169|     21|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     21|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     21|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     21|		return _ret; \
  |  |  |  |  172|     21|	} \
  |  |  |  |  173|    281|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 260]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  612|    281|		}
  613|     24|		else {
  614|       |			/* No 'DELETE' ACL of the file and not deleted for parent */
  615|     24|			rv = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|     24|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  616|     24|			sc_file_free(file);
  617|     24|		}
  618|    376|	}
  619|    481|	LOG_TEST_RET(ctx, rv, "'DELETE' authentication failed");
  ------------------
  |  |  174|    481|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    481|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    481|	int _ret = (r); \
  |  |  |  |  168|    481|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 80, False: 401]
  |  |  |  |  ------------------
  |  |  |  |  169|     80|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     80|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     80|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     80|		return _ret; \
  |  |  |  |  172|     80|	} \
  |  |  |  |  173|    481|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 401]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  620|       |
  621|       |	/* Reselect file to delete: current path could be changed by 'verify PIN' procedure */
  622|    401|	path = *file_path;
  623|    401|	rv = sc_select_file(p15card->card, &path, &file);
  624|    401|	LOG_TEST_RET(ctx, rv, "cannot select file to delete");
  ------------------
  |  |  174|    401|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    401|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    401|	int _ret = (r); \
  |  |  |  |  168|    401|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 91, False: 310]
  |  |  |  |  ------------------
  |  |  |  |  169|     91|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     91|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     91|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     91|		return _ret; \
  |  |  |  |  172|     91|	} \
  |  |  |  |  173|    401|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 310]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  625|       |
  626|    310|	memset(&path, 0, sizeof(path));
  627|    310|	path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|    310|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  628|    310|	if (file_path->len < 2) {
  ------------------
  |  Branch (628:6): [True: 1, False: 309]
  ------------------
  629|      1|		sc_file_free(file);
  630|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  631|      1|	}
  632|    309|	path.value[0] = file_path->value[file_path->len - 2];
  633|    309|	path.value[1] = file_path->value[file_path->len - 1];
  634|    309|	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|    309|	sc_log(ctx, "Now really delete file");
  ------------------
  |  |   71|    309|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  645|    309|	rv = sc_delete_file(p15card->card, &path);
  646|    309|	sc_file_free(file);
  647|    309|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    309|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    309|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    309|	int _ret = r; \
  |  |  |  |  155|    309|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 309, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    309|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    191|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 191, False: 118]
  |  |  |  |  ------------------
  |  |  |  |  157|    309|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    309|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    309|	return _ret; \
  |  |  |  |  163|    309|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  648|    309|}
sc_pkcs15init_rmdir:
  659|     41|{
  660|     41|	struct sc_context *ctx = p15card->card->ctx;
  661|     41|	unsigned char buffer[1024];
  662|     41|	struct sc_path	path;
  663|     41|	struct sc_file	*file, *parent;
  664|     41|	int		r = 0, nfids;
  665|       |
  666|     41|	if (df == NULL)
  ------------------
  |  Branch (666:6): [True: 0, False: 41]
  ------------------
  667|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  668|     41|	sc_log(ctx, "sc_pkcs15init_rmdir(%s)", sc_print_path(&df->path));
  ------------------
  |  |   71|     41|#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|     41|	if (df->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|     41|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (670:6): [True: 23, False: 18]
  ------------------
  671|     23|		r = sc_pkcs15init_authenticate(profile, p15card, df, SC_AC_OP_LIST_FILES);
  ------------------
  |  |  172|     23|#define SC_AC_OP_LIST_FILES		6
  ------------------
  672|     23|		if (r < 0)
  ------------------
  |  Branch (672:7): [True: 0, False: 23]
  ------------------
  673|      0|			return r;
  674|     23|		r = sc_list_files(p15card->card, buffer, sizeof(buffer));
  675|     23|		if (r < 0)
  ------------------
  |  Branch (675:7): [True: 13, False: 10]
  ------------------
  676|     13|			return r;
  677|       |
  678|     10|		path = df->path;
  679|     10|		path.len += 2;
  680|     10|		if (path.len > SC_MAX_PATH_SIZE)
  ------------------
  |  |   47|     10|#define SC_MAX_PATH_SIZE		16
  ------------------
  |  Branch (680:7): [True: 2, False: 8]
  ------------------
  681|      2|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      2|#define SC_ERROR_INTERNAL			-1400
  ------------------
  682|       |
  683|      8|		nfids = r / 2;
  684|      9|		while (r >= 0 && nfids--) {
  ------------------
  |  Branch (684:10): [True: 8, False: 1]
  |  Branch (684:20): [True: 3, False: 5]
  ------------------
  685|      3|			path.value[path.len-2] = buffer[2*nfids];
  686|      3|			path.value[path.len-1] = buffer[2*nfids+1];
  687|      3|			r = sc_select_file(p15card->card, &path, &file);
  688|      3|			if (r < 0) {
  ------------------
  |  Branch (688:8): [True: 2, False: 1]
  ------------------
  689|      2|				if (r == SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|      2|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (689:9): [True: 0, False: 2]
  ------------------
  690|      0|					continue;
  691|      2|				break;
  692|      2|			}
  693|      1|			r = sc_pkcs15init_rmdir(p15card, profile, file);
  694|      1|			sc_file_free(file);
  695|      1|		}
  696|       |
  697|      8|		if (r < 0)
  ------------------
  |  Branch (697:7): [True: 3, False: 5]
  ------------------
  698|      3|			return r;
  699|      8|	}
  700|       |
  701|       |	/* Select the parent DF */
  702|     23|	path = df->path;
  703|     23|	if (path.len <= 2)
  ------------------
  |  Branch (703:6): [True: 3, False: 20]
  ------------------
  704|      3|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      3|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  705|     20|	path.len -= 2;
  706|     20|	r = sc_select_file(p15card->card, &path, &parent);
  707|     20|	if (r < 0)
  ------------------
  |  Branch (707:6): [True: 12, False: 8]
  ------------------
  708|     12|		return r;
  709|       |
  710|      8|	r = sc_pkcs15init_authenticate(profile, p15card, df, SC_AC_OP_DELETE);
  ------------------
  |  |  168|      8|#define SC_AC_OP_DELETE			2
  ------------------
  711|      8|	if (r < 0) {
  ------------------
  |  Branch (711:6): [True: 1, False: 7]
  ------------------
  712|      1|		sc_file_free(parent);
  713|      1|		return r;
  714|      1|	}
  715|      7|	r = sc_pkcs15init_authenticate(profile, p15card, parent, SC_AC_OP_DELETE);
  ------------------
  |  |  168|      7|#define SC_AC_OP_DELETE			2
  ------------------
  716|      7|	sc_file_free(parent);
  717|      7|	if (r < 0)
  ------------------
  |  Branch (717:6): [True: 1, False: 6]
  ------------------
  718|      1|		return r;
  719|       |
  720|      6|	memset(&path, 0, sizeof(path));
  721|      6|	path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|      6|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  722|      6|	path.value[0] = df->id >> 8;
  723|      6|	path.value[1] = df->id & 0xFF;
  724|      6|	path.len = 2;
  725|       |
  726|       |	/* ensure that the card is in the correct lifecycle */
  727|      6|	r = sc_pkcs15init_set_lifecycle(p15card->card, SC_CARDCTRL_LIFECYCLE_ADMIN);
  728|      6|	if (r < 0 && r != SC_ERROR_NOT_SUPPORTED)
  ------------------
  |  |   89|      3|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  |  Branch (728:6): [True: 3, False: 3]
  |  Branch (728:15): [True: 2, False: 1]
  ------------------
  729|      2|		return r;
  730|       |
  731|      4|	r = sc_delete_file(p15card->card, &path);
  732|      4|	return r;
  733|      6|}
sc_pkcs15init_finalize_card:
  738|  3.97k|{
  739|  3.97k|	if (profile->ops->finalize_card == NULL)
  ------------------
  |  Branch (739:6): [True: 2.75k, False: 1.22k]
  ------------------
  740|  2.75k|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|  2.75k|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  741|  1.22k|	return profile->ops->finalize_card(card);
  742|  3.97k|}
sc_pkcs15init_add_app:
  781|  6.63k|{
  782|  6.63k|	struct sc_context *ctx = card->ctx;
  783|  6.63k|	struct sc_pkcs15_card	*p15card = profile->p15_spec;
  784|  6.63k|	struct sc_pkcs15_auth_info pin_ainfo, puk_ainfo;
  785|  6.63k|	struct sc_pkcs15_pin_attributes *pin_attrs = &pin_ainfo.attrs.pin;
  786|  6.63k|	struct sc_pkcs15_object	*pin_obj = NULL;
  787|  6.63k|	struct sc_app_info	*app;
  788|  6.63k|	struct sc_file		*df = profile->df_info->file;
  789|  6.63k|	int			r = SC_SUCCESS;
  ------------------
  |  |   28|  6.63k|#define SC_SUCCESS				0
  ------------------
  790|  6.63k|	int			has_so_pin = args->so_pin_len != 0;
  791|       |
  792|  6.63k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  6.63k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  6.63k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  6.63k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  6.63k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 6.63k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  793|  6.63k|	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|  6.63k|	p15card->opts.use_pin_cache = 1;
  800|       |
  801|  6.63k|	if (card->app_count >= SC_MAX_CARD_APPS)
  ------------------
  |  |   33|  6.63k|#define SC_MAX_CARD_APPS		8
  ------------------
  |  Branch (801:6): [True: 0, False: 6.63k]
  ------------------
  802|  6.63k|		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|  6.63k|	if (!has_so_pin && (card->reader->capabilities & SC_READER_CAP_PIN_PAD)) {
  ------------------
  |  |  376|      0|#define SC_READER_CAP_PIN_PAD	0x00000002
  ------------------
  |  Branch (805:6): [True: 0, False: 6.63k]
  |  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|  6.63k|	if (has_so_pin) {
  ------------------
  |  Branch (812:6): [True: 6.63k, False: 0]
  ------------------
  813|  6.63k|		const char	*pin_label;
  814|       |
  815|  6.63k|		if (args->so_pin_len) {
  ------------------
  |  Branch (815:7): [True: 6.63k, False: 0]
  ------------------
  816|  6.63k|			sc_profile_get_pin_info(profile, SC_PKCS15INIT_SO_PIN, &pin_ainfo);
  ------------------
  |  |  169|  6.63k|#define SC_PKCS15INIT_SO_PIN		0
  ------------------
  817|  6.63k|			r = sc_pkcs15init_qualify_pin(card, "SO PIN", args->so_pin_len, &pin_ainfo);
  818|  6.63k|			LOG_TEST_RET(ctx, r, "Failed to qualify SO PIN");
  ------------------
  |  |  174|  6.63k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  6.63k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  6.63k|	int _ret = (r); \
  |  |  |  |  168|  6.63k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 4.73k, False: 1.89k]
  |  |  |  |  ------------------
  |  |  |  |  169|  4.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|  4.73k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  4.73k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  4.73k|		return _ret; \
  |  |  |  |  172|  4.73k|	} \
  |  |  |  |  173|  6.63k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.89k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  819|  6.63k|		}
  820|       |
  821|       |		/* Path encoded only for local SO PIN */
  822|  1.89k|		if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_LOCAL)
  ------------------
  |  |   55|  1.89k|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
  |  Branch (822:7): [True: 1.70k, False: 188]
  ------------------
  823|  1.70k|			pin_ainfo.path = df->path;
  824|       |
  825|       |		/* Select the PIN reference */
  826|  1.89k|		if (profile->ops->select_pin_reference) {
  ------------------
  |  Branch (826:7): [True: 1.76k, False: 134]
  ------------------
  827|  1.76k|			r = profile->ops->select_pin_reference(profile, p15card, &pin_ainfo);
  828|  1.76k|			LOG_TEST_RET(ctx, r, "Failed to select card specific PIN reference");
  ------------------
  |  |  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: 338, False: 1.42k]
  |  |  |  |  ------------------
  |  |  |  |  169|    338|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    338|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    338|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    338|		return _ret; \
  |  |  |  |  172|    338|	} \
  |  |  |  |  173|  1.76k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.42k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  829|  1.76k|		}
  830|       |
  831|  1.55k|		sc_profile_get_pin_info(profile, SC_PKCS15INIT_SO_PUK, &puk_ainfo);
  ------------------
  |  |  170|  1.55k|#define SC_PKCS15INIT_SO_PUK		1
  ------------------
  832|  1.55k|		r = sc_pkcs15init_qualify_pin(card, "SO PUK", args->so_puk_len, &puk_ainfo);
  833|  1.55k|		LOG_TEST_RET(ctx, r, "Failed to qualify SO PUK");
  ------------------
  |  |  174|  1.55k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.55k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.55k|	int _ret = (r); \
  |  |  |  |  168|  1.55k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 184, False: 1.37k]
  |  |  |  |  ------------------
  |  |  |  |  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|  1.55k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.37k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  834|       |
  835|  1.37k|		if (!(pin_label = args->so_pin_label)) {
  ------------------
  |  Branch (835:7): [True: 1.37k, False: 0]
  ------------------
  836|  1.37k|			if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_SO_PIN)
  ------------------
  |  |   61|  1.37k|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (836:8): [True: 153, False: 1.22k]
  ------------------
  837|    153|				pin_label = "Security Officer PIN";
  838|  1.22k|			else
  839|  1.22k|				pin_label = "User PIN";
  840|  1.37k|		}
  841|       |
  842|  1.37k|		if (args->so_puk_len == 0)
  ------------------
  |  Branch (842:7): [True: 73, False: 1.30k]
  ------------------
  843|     73|			pin_attrs->flags |= SC_PKCS15_PIN_FLAG_UNBLOCK_DISABLED;
  ------------------
  |  |   57|     73|#define SC_PKCS15_PIN_FLAG_UNBLOCK_DISABLED		0x0008
  ------------------
  844|       |
  845|  1.37k|		pin_obj = sc_pkcs15init_new_object(SC_PKCS15_TYPE_AUTH_PIN, pin_label, NULL, &pin_ainfo);
  ------------------
  |  |  445|  1.37k|#define SC_PKCS15_TYPE_AUTH_PIN			0x601
  ------------------
  846|  1.37k|		if (pin_obj)   {
  ------------------
  |  Branch (846:7): [True: 1.37k, 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|  1.37k|			sc_log(ctx, "Add virtual SO_PIN('%.*s',flags:%X,reference:%i,path:'%s')", (int) sizeof pin_obj->label, pin_obj->label,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  853|  1.37k|					pin_attrs->flags, pin_attrs->reference, sc_print_path(&pin_ainfo.path));
  854|       |
  855|  1.37k|			r = sc_pkcs15_add_object(p15card, pin_obj);
  856|  1.37k|			LOG_TEST_GOTO_ERR(ctx, r, "Failed to add 'SOPIN' AUTH object");
  ------------------
  |  |  184|  1.37k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  1.37k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  1.37k|	int _ret = (r); \
  |  |  |  |  178|  1.37k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 1.37k]
  |  |  |  |  ------------------
  |  |  |  |  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.37k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1.37k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  857|  1.37k|		}
  858|  1.37k|	}
  859|       |
  860|       |	/* Perform card-specific initialization */
  861|  1.37k|	if (profile->ops->init_card)   {
  ------------------
  |  Branch (861:6): [True: 1.05k, False: 315]
  ------------------
  862|  1.05k|		r = profile->ops->init_card(profile, p15card);
  863|  1.05k|		if (r < 0 && pin_obj)   {
  ------------------
  |  Branch (863:7): [True: 440, False: 618]
  |  Branch (863:16): [True: 440, False: 0]
  ------------------
  864|    440|			sc_pkcs15_remove_object(p15card, pin_obj);
  865|    440|		}
  866|  1.05k|		LOG_TEST_GOTO_ERR(ctx, r, "Card specific init failed");
  ------------------
  |  |  184|  1.05k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  1.05k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  1.05k|	int _ret = (r); \
  |  |  |  |  178|  1.05k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 440, False: 618]
  |  |  |  |  ------------------
  |  |  |  |  179|    440|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    440|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    440|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    440|		goto err; \
  |  |  |  |  182|    440|	} \
  |  |  |  |  183|  1.05k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 618]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  867|  1.05k|	}
  868|       |
  869|       |	/* Create the application directory */
  870|    933|	if (profile->ops->create_dir) {
  ------------------
  |  Branch (870:6): [True: 847, False: 86]
  ------------------
  871|    847|		r = profile->ops->create_dir(profile, p15card, df);
  872|    847|		if (r < 0 && pin_obj)   {
  ------------------
  |  Branch (872:7): [True: 631, False: 216]
  |  Branch (872:16): [True: 631, False: 0]
  ------------------
  873|    631|			sc_pkcs15_remove_object(p15card, pin_obj);
  874|    631|		}
  875|    847|		LOG_TEST_GOTO_ERR(ctx, r, "Create 'DIR' error");
  ------------------
  |  |  184|    847|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    847|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    847|	int _ret = (r); \
  |  |  |  |  178|    847|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 631, False: 216]
  |  |  |  |  ------------------
  |  |  |  |  179|    631|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    631|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    631|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    631|		goto err; \
  |  |  |  |  182|    631|	} \
  |  |  |  |  183|    847|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 216]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  876|    847|	}
  877|       |
  878|       |	/* Store SO PIN */
  879|    302|	if (pin_obj && profile->ops->create_pin)
  ------------------
  |  Branch (879:6): [True: 302, False: 0]
  |  Branch (879:17): [True: 216, False: 86]
  ------------------
  880|    216|		r = profile->ops->create_pin(profile, p15card, df, pin_obj,
  881|    216|				args->so_pin, args->so_pin_len,
  882|    216|				args->so_puk, args->so_puk_len);
  883|       |
  884|    302|	if (pin_obj)
  ------------------
  |  Branch (884:6): [True: 302, False: 0]
  ------------------
  885|       |		/* Remove 'virtual' AUTH object . */
  886|    302|		sc_pkcs15_remove_object(p15card, pin_obj);
  887|       |
  888|    302|	LOG_TEST_GOTO_ERR(ctx, r, "Card specific create application DF failed");
  ------------------
  |  |  184|    302|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    302|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    302|	int _ret = (r); \
  |  |  |  |  178|    302|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 86, False: 216]
  |  |  |  |  ------------------
  |  |  |  |  179|     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
  |  |  |  |  ------------------
  |  |  |  |  180|     86|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     86|		goto err; \
  |  |  |  |  182|     86|	} \
  |  |  |  |  183|    302|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 216]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  889|       |
  890|       |	/* Store the PKCS15 information on the card */
  891|    216|	app = (struct sc_app_info *)calloc(1, sizeof(*app));
  892|    216|	if (app == NULL) {
  ------------------
  |  Branch (892:6): [True: 0, False: 216]
  ------------------
  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|    216|	app->path = p15card->file_app->path;
  898|    216|	if (p15card->file_app->namelen <= SC_MAX_AID_SIZE) {
  ------------------
  |  |   43|    216|#define SC_MAX_AID_SIZE			16
  ------------------
  |  Branch (898:6): [True: 216, False: 0]
  ------------------
  899|    216|		app->aid.len = p15card->file_app->namelen;
  900|    216|		memcpy(app->aid.value, p15card->file_app->name, app->aid.len);
  901|    216|	}
  902|       |
  903|       |	/* set serial number if explicitly specified */
  904|    216|	if (args->serial)   {
  ------------------
  |  Branch (904:6): [True: 0, False: 216]
  ------------------
  905|      0|		sc_pkcs15init_set_serial(profile, args->serial);
  906|      0|	}
  907|    216|	else {
  908|       |		/* otherwise try to get the serial number from the card */
  909|    216|		struct sc_serial_number serialnr;
  910|       |
  911|    216|		r = sc_card_ctl(card, SC_CARDCTL_GET_SERIALNR, &serialnr);
  912|    216|		if (r == SC_SUCCESS) {
  ------------------
  |  |   28|    216|#define SC_SUCCESS				0
  ------------------
  |  Branch (912:7): [True: 77, False: 139]
  ------------------
  913|     77|			char hex_serial[SC_MAX_SERIALNR * 2 + 1];
  914|       |
  915|     77|			sc_bin_to_hex(serialnr.value, serialnr.len, hex_serial, sizeof(hex_serial), 0);
  916|     77|			sc_pkcs15init_set_serial(profile, hex_serial);
  917|     77|		}
  918|    216|	}
  919|       |
  920|    216|	if (args->label) {
  ------------------
  |  Branch (920:6): [True: 0, False: 216]
  ------------------
  921|      0|		free(p15card->tokeninfo->label);
  922|      0|		p15card->tokeninfo->label = strdup(args->label);
  923|      0|	}
  924|    216|	if (p15card->tokeninfo->label)
  ------------------
  |  Branch (924:6): [True: 216, False: 0]
  ------------------
  925|    216|		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|    216|	r = sc_pkcs15init_add_object(p15card, profile, SC_PKCS15_AODF, pin_obj);
  ------------------
  |  |  496|    216|#define SC_PKCS15_AODF			8
  ------------------
  931|    216|	if (r >= 0) {
  ------------------
  |  Branch (931:6): [True: 75, False: 141]
  ------------------
  932|     75|		r = sc_pkcs15init_update_dir(p15card, profile, app);
  933|     75|		if (r >= 0) {
  ------------------
  |  Branch (933:7): [True: 8, False: 67]
  ------------------
  934|      8|			r = sc_pkcs15init_update_tokeninfo(p15card, profile);
  935|     67|		} else {
  936|       |			/* FIXED: what to do if sc_pkcs15init_update_dir failed? */
  937|       |			/* sc_pkcs15init_update_dir may add app to card->app[] */
  938|     67|			int found = 0;
  939|     67|			int i;
  940|     67|			for (i = 0; i < card->app_count; i++) {
  ------------------
  |  Branch (940:16): [True: 34, False: 33]
  ------------------
  941|     34|				if (card->app[i] == app) {
  ------------------
  |  Branch (941:9): [True: 34, False: 0]
  ------------------
  942|     34|					found = 1;
  943|     34|					break;
  944|     34|				}
  945|     34|			}
  946|     67|			if (found == 0) { /* not in card->app[] free it */
  ------------------
  |  Branch (946:8): [True: 33, False: 34]
  ------------------
  947|     33|				free(app->label);
  948|     33|				free(app); /* unused */
  949|     33|			}
  950|     67|		}
  951|     75|	}
  952|    141|	else {
  953|    141|		free(app->label);
  954|    141|		free(app); /* unused */
  955|    141|		LOG_TEST_GOTO_ERR(ctx, r, "Failed to add pin object.");
  ------------------
  |  |  184|    141|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    141|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    141|	int _ret = (r); \
  |  |  |  |  178|    141|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 141, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|    141|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    141|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    141|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    141|		goto err; \
  |  |  |  |  182|    141|	} \
  |  |  |  |  183|    141|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  956|    141|	}
  957|       |
  958|     75|	sc_pkcs15init_write_info(p15card, profile, pin_obj);
  959|     75|	pin_obj = NULL;
  960|       |
  961|  1.37k|err:
  962|  1.37k|	sc_pkcs15_free_object(pin_obj);
  963|  1.37k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  1.37k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.37k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.37k|	int _ret = r; \
  |  |  |  |  155|  1.37k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.37k, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.37k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  1.37k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.37k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.37k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.37k|	} else { \
  |  |  |  |  159|      3|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      3|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      3|	} \
  |  |  |  |  162|  1.37k|	return _ret; \
  |  |  |  |  163|  1.37k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  964|  1.37k|}
sc_pkcs15init_store_pin:
 1042|  3.97k|{
 1043|  3.97k|	struct sc_context *ctx = p15card->card->ctx;
 1044|  3.97k|	struct sc_pkcs15_object	*pin_obj;
 1045|  3.97k|	struct sc_pkcs15_auth_info *auth_info;
 1046|  3.97k|	int			r;
 1047|       |
 1048|  3.97k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  3.97k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.97k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.97k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.97k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.97k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1049|       |	/* No auth_id given: select one */
 1050|  3.97k|	if (args->auth_id.len == 0) {
  ------------------
  |  Branch (1050:6): [True: 0, False: 3.97k]
  ------------------
 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|  3.97k|	else   {
 1065|       |		/* Make sure we don't get duplicate PIN IDs */
 1066|  3.97k|		r = sc_pkcs15_find_pin_by_auth_id(p15card, &args->auth_id, NULL);
 1067|  3.97k|		if (r != SC_ERROR_OBJECT_NOT_FOUND)
  ------------------
  |  |   88|  3.97k|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  |  Branch (1067:7): [True: 576, False: 3.40k]
  ------------------
 1068|  3.97k|			LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "There already is a PIN with this ID.");
  ------------------
  |  |  174|    576|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    576|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    576|	int _ret = (r); \
  |  |  |  |  168|    576|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 576, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    576|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    576|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    576|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    576|		return _ret; \
  |  |  |  |  172|    576|	} \
  |  |  |  |  173|    576|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1069|  3.97k|	}
 1070|       |
 1071|  3.40k|	pin_obj = sc_pkcs15init_new_object(SC_PKCS15_TYPE_AUTH_PIN, args->label, NULL, NULL);
  ------------------
  |  |  445|  3.40k|#define SC_PKCS15_TYPE_AUTH_PIN			0x601
  ------------------
 1072|  3.40k|	if (pin_obj == NULL)
  ------------------
  |  Branch (1072:6): [True: 0, False: 3.40k]
  ------------------
 1073|  3.40k|		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|  3.40k|	auth_info = (struct sc_pkcs15_auth_info *) pin_obj->data;
 1076|       |
 1077|  3.40k|	sc_profile_get_pin_info(profile, SC_PKCS15INIT_USER_PIN, auth_info);
  ------------------
  |  |  171|  3.40k|#define SC_PKCS15INIT_USER_PIN		2
  ------------------
 1078|  3.40k|	if (auth_info == NULL)
  ------------------
  |  Branch (1078:6): [True: 0, False: 3.40k]
  ------------------
 1079|  3.40k|		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|  3.40k|	auth_info->auth_id = args->auth_id;
 1082|       |
 1083|       |	/* Now store the PINs */
 1084|  3.40k|	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|  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__
  |  |  ------------------
  ------------------
 1085|  3.40k|	if (profile->ops->create_pin) {
  ------------------
  |  Branch (1085:6): [True: 2.85k, False: 545]
  ------------------
 1086|  2.85k|		r = sc_pkcs15init_create_pin(p15card, profile, pin_obj, args);
 1087|  2.85k|		LOG_TEST_GOTO_ERR(ctx, r, "Card specific create PIN failed.");
  ------------------
  |  |  184|  2.85k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  2.85k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  2.85k|	int _ret = (r); \
  |  |  |  |  178|  2.85k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 2.65k, False: 207]
  |  |  |  |  ------------------
  |  |  |  |  179|  2.65k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.65k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|  2.65k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|  2.65k|		goto err; \
  |  |  |  |  182|  2.65k|	} \
  |  |  |  |  183|  2.85k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 207]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1088|  2.85k|	} else {
 1089|    545|		r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    545|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1090|    545|		LOG_TEST_GOTO_ERR(ctx, r, "Store PIN operation is not supported");
  ------------------
  |  |  184|    545|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    545|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    545|	int _ret = (r); \
  |  |  |  |  178|    545|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 545, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|    545|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    545|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    545|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    545|		goto err; \
  |  |  |  |  182|    545|	} \
  |  |  |  |  183|    545|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1091|    545|	}
 1092|       |
 1093|    207|	r = sc_pkcs15init_add_object(p15card, profile, SC_PKCS15_AODF, pin_obj);
  ------------------
  |  |  496|    207|#define SC_PKCS15_AODF			8
  ------------------
 1094|    207|	LOG_TEST_GOTO_ERR(ctx, r, "Failed to add PIN object");
  ------------------
  |  |  184|    207|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    207|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    207|	int _ret = (r); \
  |  |  |  |  178|    207|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 207, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|    207|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    207|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    207|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    207|		goto err; \
  |  |  |  |  182|    207|	} \
  |  |  |  |  183|    207|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1095|       |
 1096|      0|	if (args->puk_id.len)
  ------------------
  |  Branch (1096:6): [True: 0, False: 0]
  ------------------
 1097|      0|		r = sc_pkcs15init_store_puk(p15card, profile, args);
 1098|       |
 1099|      0|	profile->dirty = 1;
 1100|       |
 1101|      0|	pin_obj = NULL;
 1102|       |
 1103|  3.40k|err:
 1104|  3.40k|	sc_pkcs15_free_object(pin_obj);
 1105|  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|  3.40k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 3.40k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1106|  3.40k|}
sc_pkcs15_create_pin_domain:
 1184|      1|{
 1185|      1|	struct sc_context *ctx = p15card->card->ctx;
 1186|      1|	struct sc_file *df = profile->df_info->file;
 1187|      1|	int	r;
 1188|       |
 1189|      1|	sc_log(ctx, "create PIN domain (path:%s,ID:%s)", sc_print_path(&df->path), sc_pkcs15_print_id(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__
  |  |  ------------------
  ------------------
 1190|       |	/* Instantiate PIN directory just below the application DF */
 1191|      1|	r = sc_profile_instantiate_template(profile, "pin-domain", &df->path, "pin-dir", id, ret);
 1192|      1|	if (r >= 0)   {
  ------------------
  |  Branch (1192:6): [True: 0, False: 1]
  ------------------
 1193|      0|		sc_log(ctx, "create PIN DF(path:%s)", sc_print_path(&(*ret)->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__
  |  |  ------------------
  ------------------
 1194|      0|		r = profile->ops->create_dir(profile, p15card, *ret);
 1195|      0|	}
 1196|       |
 1197|      1|	return r;
 1198|      1|}
sc_pkcs15init_generate_key:
 1529|  7.95k|{
 1530|  7.95k|	struct sc_context *ctx = p15card->card->ctx;
 1531|  7.95k|	struct sc_pkcs15init_pubkeyargs pubkey_args;
 1532|  7.95k|	struct sc_pkcs15_object *object = NULL;
 1533|  7.95k|	struct sc_pkcs15_prkey_info *key_info = NULL;
 1534|  7.95k|	struct sc_pkcs15_pubkey *pubkey = NULL;
 1535|  7.95k|	int r, caller_supplied_id = 0;
 1536|  7.95k|	unsigned long algorithm = keygen_args->prkey_args.key.algorithm;
 1537|       |
 1538|  7.95k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  7.95k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  7.95k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  7.95k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  7.95k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 7.95k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1539|       |
 1540|  7.95k|	memset(&pubkey_args, 0, sizeof(pubkey_args));
 1541|       |
 1542|       |	/* check supported key size */
 1543|  7.95k|	r = check_keygen_params_consistency(p15card->card,
 1544|  7.95k|		algorithm, &keygen_args->prkey_args,
 1545|  7.95k|		&keybits);
 1546|  7.95k|	LOG_TEST_GOTO_ERR(ctx, r, "Invalid key size");
  ------------------
  |  |  184|  7.95k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  7.95k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  7.95k|	int _ret = (r); \
  |  |  |  |  178|  7.95k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 3.55k, False: 4.40k]
  |  |  |  |  ------------------
  |  |  |  |  179|  3.55k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.55k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|  3.55k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|  3.55k|		goto err; \
  |  |  |  |  182|  3.55k|	} \
  |  |  |  |  183|  7.95k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 4.40k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1547|       |
 1548|  4.40k|	if (check_key_compatibility(p15card, algorithm,
  ------------------
  |  Branch (1548:6): [True: 50, False: 4.35k]
  ------------------
 1549|  4.40k|			&keygen_args->prkey_args.key, keygen_args->prkey_args.x509_usage,
 1550|  4.40k|			keybits, SC_ALGORITHM_ONBOARD_KEY_GEN) != SC_SUCCESS) {
  ------------------
  |  |   93|  4.40k|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
              			keybits, SC_ALGORITHM_ONBOARD_KEY_GEN) != SC_SUCCESS) {
  ------------------
  |  |   28|  4.40k|#define SC_SUCCESS				0
  ------------------
 1551|     50|		r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|     50|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1552|     50|		LOG_TEST_GOTO_ERR(ctx, r, "Cannot generate key with the given parameters");
  ------------------
  |  |  184|     50|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     50|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     50|	int _ret = (r); \
  |  |  |  |  178|     50|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 50, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|     50|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     50|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     50|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     50|		goto err; \
  |  |  |  |  182|     50|	} \
  |  |  |  |  183|     50|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1553|     50|	}
 1554|       |
 1555|  4.35k|	if (profile->ops->generate_key == NULL) {
  ------------------
  |  Branch (1555:6): [True: 0, False: 4.35k]
  ------------------
 1556|      0|		r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1557|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1558|      0|	}
 1559|       |
 1560|  4.35k|	if (keygen_args->prkey_args.id.len)   {
  ------------------
  |  Branch (1560:6): [True: 955, False: 3.40k]
  ------------------
 1561|    955|		caller_supplied_id = 1;
 1562|       |
 1563|       |		/* Make sure that private key's ID is the unique inside the PKCS#15 application */
 1564|    955|		r = sc_pkcs15_find_prkey_by_id(p15card, &keygen_args->prkey_args.id, NULL);
 1565|    955|		if (!r) {
  ------------------
  |  Branch (1565:7): [True: 0, False: 955]
  ------------------
 1566|      0|			r = SC_ERROR_NON_UNIQUE_ID;
  ------------------
  |  |  107|      0|#define SC_ERROR_NON_UNIQUE_ID			-1505
  ------------------
 1567|      0|			LOG_TEST_GOTO_ERR(ctx, r, "Non unique ID of the private 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1568|      0|		}
 1569|    955|		else if (r != SC_ERROR_OBJECT_NOT_FOUND) {
  ------------------
  |  |   88|    955|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  |  Branch (1569:12): [True: 0, False: 955]
  ------------------
 1570|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1571|      0|		}
 1572|    955|	}
 1573|       |
 1574|       |	/* Set up the PrKDF object */
 1575|  4.35k|	r = sc_pkcs15init_init_prkdf(p15card, profile, &keygen_args->prkey_args,
 1576|  4.35k|		&keygen_args->prkey_args.key, keybits, &object);
 1577|  4.35k|	LOG_TEST_GOTO_ERR(ctx, r, "Set up private key object error");
  ------------------
  |  |  184|  4.35k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  4.35k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  4.35k|	int _ret = (r); \
  |  |  |  |  178|  4.35k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 693, False: 3.66k]
  |  |  |  |  ------------------
  |  |  |  |  179|    693|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    693|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    693|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    693|		goto err; \
  |  |  |  |  182|    693|	} \
  |  |  |  |  183|  4.35k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 3.66k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1578|       |
 1579|  3.66k|	key_info = (struct sc_pkcs15_prkey_info *) object->data;
 1580|       |
 1581|  3.66k|	if (keygen_args->prkey_args.guid) {
  ------------------
  |  Branch (1581:6): [True: 0, False: 3.66k]
  ------------------
 1582|      0|		r = _pkcd15init_set_aux_md_data(p15card, &key_info->aux_data,
 1583|      0|				keygen_args->prkey_args.guid, keygen_args->prkey_args.guid_len);
 1584|      0|		LOG_TEST_GOTO_ERR(ctx, r, "Failed to set aux MD data");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1585|  3.66k|	} else {
 1586|  3.66k|		key_info->aux_data = keygen_args->prkey_args.aux_data;
 1587|  3.66k|	}
 1588|       |
 1589|       |	/* Set up the PuKDF info. The public key will be filled in
 1590|       |	 * by the card driver's generate_key function called below.
 1591|       |	 * Auth.ID of the public key object is left empty. */
 1592|  3.66k|	pubkey_args.id = keygen_args->prkey_args.id;
 1593|  3.66k|	pubkey_args.label = keygen_args->pubkey_label ? keygen_args->pubkey_label : object->label;
  ------------------
  |  Branch (1593:22): [True: 0, False: 3.66k]
  ------------------
 1594|  3.66k|	pubkey_args.usage = keygen_args->pubkey_usage;
 1595|  3.66k|	pubkey_args.x509_usage = keygen_args->prkey_args.x509_usage;
 1596|  3.66k|	pubkey_args.key.algorithm = algorithm;
 1597|       |
 1598|  3.66k|	if (algorithm == SC_ALGORITHM_GOSTR3410)   {
  ------------------
  |  |   71|  3.66k|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (1598:6): [True: 0, False: 3.66k]
  ------------------
 1599|      0|		pubkey_args.params.gost = keygen_args->prkey_args.params.gost;
 1600|      0|		r = sc_copy_gost_params(&(pubkey_args.key.u.gostr3410.params), &(keygen_args->prkey_args.key.u.gostr3410.params));
 1601|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1602|  3.66k|	} else if (algorithm == SC_ALGORITHM_EC ||
  ------------------
  |  |   70|  7.32k|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (1602:13): [True: 894, False: 2.76k]
  ------------------
 1603|  2.76k|			algorithm == SC_ALGORITHM_EDDSA ||
  ------------------
  |  |   72|  6.43k|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (1603:4): [True: 0, False: 2.76k]
  ------------------
 1604|  2.76k|			algorithm == SC_ALGORITHM_XEDDSA) {
  ------------------
  |  |   73|  2.76k|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (1604:4): [True: 0, False: 2.76k]
  ------------------
 1605|    894|		r = sc_copy_ec_params(&pubkey_args.key.u.ec.params, &keygen_args->prkey_args.key.u.ec.params);
 1606|    894|		LOG_TEST_GOTO_ERR(ctx, r, "Cannot allocate EC parameters");
  ------------------
  |  |  184|    894|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    894|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    894|	int _ret = (r); \
  |  |  |  |  178|    894|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 894]
  |  |  |  |  ------------------
  |  |  |  |  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|    894|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 894]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1607|    894|	}
 1608|       |
 1609|       |	/* Generate the private key on card */
 1610|  3.66k|	r = profile->ops->create_key(profile, p15card, object);
 1611|  3.66k|	LOG_TEST_GOTO_ERR(ctx, r, "Cannot generate key: create key failed");
  ------------------
  |  |  184|  3.66k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  3.66k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  3.66k|	int _ret = (r); \
  |  |  |  |  178|  3.66k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 1.72k, False: 1.93k]
  |  |  |  |  ------------------
  |  |  |  |  179|  1.72k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.72k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|  1.72k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|  1.72k|		goto err; \
  |  |  |  |  182|  1.72k|	} \
  |  |  |  |  183|  3.66k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1.93k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1612|       |
 1613|  1.93k|	r = profile->ops->generate_key(profile, p15card, object, &pubkey_args.key);
 1614|  1.93k|	LOG_TEST_GOTO_ERR(ctx, r, "Failed to generate key");
  ------------------
  |  |  184|  1.93k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  1.93k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  1.93k|	int _ret = (r); \
  |  |  |  |  178|  1.93k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 1.89k, False: 41]
  |  |  |  |  ------------------
  |  |  |  |  179|  1.89k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.89k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|  1.89k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|  1.89k|		goto err; \
  |  |  |  |  182|  1.89k|	} \
  |  |  |  |  183|  1.93k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 41]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1615|       |
 1616|       |	/* update PrKDF entry */
 1617|     41|	if (!caller_supplied_id)   {
  ------------------
  |  Branch (1617:6): [True: 17, False: 24]
  ------------------
 1618|     17|		struct sc_pkcs15_id iid;
 1619|       |
 1620|       |		/* Caller not supplied ID, so,
 1621|       |		 * if intrinsic ID can be calculated -- overwrite the native one */
 1622|     17|		memset(&iid, 0, sizeof(iid));
 1623|     17|		r = sc_pkcs15init_select_intrinsic_id(p15card, profile, SC_PKCS15_TYPE_PUBKEY, &iid, &pubkey_args.key);
  ------------------
  |  |  425|     17|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
 1624|     17|		LOG_TEST_GOTO_ERR(ctx, r, "Select intrinsic ID error");
  ------------------
  |  |  184|     17|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     17|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     17|	int _ret = (r); \
  |  |  |  |  178|     17|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 17]
  |  |  |  |  ------------------
  |  |  |  |  179|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|     17|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 17]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1625|       |
 1626|     17|		if (iid.len)
  ------------------
  |  Branch (1626:7): [True: 1, False: 16]
  ------------------
 1627|      1|			key_info->id = iid;
 1628|     17|	}
 1629|     41|	pubkey = &pubkey_args.key;
 1630|     41|	if (!pubkey->alg_id)   {
  ------------------
  |  Branch (1630:6): [True: 41, False: 0]
  ------------------
 1631|     41|		pubkey->alg_id = calloc(1, sizeof(struct sc_algorithm_id));
 1632|     41|		if (!pubkey->alg_id) {
  ------------------
  |  Branch (1632:7): [True: 0, False: 41]
  ------------------
 1633|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1634|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1635|      0|		}
 1636|       |
 1637|     41|		sc_init_oid(&pubkey->alg_id->oid);
 1638|     41|		pubkey->alg_id->algorithm = pubkey->algorithm;
 1639|     41|	}
 1640|       |
 1641|     41|	pubkey_args.id = key_info->id;
 1642|     41|	r = sc_pkcs15_encode_pubkey(ctx, pubkey, &object->content.value, &object->content.len);
 1643|     41|	LOG_TEST_GOTO_ERR(ctx, r, "Failed to encode public key");
  ------------------
  |  |  184|     41|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     41|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     41|	int _ret = (r); \
  |  |  |  |  178|     41|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 1, False: 40]
  |  |  |  |  ------------------
  |  |  |  |  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|     41|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 40]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1644|       |
 1645|     40|	r = sc_pkcs15init_add_object(p15card, profile, SC_PKCS15_PRKDF, object);
  ------------------
  |  |  488|     40|#define SC_PKCS15_PRKDF			0
  ------------------
 1646|     40|	LOG_TEST_GOTO_ERR(ctx, r, "Failed to add generated private key object");
  ------------------
  |  |  184|     40|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     40|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     40|	int _ret = (r); \
  |  |  |  |  178|     40|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 30, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  179|     30|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     30|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     30|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     30|		goto err; \
  |  |  |  |  182|     30|	} \
  |  |  |  |  183|     40|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1647|       |
 1648|     10|	if (!r && profile->ops->emu_store_data)   {
  ------------------
  |  Branch (1648:6): [True: 10, False: 0]
  |  Branch (1648:12): [True: 2, False: 8]
  ------------------
 1649|      2|		r = profile->ops->emu_store_data(p15card, profile, object, NULL, NULL);
 1650|      2|		if (r == SC_ERROR_NOT_IMPLEMENTED)
  ------------------
  |  |   97|      2|#define SC_ERROR_NOT_IMPLEMENTED		-1416
  ------------------
  |  Branch (1650:7): [True: 0, False: 2]
  ------------------
 1651|      0|			r = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1652|      2|		if (r < 0)
  ------------------
  |  Branch (1652:7): [True: 0, False: 2]
  ------------------
 1653|      0|			sc_pkcs15_remove_object(p15card, object);
 1654|      2|		LOG_TEST_GOTO_ERR(ctx, r, "Card specific 'store data' 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1655|      2|	}
 1656|       |
 1657|     10|	r = sc_pkcs15init_store_public_key(p15card, profile, &pubkey_args, NULL);
 1658|     10|	if (r < 0)
  ------------------
  |  Branch (1658:6): [True: 9, False: 1]
  ------------------
 1659|      9|		sc_pkcs15_remove_object(p15card, object);
 1660|     10|	LOG_TEST_GOTO_ERR(ctx, r, "Failed to store public key");
  ------------------
  |  |  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: 9, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  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|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1661|       |
 1662|      1|	if (res_obj)
  ------------------
  |  Branch (1662:6): [True: 0, False: 1]
  ------------------
 1663|      0|		*res_obj = object;
 1664|      1|	object = NULL;
 1665|       |
 1666|      1|	profile->dirty = 1;
 1667|       |
 1668|  7.95k|err:
 1669|  7.95k|	sc_pkcs15_free_object(object);
 1670|  7.95k|	sc_pkcs15_erase_pubkey(&pubkey_args.key);
 1671|  7.95k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  7.95k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  7.95k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  7.95k|	int _ret = r; \
  |  |  |  |  155|  7.95k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 7.95k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  7.95k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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.95k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 7.95k, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|  7.95k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  7.95k|	} else { \
  |  |  |  |  159|      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.95k|	return _ret; \
  |  |  |  |  163|  7.95k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1672|  7.95k|}
sc_pkcs15init_generate_secret_key:
 1680|  11.9k|{
 1681|  11.9k|	struct sc_context *ctx = p15card->card->ctx;
 1682|  11.9k|	struct sc_pkcs15_object *object = NULL;
 1683|  11.9k|	unsigned int keybits = (unsigned int)skey_args->value_len;
 1684|  11.9k|	int r;
 1685|       |
 1686|  11.9k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  11.9k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  11.9k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  11.9k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  11.9k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 11.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1687|       |	/* check supported key size */
 1688|  11.9k|	r = check_keygen_params_consistency(p15card->card, skey_args->algorithm, NULL, &keybits);
 1689|  11.9k|	LOG_TEST_RET(ctx, r, "Invalid key size");
  ------------------
  |  |  174|  11.9k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  11.9k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  11.9k|	int _ret = (r); \
  |  |  |  |  168|  11.9k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 11.2k, False: 690]
  |  |  |  |  ------------------
  |  |  |  |  169|  11.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|  11.2k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  11.2k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  11.2k|		return _ret; \
  |  |  |  |  172|  11.2k|	} \
  |  |  |  |  173|  11.9k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 690]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1690|       |
 1691|    690|	if (check_key_compatibility(p15card, skey_args->algorithm, NULL, 0,
  ------------------
  |  Branch (1691:6): [True: 690, False: 0]
  ------------------
 1692|    690|			keybits, SC_ALGORITHM_ONBOARD_KEY_GEN) != SC_SUCCESS)
  ------------------
  |  |   93|    690|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
              			keybits, SC_ALGORITHM_ONBOARD_KEY_GEN) != SC_SUCCESS)
  ------------------
  |  |   28|    690|#define SC_SUCCESS				0
  ------------------
 1693|    690|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Cannot generate key with the given parameters");
  ------------------
  |  |  174|    690|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    690|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    690|	int _ret = (r); \
  |  |  |  |  168|    690|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 690, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    690|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    690|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    690|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    690|		return _ret; \
  |  |  |  |  172|    690|	} \
  |  |  |  |  173|    690|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1694|       |
 1695|      0|	if (profile->ops->generate_key == NULL)
  ------------------
  |  Branch (1695:6): [True: 0, False: 0]
  ------------------
 1696|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1697|       |
 1698|      0|	if (skey_args->id.len)   {
  ------------------
  |  Branch (1698:6): [True: 0, False: 0]
  ------------------
 1699|       |		/* Make sure that secret key's ID is the unique inside the PKCS#15 application */
 1700|      0|		r = sc_pkcs15_find_skey_by_id(p15card, &skey_args->id, NULL);
 1701|      0|		if (!r)
  ------------------
  |  Branch (1701:7): [True: 0, False: 0]
  ------------------
 1702|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1703|      0|		else if (r != SC_ERROR_OBJECT_NOT_FOUND)
  ------------------
  |  |   88|      0|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  |  Branch (1703:12): [True: 0, False: 0]
  ------------------
 1704|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1705|      0|	}
 1706|       |
 1707|       |	/* Set up the SKDF object */
 1708|      0|	r = sc_pkcs15init_init_skdf(p15card, profile, skey_args, &object);
 1709|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1710|       |
 1711|       |	/* Generate the secret key on card */
 1712|      0|	r = profile->ops->create_key(profile, p15card, object);
 1713|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1714|       |
 1715|      0|	r = profile->ops->generate_key(profile, p15card, object, NULL);
 1716|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1717|       |
 1718|      0|	r = sc_pkcs15init_add_object(p15card, profile, SC_PKCS15_SKDF, object);
  ------------------
  |  |  491|      0|#define SC_PKCS15_SKDF			3
  ------------------
 1719|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1720|       |
 1721|      0|	if (!r && profile->ops->emu_store_data)   {
  ------------------
  |  Branch (1721:6): [True: 0, False: 0]
  |  Branch (1721:12): [True: 0, False: 0]
  ------------------
 1722|      0|		r = profile->ops->emu_store_data(p15card, profile, object, NULL, NULL);
 1723|      0|		if (r == SC_ERROR_NOT_IMPLEMENTED)
  ------------------
  |  |   97|      0|#define SC_ERROR_NOT_IMPLEMENTED		-1416
  ------------------
  |  Branch (1723:7): [True: 0, False: 0]
  ------------------
 1724|      0|			r = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1725|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1726|      0|	}
 1727|       |
 1728|      0|	if (res_obj)
  ------------------
  |  Branch (1728:6): [True: 0, False: 0]
  ------------------
 1729|      0|		*res_obj = object;
 1730|      0|	object = NULL;
 1731|       |
 1732|      0|	profile->dirty = 1;
 1733|       |
 1734|      0|err:
 1735|      0|	sc_pkcs15_free_object(object);
 1736|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1737|      0|}
sc_pkcs15init_store_public_key:
 1845|     10|{
 1846|     10|	struct sc_context *ctx = p15card->card->ctx;
 1847|     10|	struct sc_pkcs15_object *object = NULL;
 1848|     10|	struct sc_pkcs15_pubkey_info *key_info;
 1849|     10|	struct sc_pkcs15_keyinfo_gostparams *keyinfo_gostparams;
 1850|     10|	struct sc_pkcs15_pubkey key;
 1851|     10|	struct sc_path	*path;
 1852|     10|	const char	*label;
 1853|     10|	unsigned int	type = 0;
 1854|     10|	unsigned int usage;
 1855|     10|	size_t keybits;
 1856|     10|	int		r;
 1857|       |
 1858|     10|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     10|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     10|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     10|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     10|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1859|     10|	if (!keyargs)
  ------------------
  |  Branch (1859:6): [True: 0, False: 10]
  ------------------
 1860|     10|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1861|       |
 1862|       |	/* Create shallow a copy of the key first */
 1863|     10|	key = keyargs->key;
 1864|       |
 1865|       |	/* Copy algorithm id structure */
 1866|     10|	if (keyargs->key.alg_id) {
  ------------------
  |  Branch (1866:6): [True: 10, False: 0]
  ------------------
 1867|     10|		key.alg_id = calloc(1, sizeof(struct sc_algorithm_id));
 1868|     10|		if (!key.alg_id)
  ------------------
  |  Branch (1868:7): [True: 0, False: 10]
  ------------------
 1869|     10|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1870|       |
 1871|     10|		key.alg_id->algorithm = keyargs->key.alg_id->algorithm;
 1872|     10|		memcpy(&key.alg_id->oid, &keyargs->key.alg_id->oid, sizeof(struct sc_object_id));
 1873|     10|	}
 1874|       |
 1875|       |	/* Copy algorithm related parameters */
 1876|     10|	switch (key.algorithm) {
 1877|      2|	case SC_ALGORITHM_RSA:
  ------------------
  |  |   69|      2|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (1877:2): [True: 2, False: 8]
  ------------------
 1878|      2|		key.u.rsa.modulus.data = NULL;
 1879|      2|		key.u.rsa.exponent.data = NULL;
 1880|       |		// copy RSA params
 1881|      2|		if (!(key.u.rsa.modulus.data = malloc(keyargs->key.u.rsa.modulus.len))) {
  ------------------
  |  Branch (1881:7): [True: 0, False: 2]
  ------------------
 1882|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1883|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1884|      0|		}
 1885|      2|		memcpy(key.u.rsa.modulus.data, keyargs->key.u.rsa.modulus.data, keyargs->key.u.rsa.modulus.len);
 1886|      2|		if (!(key.u.rsa.exponent.data = malloc(keyargs->key.u.rsa.exponent.len))) {
  ------------------
  |  Branch (1886:7): [True: 0, False: 2]
  ------------------
 1887|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1888|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1889|      0|		}
 1890|      2|		memcpy(key.u.rsa.exponent.data, keyargs->key.u.rsa.exponent.data, keyargs->key.u.rsa.exponent.len);
 1891|      2|		keybits = sc_pkcs15init_keybits(&key.u.rsa.modulus);
 1892|      2|		type = SC_PKCS15_TYPE_PUBKEY_RSA;
  ------------------
  |  |  426|      2|#define SC_PKCS15_TYPE_PUBKEY_RSA		0x201
  ------------------
 1893|      2|		break;
 1894|      0|	case SC_ALGORITHM_GOSTR3410:
  ------------------
  |  |   71|      0|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (1894:2): [True: 0, False: 10]
  ------------------
 1895|      0|		key.u.gostr3410.xy.data = NULL;
 1896|       |		// copy GOSTR params
 1897|      0|		if (!(key.u.gostr3410.xy.data = malloc(keyargs->key.u.gostr3410.xy.len))) {
  ------------------
  |  Branch (1897:7): [True: 0, False: 0]
  ------------------
 1898|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1899|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1900|      0|		}
 1901|      0|		memcpy(key.u.gostr3410.xy.data, keyargs->key.u.gostr3410.xy.data, keyargs->key.u.gostr3410.xy.len);
 1902|      0|		keybits = SC_PKCS15_GOSTR3410_KEYSIZE;
  ------------------
  |  |  326|      0|#define SC_PKCS15_GOSTR3410_KEYSIZE             256
  ------------------
 1903|      0|		type = SC_PKCS15_TYPE_PUBKEY_GOSTR3410;
  ------------------
  |  |  427|      0|#define SC_PKCS15_TYPE_PUBKEY_GOSTR3410		0x203
  ------------------
 1904|      0|		break;
 1905|      8|	case SC_ALGORITHM_EC:
  ------------------
  |  |   70|      8|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (1905:2): [True: 8, False: 2]
  ------------------
 1906|      8|	case SC_ALGORITHM_EDDSA:
  ------------------
  |  |   72|      8|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (1906:2): [True: 0, False: 10]
  ------------------
 1907|      8|	case SC_ALGORITHM_XEDDSA:
  ------------------
  |  |   73|      8|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (1907:2): [True: 0, False: 10]
  ------------------
 1908|       |
 1909|      8|		r = sc_copy_ec_params(&key.u.ec.params, &keyargs->key.u.ec.params);
 1910|      8|		LOG_TEST_GOTO_ERR(ctx, r, "Failed to copy EC public key parameters");
  ------------------
  |  |  184|      8|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      8|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      8|	int _ret = (r); \
  |  |  |  |  178|      8|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  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|      8|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1911|      8|		r = sc_pkcs15_fix_ec_parameters(ctx, &key.u.ec.params);
 1912|      8|		LOG_TEST_GOTO_ERR(ctx, r, "Failed to fix EC public key parameters");
  ------------------
  |  |  184|      8|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      8|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      8|	int _ret = (r); \
  |  |  |  |  178|      8|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  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|      8|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1913|       |
 1914|      8|		if (key.algorithm == SC_ALGORITHM_EC)
  ------------------
  |  |   70|      8|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (1914:7): [True: 8, False: 0]
  ------------------
 1915|      8|			type = SC_PKCS15_TYPE_PUBKEY_EC;
  ------------------
  |  |  428|      8|#define SC_PKCS15_TYPE_PUBKEY_EC		0x204
  ------------------
 1916|      0|		else if (key.algorithm == SC_ALGORITHM_EDDSA)
  ------------------
  |  |   72|      0|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (1916:12): [True: 0, False: 0]
  ------------------
 1917|      0|			type = SC_PKCS15_TYPE_PUBKEY_EDDSA;
  ------------------
  |  |  429|      0|#define SC_PKCS15_TYPE_PUBKEY_EDDSA		0x205
  ------------------
 1918|      0|		else if (key.algorithm == SC_ALGORITHM_XEDDSA)
  ------------------
  |  |   73|      0|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (1918:12): [True: 0, False: 0]
  ------------------
 1919|      0|			type = SC_PKCS15_TYPE_PUBKEY_XEDDSA;
  ------------------
  |  |  430|      0|#define SC_PKCS15_TYPE_PUBKEY_XEDDSA		0x206
  ------------------
 1920|       |
 1921|      8|		keybits = key.u.ec.params.field_length;
 1922|      8|		break;
 1923|      0|	default:
  ------------------
  |  Branch (1923:2): [True: 0, False: 10]
  ------------------
 1924|      0|		r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1925|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1926|     10|	}
 1927|       |
 1928|     10|	if ((usage = keyargs->usage) == 0) {
  ------------------
  |  Branch (1928:6): [True: 10, False: 0]
  ------------------
 1929|     10|		if (type == SC_PKCS15_TYPE_PUBKEY_XEDDSA) {
  ------------------
  |  |  430|     10|#define SC_PKCS15_TYPE_PUBKEY_XEDDSA		0x206
  ------------------
  |  Branch (1929:7): [True: 0, False: 10]
  ------------------
 1930|      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__
  |  |  ------------------
  ------------------
 1931|      0|			usage = SC_PKCS15_PRKEY_USAGE_DERIVE;
  ------------------
  |  |  313|      0|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
 1932|     10|		} else {
 1933|     10|			sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Setting default usage to verify");
  ------------------
  |  |   70|     10|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1934|     10|			usage = SC_PKCS15_PRKEY_USAGE_VERIFY;
  ------------------
  |  |  311|     10|#define SC_PKCS15_PRKEY_USAGE_VERIFY		0x40
  ------------------
 1935|     10|		}
 1936|     10|		if (keyargs->x509_usage) {
  ------------------
  |  Branch (1936:7): [True: 0, False: 10]
  ------------------
 1937|      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__
  |  |  ------------------
  ------------------
 1938|      0|			usage = sc_pkcs15init_map_usage(keyargs->x509_usage, 0);
 1939|      0|		}
 1940|     10|	}
 1941|     10|	sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Usage: 0x%X", usage);
  ------------------
  |  |   70|     10|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1942|       |
 1943|     10|	label = keyargs->label;
 1944|     10|	if (!label)
  ------------------
  |  Branch (1944:6): [True: 0, False: 10]
  ------------------
 1945|      0|		label = "Public Key";
 1946|       |
 1947|       |	/* Set up the pkcs15 object. */
 1948|     10|	object = sc_pkcs15init_new_object(type, label, &keyargs->auth_id, NULL);
 1949|     10|	if (object == NULL) {
  ------------------
  |  Branch (1949:6): [True: 0, False: 10]
  ------------------
 1950|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1951|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1952|      0|	}
 1953|       |
 1954|     10|	key_info = (struct sc_pkcs15_pubkey_info *) object->data;
 1955|     10|	key_info->usage = usage;
 1956|     10|	key_info->id = keyargs->id;
 1957|       |
 1958|     10|	if (key.algorithm == SC_ALGORITHM_RSA) {
  ------------------
  |  |   69|     10|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (1958:6): [True: 2, False: 8]
  ------------------
 1959|      2|		key_info->modulus_length = keybits;
 1960|      8|	} else if (key.algorithm == SC_ALGORITHM_GOSTR3410) {
  ------------------
  |  |   71|      8|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (1960:13): [True: 0, False: 8]
  ------------------
 1961|      0|		key_info->params.len = sizeof(*keyinfo_gostparams);
 1962|       |		/* FIXME: malloc() call in pkcs15init, but free() call
 1963|       |		 * in libopensc (sc_pkcs15_free_prkey_info) */
 1964|      0|		key_info->params.data = malloc(key_info->params.len);
 1965|      0|		if (!key_info->params.data) {
  ------------------
  |  Branch (1965:7): [True: 0, False: 0]
  ------------------
 1966|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1967|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1968|      0|		}
 1969|      0|		keyinfo_gostparams = key_info->params.data;
 1970|      0|		keyinfo_gostparams->gostr3410 = keyargs->params.gost.gostr3410;
 1971|      0|		keyinfo_gostparams->gostr3411 = keyargs->params.gost.gostr3411;
 1972|      0|		keyinfo_gostparams->gost28147 = keyargs->params.gost.gost28147;
 1973|      8|	} else if (key.algorithm == SC_ALGORITHM_EC ||
  ------------------
  |  |   70|     16|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (1973:13): [True: 8, False: 0]
  ------------------
 1974|      0|			key.algorithm == SC_ALGORITHM_EDDSA ||
  ------------------
  |  |   72|      8|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (1974:4): [True: 0, False: 0]
  ------------------
 1975|      8|			key.algorithm == SC_ALGORITHM_XEDDSA) {
  ------------------
  |  |   73|      0|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (1975:4): [True: 0, False: 0]
  ------------------
 1976|      8|		key_info->field_length = keybits;
 1977|       |		/* only SC_ALGORITHM_EC has ec_params with the EC curveName OID
 1978|       |		 * that becomes part of the SPKI algo params.
 1979|       |		 * EDDSA and XEDDSA ec_params have the OID of the EDDSA or XEDDSA
 1980|       |		 * which is used as the alg OID. But we still copy here
 1981|       |		 * as the asn1 routines will do the right thing based on key.algorithm.
 1982|       |		 */
 1983|      8|		if (key.u.ec.params.der.value) {
  ------------------
  |  Branch (1983:7): [True: 8, False: 0]
  ------------------
 1984|      8|			key_info->params.data = malloc(key.u.ec.params.der.len);
 1985|      8|			if (!key_info->params.data) {
  ------------------
  |  Branch (1985:8): [True: 0, False: 8]
  ------------------
 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 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1988|      0|			}
 1989|      8|			key_info->params.len = key.u.ec.params.der.len;
 1990|      8|			memcpy(key_info->params.data, key.u.ec.params.der.value, key.u.ec.params.der.len);
 1991|      8|		}
 1992|      8|		if (keyargs->key.u.ec.ecpointQ.value) {
  ------------------
  |  Branch (1992:7): [True: 8, False: 0]
  ------------------
 1993|      8|			key.u.ec.ecpointQ.value = malloc(keyargs->key.u.ec.ecpointQ.len);
 1994|      8|			if (!key.u.ec.ecpointQ.value) {
  ------------------
  |  Branch (1994:8): [True: 0, False: 8]
  ------------------
 1995|      0|				r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1996|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1997|      0|			}
 1998|      8|			key.u.ec.ecpointQ.len = keyargs->key.u.ec.ecpointQ.len;
 1999|      8|			memcpy(key.u.ec.ecpointQ.value, keyargs->key.u.ec.ecpointQ.value, key.u.ec.ecpointQ.len);
 2000|      8|		}
 2001|      8|	}
 2002|       |
 2003|       |	/* Select a intrinsic Key ID if the user didn't specify one */
 2004|     10|	r = sc_pkcs15init_select_intrinsic_id(p15card, profile, SC_PKCS15_TYPE_PUBKEY, &keyargs->id, &key);
  ------------------
  |  |  425|     10|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
 2005|     10|	LOG_TEST_GOTO_ERR(ctx, r, "Get intrinsic ID error");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2006|       |
 2007|       |	/* Select a Key ID if the user didn't specify one and there is no intrinsic ID,
 2008|       |	 * otherwise make sure it's unique */
 2009|     10|	r = select_id(p15card, SC_PKCS15_TYPE_PUBKEY, &keyargs->id);
  ------------------
  |  |  425|     10|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
 2010|     10|	LOG_TEST_GOTO_ERR(ctx, r, "Failed to select public key object ID");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2011|       |
 2012|       |	/* Make sure that private key's ID is the unique inside the PKCS#15 application */
 2013|     10|	r = sc_pkcs15_find_pubkey_by_id(p15card, &keyargs->id, NULL);
 2014|     10|	if (!r) {
  ------------------
  |  Branch (2014:6): [True: 0, False: 10]
  ------------------
 2015|      0|		r = SC_ERROR_NON_UNIQUE_ID;
  ------------------
  |  |  107|      0|#define SC_ERROR_NON_UNIQUE_ID			-1505
  ------------------
 2016|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2017|     10|	} else if (r != SC_ERROR_OBJECT_NOT_FOUND)  {
  ------------------
  |  |   88|     10|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  |  Branch (2017:13): [True: 0, False: 10]
  ------------------
 2018|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2019|      0|	}
 2020|       |
 2021|     10|	key_info->id = keyargs->id;
 2022|       |
 2023|       |	/* DER encode public key components */
 2024|     10|	r = sc_pkcs15_encode_pubkey(p15card->card->ctx, &key, &object->content.value, &object->content.len);
 2025|     10|	LOG_TEST_GOTO_ERR(ctx, r, "Encode public key error");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2026|       |
 2027|     10|	r = sc_pkcs15_encode_pubkey(p15card->card->ctx, &key, &key_info->direct.raw.value, &key_info->direct.raw.len);
 2028|     10|	LOG_TEST_GOTO_ERR(ctx, r, "RAW encode public key error");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2029|       |
 2030|       |	/* EC key are encoded as SPKI to preserve domain parameter */
 2031|     10|	r = sc_pkcs15_encode_pubkey_as_spki(p15card->card->ctx, &key, &key_info->direct.spki.value, &key_info->direct.spki.len);
 2032|     10|	LOG_TEST_GOTO_ERR(ctx, r, "SPKI encode public key error");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2033|       |
 2034|       |	/* Now create key file and store key */
 2035|     10|	if (type == SC_PKCS15_TYPE_PUBKEY_EC ||
  ------------------
  |  |  428|     20|#define SC_PKCS15_TYPE_PUBKEY_EC		0x204
  ------------------
  |  Branch (2035:6): [True: 8, False: 2]
  ------------------
 2036|      2|			type == SC_PKCS15_TYPE_PUBKEY_EDDSA ||
  ------------------
  |  |  429|     12|#define SC_PKCS15_TYPE_PUBKEY_EDDSA		0x205
  ------------------
  |  Branch (2036:4): [True: 0, False: 2]
  ------------------
 2037|      2|			type == SC_PKCS15_TYPE_PUBKEY_XEDDSA)
  ------------------
  |  |  430|      2|#define SC_PKCS15_TYPE_PUBKEY_XEDDSA		0x206
  ------------------
  |  Branch (2037:4): [True: 0, False: 2]
  ------------------
 2038|      8|		r = sc_pkcs15init_store_data(p15card, profile, object, &key_info->direct.spki, &key_info->path);
 2039|      2|	else
 2040|      2|		r = sc_pkcs15init_store_data(p15card, profile, object, &object->content, &key_info->path);
 2041|       |
 2042|     10|	path = &key_info->path;
 2043|     10|	if (path->count == 0) {
  ------------------
  |  Branch (2043:6): [True: 7, False: 3]
  ------------------
 2044|      7|		path->index = 0;
 2045|      7|		path->count = -1;
 2046|      7|	}
 2047|       |
 2048|       |	/* Update the PuKDF */
 2049|     10|	if (r >= 0)
  ------------------
  |  Branch (2049:6): [True: 2, False: 8]
  ------------------
 2050|      2|		r = sc_pkcs15init_add_object(p15card, profile, SC_PKCS15_PUKDF, object);
  ------------------
  |  |  489|      2|#define SC_PKCS15_PUKDF			1
  ------------------
 2051|     10|	LOG_TEST_GOTO_ERR(ctx, r, "Add object error");
  ------------------
  |  |  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: 9, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  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|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2052|       |
 2053|      1|	if (r >= 0 && res_obj)
  ------------------
  |  Branch (2053:6): [True: 1, False: 0]
  |  Branch (2053:16): [True: 0, False: 1]
  ------------------
 2054|      0|		*res_obj = object;
 2055|      1|	object = NULL;
 2056|       |
 2057|      1|	profile->dirty = 1;
 2058|       |
 2059|     10|err:
 2060|     10|	sc_pkcs15_erase_pubkey(&key);
 2061|     10|	sc_pkcs15_free_object(object);
 2062|     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|      9|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 9, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2063|     10|}
sc_pkcs15init_store_secret_key:
 2072|  11.9k|{
 2073|  11.9k|	struct sc_context *ctx = p15card->card->ctx;
 2074|  11.9k|	struct sc_pkcs15_object *object = NULL;
 2075|  11.9k|	int r = 0;
 2076|       |
 2077|  11.9k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  11.9k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  11.9k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  11.9k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  11.9k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 11.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2078|       |
 2079|       |	/* Now check whether the card is able to handle this key */
 2080|  11.9k|	if (check_key_compatibility(p15card, keyargs->algorithm, NULL, 0, keyargs->value_len, 0) != SC_SUCCESS) {
  ------------------
  |  |   28|  11.9k|#define SC_SUCCESS				0
  ------------------
  |  Branch (2080:6): [True: 11.2k, False: 690]
  ------------------
 2081|       |		/* Make sure the caller explicitly tells us to store
 2082|       |		 * the key as extractable. */
 2083|  11.2k|		if (!(keyargs->access_flags & SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE))
  ------------------
  |  |  317|  11.2k|#define SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE	0x02
  ------------------
  |  Branch (2083:7): [True: 0, False: 11.2k]
  ------------------
 2084|  11.2k|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2085|  11.2k|	}
 2086|       |
 2087|  11.9k|#ifdef ENABLE_OPENSSL
 2088|  11.9k|	if (!keyargs->id.len) {
  ------------------
  |  Branch (2088:6): [True: 3.97k, False: 7.95k]
  ------------------
 2089|       |		/* Calculating intrinsic Key ID for secret key does not make
 2090|       |		 * sense - just generate random one */
 2091|  3.97k|		if (RAND_bytes(keyargs->id.value, 20) == 1)
  ------------------
  |  Branch (2091:7): [True: 3.97k, False: 0]
  ------------------
 2092|  3.97k|			keyargs->id.len = 20;
 2093|  3.97k|	}
 2094|  11.9k|#endif
 2095|       |
 2096|       |	/* Make sure that secret key's ID is the unique inside the PKCS#15 application */
 2097|  11.9k|	r = sc_pkcs15_find_skey_by_id(p15card, &keyargs->id, NULL);
 2098|  11.9k|	if (!r)
  ------------------
  |  Branch (2098:6): [True: 2, False: 11.9k]
  ------------------
 2099|  11.9k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2100|  11.9k|	else if (r != SC_ERROR_OBJECT_NOT_FOUND)
  ------------------
  |  |   88|  11.9k|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  |  Branch (2100:11): [True: 0, False: 11.9k]
  ------------------
 2101|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2102|       |
 2103|       |	/* Set up the SKDF object */
 2104|  11.9k|	r = sc_pkcs15init_init_skdf(p15card, profile, keyargs, &object);
 2105|  11.9k|	LOG_TEST_RET(ctx, r, "Failed to initialize secret key object");
  ------------------
  |  |  174|  11.9k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  11.9k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  11.9k|	int _ret = (r); \
  |  |  |  |  168|  11.9k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6.74k, False: 5.18k]
  |  |  |  |  ------------------
  |  |  |  |  169|  6.74k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  6.74k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  6.74k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  6.74k|		return _ret; \
  |  |  |  |  172|  6.74k|	} \
  |  |  |  |  173|  11.9k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 5.18k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2106|       |
 2107|  5.18k|	if (profile->ops->create_key)
  ------------------
  |  Branch (2107:6): [True: 5.18k, False: 0]
  ------------------
 2108|  5.18k|		r = profile->ops->create_key(profile, p15card, object);
 2109|  5.18k|	LOG_TEST_GOTO_ERR(ctx, r, "Card specific 'create key' failed");
  ------------------
  |  |  184|  5.18k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  5.18k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  5.18k|	int _ret = (r); \
  |  |  |  |  178|  5.18k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 3.35k, False: 1.83k]
  |  |  |  |  ------------------
  |  |  |  |  179|  3.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|  3.35k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|  3.35k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|  3.35k|		goto err; \
  |  |  |  |  182|  3.35k|	} \
  |  |  |  |  183|  5.18k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1.83k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2110|       |
 2111|       |	/* If no key data, only an empty EF is created.
 2112|       |	 * It can be used to receive an unwrapped key later. */
 2113|  1.83k|	if (keyargs->key.data_len > 0) {
  ------------------
  |  Branch (2113:6): [True: 1.83k, False: 0]
  ------------------
 2114|  1.83k|		if (profile->ops->store_key) {
  ------------------
  |  Branch (2114:7): [True: 1.83k, False: 0]
  ------------------
 2115|  1.83k|			struct sc_pkcs15_prkey key;
 2116|  1.83k|			memset(&key, 0, sizeof(key));
 2117|  1.83k|			key.algorithm = keyargs->algorithm;
 2118|  1.83k|			key.u.secret = keyargs->key;
 2119|  1.83k|			r = profile->ops->store_key(profile, p15card, object, &key);
 2120|  1.83k|		}
 2121|  1.83k|	}
 2122|  1.83k|	LOG_TEST_GOTO_ERR(ctx, r, "Card specific 'store key' failed");
  ------------------
  |  |  184|  1.83k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  1.83k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  1.83k|	int _ret = (r); \
  |  |  |  |  178|  1.83k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 1.72k, False: 109]
  |  |  |  |  ------------------
  |  |  |  |  179|  1.72k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.72k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|  1.72k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|  1.72k|		goto err; \
  |  |  |  |  182|  1.72k|	} \
  |  |  |  |  183|  1.83k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 109]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2123|       |
 2124|    109|	sc_pkcs15_free_object_content(object);
 2125|       |
 2126|       |	/* Now update the SKDF, unless it is a session object.
 2127|       |	   If we have an on card session object, we have created the actual key object on card.
 2128|       |	   The card handles removing it when the session is finished or during the next reset.
 2129|       |	   We will maintain the object in the P15 structure in memory for duration of the session,
 2130|       |	   but we don't want it to be written into SKDF. */
 2131|    109|	if (!object->session_object) {
  ------------------
  |  Branch (2131:6): [True: 109, False: 0]
  ------------------
 2132|    109|		r = sc_pkcs15init_add_object(p15card, profile, SC_PKCS15_SKDF, object);
  ------------------
  |  |  491|    109|#define SC_PKCS15_SKDF			3
  ------------------
 2133|    109|		LOG_TEST_GOTO_ERR(ctx, r, "Failed to add new secret key PKCS#15 object");
  ------------------
  |  |  184|    109|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    109|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    109|	int _ret = (r); \
  |  |  |  |  178|    109|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 103, False: 6]
  |  |  |  |  ------------------
  |  |  |  |  179|    103|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    103|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    103|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    103|		goto err; \
  |  |  |  |  182|    103|	} \
  |  |  |  |  183|    109|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2134|    109|	}
 2135|       |
 2136|      6|	if (!r && profile->ops->emu_store_data && !object->session_object)   {
  ------------------
  |  Branch (2136:6): [True: 6, False: 0]
  |  Branch (2136:12): [True: 0, False: 6]
  |  Branch (2136:44): [True: 0, False: 0]
  ------------------
 2137|      0|		r = profile->ops->emu_store_data(p15card, profile, object, NULL, NULL);
 2138|      0|		if (r == SC_ERROR_NOT_IMPLEMENTED)
  ------------------
  |  |   97|      0|#define SC_ERROR_NOT_IMPLEMENTED		-1416
  ------------------
  |  Branch (2138:7): [True: 0, False: 0]
  ------------------
 2139|      0|			r = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 2140|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2141|      0|	}
 2142|       |
 2143|      6|	if (r >= 0 && res_obj)
  ------------------
  |  Branch (2143:6): [True: 6, False: 0]
  |  Branch (2143:16): [True: 0, False: 6]
  ------------------
 2144|      0|		*res_obj = object;
 2145|      6|	object = NULL;
 2146|       |
 2147|      6|	profile->dirty = 1;
 2148|       |
 2149|  5.18k|err:
 2150|  5.18k|	sc_pkcs15_free_object(object);
 2151|  5.18k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  5.18k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  5.18k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  5.18k|	int _ret = r; \
  |  |  |  |  155|  5.18k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 5.18k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  5.18k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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.18k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 5.18k, False: 6]
  |  |  |  |  ------------------
  |  |  |  |  157|  5.18k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  5.18k|	} else { \
  |  |  |  |  159|      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.18k|	return _ret; \
  |  |  |  |  163|  5.18k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2152|  5.18k|}
sc_pkcs15init_store_data_object:
 2269|  3.97k|{
 2270|  3.97k|	struct sc_context *ctx = p15card->card->ctx;
 2271|  3.97k|	struct sc_pkcs15_data_info *data_object_info;
 2272|  3.97k|	struct sc_pkcs15_object *object;
 2273|  3.97k|	struct sc_pkcs15_object *objs[32];
 2274|  3.97k|	const char	*label;
 2275|  3.97k|	int		r, i;
 2276|  3.97k|	unsigned int    tid = 0x01;
 2277|       |
 2278|  3.97k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  3.97k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.97k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.97k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.97k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.97k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2279|  3.97k|	if (!profile)
  ------------------
  |  Branch (2279:6): [True: 0, False: 3.97k]
  ------------------
 2280|  3.97k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2281|  3.97k|	label = args->label;
 2282|       |
 2283|  3.97k|	if (!args->id.len) {
  ------------------
  |  Branch (2283:6): [True: 3.97k, False: 0]
  ------------------
 2284|       |		/* Select an ID if the user didn't specify one, otherwise
 2285|       |		 * make sure it's unique (even though data objects doesn't
 2286|       |		 * have a pkcs15 id we need one here to create a unique
 2287|       |		 * file id from the data file template */
 2288|  3.97k|		r = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_DATA_OBJECT, objs, 32);
  ------------------
  |  |  442|  3.97k|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
 2289|  3.97k|		LOG_TEST_RET(ctx, r, "Get 'DATA' objects error");
  ------------------
  |  |  174|  3.97k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  3.97k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  3.97k|	int _ret = (r); \
  |  |  |  |  168|  3.97k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 3.97k]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#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.97k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3.97k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2290|       |
 2291|  4.02k|		for (i = 0; i < r; i++) {
  ------------------
  |  Branch (2291:15): [True: 44, False: 3.97k]
  ------------------
 2292|     44|			unsigned char cid;
 2293|     44|			struct sc_pkcs15_data_info *cinfo = (struct sc_pkcs15_data_info *) objs[i]->data;
 2294|     44|			if (!cinfo->path.len)
  ------------------
  |  Branch (2294:8): [True: 0, False: 44]
  ------------------
 2295|      0|				continue;
 2296|     44|			cid = cinfo->path.value[cinfo->path.len - 1];
 2297|     44|			if (cid >= tid)
  ------------------
  |  Branch (2297:8): [True: 23, False: 21]
  ------------------
 2298|     23|				tid = cid + 1;
 2299|     44|		}
 2300|  3.97k|		if (tid > 0xff)
  ------------------
  |  Branch (2300:7): [True: 1, False: 3.97k]
  ------------------
 2301|       |			/* too many data objects ... */
 2302|      1|			return SC_ERROR_TOO_MANY_OBJECTS;
  ------------------
  |  |   86|      1|#define SC_ERROR_TOO_MANY_OBJECTS		-1405
  ------------------
 2303|  3.97k|		args->id.len = 1;
 2304|  3.97k|		args->id.value[0] = tid;
 2305|  3.97k|	}
 2306|      0|	else   {
 2307|       |		/* in case the user specifies an id it should be at most
 2308|       |		 * one byte long */
 2309|      0|		if (args->id.len > 1)
  ------------------
  |  Branch (2309:7): [True: 0, False: 0]
  ------------------
 2310|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 2311|      0|	}
 2312|       |
 2313|  3.97k|	object = sc_pkcs15init_new_object(SC_PKCS15_TYPE_DATA_OBJECT, label, &args->auth_id, NULL);
  ------------------
  |  |  442|  3.97k|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
 2314|  3.97k|	if (object == NULL)
  ------------------
  |  Branch (2314:6): [True: 0, False: 3.97k]
  ------------------
 2315|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2316|       |
 2317|  3.97k|	data_object_info = (struct sc_pkcs15_data_info *) object->data;
 2318|  3.97k|	if (args->app_label != NULL)
  ------------------
  |  Branch (2318:6): [True: 3.97k, False: 0]
  ------------------
 2319|  3.97k|		strlcpy(data_object_info->app_label, args->app_label, sizeof(data_object_info->app_label));
  ------------------
  |  |   43|  3.97k|#define strlcpy _strlcpy
  ------------------
 2320|      0|	else if (label != NULL)
  ------------------
  |  Branch (2320:11): [True: 0, False: 0]
  ------------------
 2321|      0|		strlcpy(data_object_info->app_label, label, sizeof(data_object_info->app_label));
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
 2322|       |
 2323|  3.97k|	data_object_info->app_oid = args->app_oid;
 2324|  3.97k|	sc_der_copy(&data_object_info->data, &args->der_encoded);
 2325|       |
 2326|  3.97k|	r = sc_pkcs15init_store_data(p15card, profile, object, &args->der_encoded, &data_object_info->path);
 2327|  3.97k|	LOG_TEST_GOTO_ERR(ctx, r, "Store 'DATA' object error");
  ------------------
  |  |  184|  3.97k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  3.97k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  3.97k|	int _ret = (r); \
  |  |  |  |  178|  3.97k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 3.72k, False: 250]
  |  |  |  |  ------------------
  |  |  |  |  179|  3.72k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.72k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|  3.72k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|  3.72k|		goto err; \
  |  |  |  |  182|  3.72k|	} \
  |  |  |  |  183|  3.97k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 250]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2328|       |
 2329|       |	/* Now update the DDF */
 2330|    250|	r = sc_pkcs15init_add_object(p15card, profile, SC_PKCS15_DODF, object);
  ------------------
  |  |  495|    250|#define SC_PKCS15_DODF			7
  ------------------
 2331|    250|	LOG_TEST_GOTO_ERR(ctx, r, "'DODF' update error");
  ------------------
  |  |  184|    250|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    250|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    250|	int _ret = (r); \
  |  |  |  |  178|    250|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 232, False: 18]
  |  |  |  |  ------------------
  |  |  |  |  179|    232|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    232|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    232|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    232|		goto err; \
  |  |  |  |  182|    232|	} \
  |  |  |  |  183|    250|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 18]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2332|       |
 2333|     18|	if (r >= 0 && res_obj)
  ------------------
  |  Branch (2333:6): [True: 18, False: 0]
  |  Branch (2333:16): [True: 0, False: 18]
  ------------------
 2334|      0|		*res_obj = object;
 2335|     18|	object = NULL;
 2336|       |
 2337|     18|	profile->dirty = 1;
 2338|       |
 2339|  3.97k|err:
 2340|  3.97k|	sc_pkcs15_free_object(object);
 2341|  3.97k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  3.97k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.97k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.97k|	int _ret = r; \
  |  |  |  |  155|  3.97k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.97k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.97k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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.96k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 3.96k, False: 18]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.97k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.97k|	} else { \
  |  |  |  |  159|      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.97k|	return _ret; \
  |  |  |  |  163|  3.97k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2342|  3.97k|}
sc_pkcs15init_get_pin_reference:
 2348|  3.11k|{
 2349|  3.11k|	struct sc_context *ctx = p15card->card->ctx;
 2350|  3.11k|	struct sc_pkcs15_auth_info auth_info;
 2351|  3.11k|	struct sc_pkcs15_object *auth_objs[0x10];
 2352|  3.11k|	int r, ii, nn_objs;
 2353|       |
 2354|  3.11k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  3.11k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.11k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.11k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.11k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.11k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2355|       |
 2356|       |	/* 1. Look for the corresponding pkcs15 PIN object. */
 2357|       |
 2358|       |	/* Get all existing pkcs15 AUTH objects */
 2359|  3.11k|	r = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_AUTH_PIN, auth_objs, 0x10);
  ------------------
  |  |  445|  3.11k|#define SC_PKCS15_TYPE_AUTH_PIN			0x601
  ------------------
 2360|  3.11k|	LOG_TEST_RET(ctx, r, "Get PKCS#15 AUTH objects error");
  ------------------
  |  |  174|  3.11k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  3.11k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  3.11k|	int _ret = (r); \
  |  |  |  |  168|  3.11k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 3.11k]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#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.11k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3.11k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2361|  3.11k|	nn_objs = r;
 2362|       |
 2363|  3.11k|	sc_log(ctx, "found %i auth objects; looking for AUTH object(auth_method:%i,reference:%i)",
  ------------------
  |  |   71|  3.11k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2364|  3.11k|			nn_objs, auth_method, reference);
 2365|  4.70k|	for (ii=0; ii<nn_objs; ii++)   {
  ------------------
  |  Branch (2365:13): [True: 2.70k, False: 1.99k]
  ------------------
 2366|  2.70k|		struct sc_pkcs15_auth_info *auth_info = (struct sc_pkcs15_auth_info *)auth_objs[ii]->data;
 2367|  2.70k|		struct sc_pkcs15_pin_attributes *pin_attrs = &auth_info->attrs.pin;
 2368|       |
 2369|  2.70k|		sc_log(ctx, "check PIN(%.*s,auth_method:%i,type:%i,reference:%i,flags:%X)",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2370|  2.70k|				(int) sizeof auth_objs[ii]->label, auth_objs[ii]->label, auth_info->auth_method, pin_attrs->type,
 2371|  2.70k|				pin_attrs->reference, pin_attrs->flags);
 2372|       |		/* Find out if there is AUTH pkcs15 object with given 'type' and 'reference' */
 2373|  2.70k|		if (auth_info->auth_method == auth_method && pin_attrs->reference == reference)
  ------------------
  |  Branch (2373:7): [True: 375, False: 2.33k]
  |  Branch (2373:48): [True: 201, False: 174]
  ------------------
 2374|  2.70k|			LOG_FUNC_RETURN(ctx, pin_attrs->reference);
  ------------------
  |  |  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: 10, False: 191]
  |  |  |  |  ------------------
  |  |  |  |  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|    191|	} else { \
  |  |  |  |  159|    191|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    191|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    191|	} \
  |  |  |  |  162|    201|	return _ret; \
  |  |  |  |  163|    201|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2375|       |
 2376|  2.50k|		if (auth_method != SC_AC_SYMBOLIC)
  ------------------
  |  |  155|  2.50k|#define SC_AC_SYMBOLIC			0x00000010 /* internal use only */
  ------------------
  |  Branch (2376:7): [True: 343, False: 2.16k]
  ------------------
 2377|    343|			continue;
 2378|       |
 2379|       |		/* Translate 'SYMBOLIC' PIN reference into the pkcs#15 pinAttributes.flags
 2380|       |		 * 	and check for the existing pkcs15 PIN object with these flags. */
 2381|  2.16k|		switch (reference)   {
 2382|    934|		case SC_PKCS15INIT_USER_PIN:
  ------------------
  |  |  171|    934|#define SC_PKCS15INIT_USER_PIN		2
  ------------------
  |  Branch (2382:3): [True: 934, False: 1.22k]
  ------------------
 2383|    934|			if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_SO_PIN)
  ------------------
  |  |   61|    934|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (2383:8): [True: 331, False: 603]
  ------------------
 2384|    331|				continue;
 2385|    603|			if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN)
  ------------------
  |  |   60|    603|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  ------------------
  |  Branch (2385:8): [True: 10, False: 593]
  ------------------
 2386|     10|				continue;
 2387|    593|			break;
 2388|  1.21k|		case SC_PKCS15INIT_SO_PIN:
  ------------------
  |  |  169|  1.21k|#define SC_PKCS15INIT_SO_PIN		0
  ------------------
  |  Branch (2388:3): [True: 1.21k, False: 951]
  ------------------
 2389|  1.21k|			if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN)
  ------------------
  |  |   60|  1.21k|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  ------------------
  |  Branch (2389:8): [True: 309, False: 903]
  ------------------
 2390|    309|				continue;
 2391|    903|			if (!(pin_attrs->flags & SC_PKCS15_PIN_FLAG_SO_PIN))
  ------------------
  |  |   61|    903|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (2391:8): [True: 579, False: 324]
  ------------------
 2392|    579|				continue;
 2393|    324|			break;
 2394|    324|		case SC_PKCS15INIT_USER_PUK:
  ------------------
  |  |  172|     10|#define SC_PKCS15INIT_USER_PUK		3
  ------------------
  |  Branch (2394:3): [True: 10, False: 2.15k]
  ------------------
 2395|     10|			if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_SO_PIN)
  ------------------
  |  |   61|     10|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (2395:8): [True: 0, False: 10]
  ------------------
 2396|      0|				continue;
 2397|     10|			if (!(pin_attrs->flags & SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN))
  ------------------
  |  |   60|     10|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  ------------------
  |  Branch (2397:8): [True: 5, False: 5]
  ------------------
 2398|      5|				continue;
 2399|      5|			break;
 2400|      6|		case SC_PKCS15INIT_SO_PUK:
  ------------------
  |  |  170|      6|#define SC_PKCS15INIT_SO_PUK		1
  ------------------
  |  Branch (2400:3): [True: 6, False: 2.15k]
  ------------------
 2401|      6|			if (!(pin_attrs->flags & SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN))
  ------------------
  |  |   60|      6|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  ------------------
  |  Branch (2401:8): [True: 3, False: 3]
  ------------------
 2402|      3|				continue;
 2403|      3|			if (!(pin_attrs->flags & SC_PKCS15_PIN_FLAG_SO_PIN))
  ------------------
  |  |   61|      3|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (2403:8): [True: 3, False: 0]
  ------------------
 2404|      3|				continue;
 2405|      0|			break;
 2406|      1|		default:
  ------------------
  |  Branch (2406:3): [True: 1, False: 2.16k]
  ------------------
 2407|      1|			LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "Invalid Symbolic PIN 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2408|  2.16k|		}
 2409|       |
 2410|    922|		LOG_FUNC_RETURN(ctx, pin_attrs->reference);
  ------------------
  |  |  164|    922|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    922|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    922|	int _ret = r; \
  |  |  |  |  155|    922|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 17, False: 905]
  |  |  |  |  ------------------
  |  |  |  |  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|     10|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 10, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  157|     17|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    905|	} else { \
  |  |  |  |  159|    905|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    905|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    905|	} \
  |  |  |  |  162|    922|	return _ret; \
  |  |  |  |  163|    922|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2411|       |
 2412|    922|	}
 2413|       |
 2414|       |	/* 2. No existing pkcs15 PIN object
 2415|       |	 *	-- check if profile defines some PIN with 'reference' as PIN reference. */
 2416|  1.99k|	r = sc_profile_get_pin_id_by_reference(profile, auth_method, reference, &auth_info);
 2417|  1.99k|	if (r < 0)
  ------------------
  |  Branch (2417:6): [True: 657, False: 1.33k]
  ------------------
 2418|  1.99k|		LOG_TEST_RET(ctx, SC_ERROR_OBJECT_NOT_FOUND, "PIN template not found");
  ------------------
  |  |  174|    657|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    657|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    657|	int _ret = (r); \
  |  |  |  |  168|    657|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 657, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    657|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    657|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    657|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    657|		return _ret; \
  |  |  |  |  172|    657|	} \
  |  |  |  |  173|    657|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2419|       |
 2420|  1.33k|	LOG_FUNC_RETURN(ctx, auth_info.attrs.pin.reference);
  ------------------
  |  |  164|  1.33k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.33k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.33k|	int _ret = r; \
  |  |  |  |  155|  1.33k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 570, False: 768]
  |  |  |  |  ------------------
  |  |  |  |  156|    570|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    512|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 512, False: 58]
  |  |  |  |  ------------------
  |  |  |  |  157|    570|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    768|	} else { \
  |  |  |  |  159|    768|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    768|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    768|	} \
  |  |  |  |  162|  1.33k|	return _ret; \
  |  |  |  |  163|  1.33k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2421|  1.33k|}
sc_pkcs15init_select_intrinsic_id:
 2841|     27|{
 2842|       |#ifndef ENABLE_OPENSSL
 2843|       |	LOG_FUNC_RETURN(p15card->card->ctx, SC_SUCCESS);
 2844|       |#else
 2845|     27|	struct sc_context *ctx = p15card->card->ctx;
 2846|     27|	struct sc_pkcs15_pubkey *pubkey = NULL;
 2847|     27|	unsigned id_style;
 2848|     27|	struct sc_pkcs15_id id;
 2849|     27|	unsigned char *id_data = NULL;
 2850|     27|	size_t id_data_len = 0;
 2851|     27|	int rv, allocated = 0;
 2852|       |
 2853|     27|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     27|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     27|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     27|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     27|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 27]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2854|       |
 2855|     27|	if (!id_out || !profile)
  ------------------
  |  Branch (2855:6): [True: 0, False: 27]
  |  Branch (2855:17): [True: 0, False: 27]
  ------------------
 2856|     27|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2857|       |
 2858|     27|	id_style = profile->id_style;
 2859|       |
 2860|       |	/* ID already exists */
 2861|     27|	if (id_out->len)
  ------------------
  |  Branch (2861:6): [True: 10, False: 17]
  ------------------
 2862|     27|		LOG_FUNC_RETURN(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2863|       |
 2864|       |	/* Native ID style is not intrinsic one */
 2865|     17|	if (id_style == SC_PKCS15INIT_ID_STYLE_NATIVE)
  ------------------
  |  |  165|     17|#define SC_PKCS15INIT_ID_STYLE_NATIVE		0
  ------------------
  |  Branch (2865:6): [True: 16, False: 1]
  ------------------
 2866|     17|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2867|       |
 2868|      1|	memset(&id, 0, sizeof(id));
 2869|       |	/* Get PKCS15 public key */
 2870|      1|	switch(type)   {
 2871|      0|	case SC_PKCS15_TYPE_CERT_X509:
  ------------------
  |  |  439|      0|#define SC_PKCS15_TYPE_CERT_X509		0x401
  ------------------
  |  Branch (2871:2): [True: 0, False: 1]
  ------------------
 2872|      0|		rv = sc_pkcs15_pubkey_from_cert(ctx, (struct sc_pkcs15_der *)data, &pubkey);
 2873|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2874|      0|		allocated = 1;
 2875|      0|		break;
 2876|      0|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|      0|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (2876:2): [True: 0, False: 1]
  ------------------
 2877|      0|		rv = sc_pkcs15_pubkey_from_prvkey(ctx, (struct sc_pkcs15_prkey *)data, &pubkey);
 2878|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2879|      0|		allocated = 1;
 2880|      0|		break;
 2881|      1|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|      1|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (2881:2): [True: 1, False: 0]
  ------------------
 2882|      1|		pubkey = (struct sc_pkcs15_pubkey *)data;
 2883|      1|		allocated = 0;
 2884|      1|		break;
 2885|      0|	default:
  ------------------
  |  Branch (2885:2): [True: 0, False: 1]
  ------------------
 2886|      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__
  |  |  ------------------
  ------------------
 2887|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2888|      1|	}
 2889|       |
 2890|       |	/* Skip silently if key is not initialized. */
 2891|      1|	if (pubkey->algorithm == SC_ALGORITHM_RSA && !pubkey->u.rsa.modulus.len)
  ------------------
  |  |   69|      2|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (2891:6): [True: 1, False: 0]
  |  Branch (2891:47): [True: 0, False: 1]
  ------------------
 2892|      0|		goto done;
 2893|      1|	else if (pubkey->algorithm == SC_ALGORITHM_GOSTR3410 &&
  ------------------
  |  |   71|      2|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (2893:11): [True: 0, False: 1]
  ------------------
 2894|      0|			!pubkey->u.gostr3410.xy.data)
  ------------------
  |  Branch (2894:4): [True: 0, False: 0]
  ------------------
 2895|      0|		goto done;
 2896|      1|	else if (pubkey->algorithm == SC_ALGORITHM_EC && !pubkey->u.ec.ecpointQ.value)
  ------------------
  |  |   70|      2|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (2896:11): [True: 0, False: 1]
  |  Branch (2896:51): [True: 0, False: 0]
  ------------------
 2897|      0|		goto done;
 2898|       |
 2899|       |	/* In Mozilla 'GOST R 34.10' is not yet supported.
 2900|       |	 * So, switch to the ID recommended by RFC2459 */
 2901|      1|	if (pubkey->algorithm == SC_ALGORITHM_GOSTR3410 && id_style == SC_PKCS15INIT_ID_STYLE_MOZILLA)
  ------------------
  |  |   71|      2|#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 (2901:6): [True: 0, False: 1]
  |  Branch (2901:53): [True: 0, False: 0]
  ------------------
 2902|      0|		id_style = SC_PKCS15INIT_ID_STYLE_RFC2459;
  ------------------
  |  |  167|      0|#define SC_PKCS15INIT_ID_STYLE_RFC2459		2
  ------------------
 2903|       |
 2904|      1|	switch (id_style)  {
 2905|      1|	case SC_PKCS15INIT_ID_STYLE_MOZILLA:
  ------------------
  |  |  166|      1|#define SC_PKCS15INIT_ID_STYLE_MOZILLA		1
  ------------------
  |  Branch (2905:2): [True: 1, False: 0]
  ------------------
 2906|      1|		if (pubkey->algorithm == SC_ALGORITHM_RSA)
  ------------------
  |  |   69|      1|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (2906:7): [True: 1, False: 0]
  ------------------
 2907|      1|			SHA1(pubkey->u.rsa.modulus.data, pubkey->u.rsa.modulus.len, id.value);
 2908|      0|		else if (pubkey->algorithm == SC_ALGORITHM_EC)
  ------------------
  |  |   70|      0|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (2908:12): [True: 0, False: 0]
  ------------------
 2909|       |			/* ID should be SHA1 of the X coordinate according to PKCS#15 v1.1 */
 2910|       |			/* skip the 04 tag and get the X component */
 2911|      0|			SHA1(pubkey->u.ec.ecpointQ.value+1, (pubkey->u.ec.ecpointQ.len - 1) / 2, id.value);
 2912|      0|		else
 2913|      0|			goto done;
 2914|       |
 2915|      1|		id.len = SHA_DIGEST_LENGTH;
 2916|      1|		break;
 2917|      0|	case SC_PKCS15INIT_ID_STYLE_RFC2459:
  ------------------
  |  |  167|      0|#define SC_PKCS15INIT_ID_STYLE_RFC2459		2
  ------------------
  |  Branch (2917:2): [True: 0, False: 1]
  ------------------
 2918|      0|		rv = sc_pkcs15_encode_pubkey(ctx, pubkey, &id_data, &id_data_len);
 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|       |
 2921|      0|		if (!id_data || !id_data_len) {
  ------------------
  |  Branch (2921:7): [True: 0, False: 0]
  |  Branch (2921:19): [True: 0, False: 0]
  ------------------
 2922|      0|			rv = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 2923|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2924|      0|		}
 2925|       |
 2926|      0|		SHA1(id_data, id_data_len, id.value);
 2927|      0|		id.len = SHA_DIGEST_LENGTH;
 2928|       |
 2929|      0|		break;
 2930|      0|	default:
  ------------------
  |  Branch (2930:2): [True: 0, False: 1]
  ------------------
 2931|      0|		sc_log(ctx, "Unsupported ID style: %i", id_style);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2932|      0|		rv = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 2933|      0|		LOG_TEST_GOTO_ERR(ctx, rv, "Non supported ID style");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2934|      1|	}
 2935|       |
 2936|      1|done:
 2937|      1|	memcpy(id_out, &id, sizeof(*id_out));
 2938|      1|	rv = (int)id_out->len;
 2939|       |
 2940|      1|err:
 2941|      1|	if (id_data)
  ------------------
  |  Branch (2941:6): [True: 0, False: 1]
  ------------------
 2942|      0|		free(id_data);
 2943|      1|	if (allocated)
  ------------------
  |  Branch (2943:6): [True: 0, False: 1]
  ------------------
 2944|      0|		sc_pkcs15_free_pubkey(pubkey);
 2945|       |
 2946|      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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2947|      1|#endif
 2948|      1|}
sc_pkcs15init_update_any_df:
 3326|  1.14k|{
 3327|  1.14k|	struct sc_context	*ctx = p15card->card->ctx;
 3328|  1.14k|	struct sc_card	*card = p15card->card;
 3329|  1.14k|	struct sc_file	*file = NULL;
 3330|  1.14k|	unsigned char	*buf = NULL;
 3331|  1.14k|	size_t		bufsize = 0;
 3332|  1.14k|	int		update_odf = is_new, r = 0;
 3333|       |
 3334|  1.14k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  1.14k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.14k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.14k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.14k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.14k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3335|  1.14k|	if (!df)
  ------------------
  |  Branch (3335:6): [True: 0, False: 1.14k]
  ------------------
 3336|  1.14k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3337|       |
 3338|  1.14k|	r = sc_profile_get_file_by_path(profile, &df->path, &file);
 3339|  1.14k|	if (r < 0 || file == NULL) {
  ------------------
  |  Branch (3339:6): [True: 47, False: 1.09k]
  |  Branch (3339:15): [True: 0, False: 1.09k]
  ------------------
 3340|     47|		r = sc_select_file(card, &df->path, &file);
 3341|     47|		if (r < 0)
  ------------------
  |  Branch (3341:7): [True: 37, False: 10]
  ------------------
 3342|     37|			sc_log(ctx, "Failed to select DF: %s", sc_strerror(r));
  ------------------
  |  |   71|     37|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3343|     47|	}
 3344|       |
 3345|  1.14k|	r = sc_pkcs15_encode_df(card->ctx, p15card, df, &buf, &bufsize);
 3346|  1.14k|	if (r >= 0) {
  ------------------
  |  Branch (3346:6): [True: 1.12k, False: 21]
  ------------------
 3347|  1.12k|		r = sc_pkcs15init_update_file(profile, p15card, file, buf, bufsize);
 3348|       |
 3349|       |		/* For better performance and robustness, we want
 3350|       |		 * to note which portion of the file actually
 3351|       |		 * contains valid data.
 3352|       |		 *
 3353|       |		 * This is particularly useful if we store certificates
 3354|       |		 * directly in the CDF - we may want to make the CDF
 3355|       |		 * fairly big, without having to read the entire file
 3356|       |		 * every time we parse the CDF.
 3357|       |		 */
 3358|  1.12k|		if (profile->pkcs15.encode_df_length) {
  ------------------
  |  Branch (3358:7): [True: 48, False: 1.07k]
  ------------------
 3359|     48|			df->path.count = (int)bufsize;
 3360|     48|			df->path.index = 0;
 3361|     48|			update_odf = 1;
 3362|     48|		}
 3363|  1.12k|		free(buf);
 3364|  1.12k|	}
 3365|  1.14k|	sc_file_free(file);
 3366|       |
 3367|  1.14k|	LOG_TEST_RET(ctx, r, "Failed to encode or update xDF");
  ------------------
  |  |  174|  1.14k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.14k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.14k|	int _ret = (r); \
  |  |  |  |  168|  1.14k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 283, False: 858]
  |  |  |  |  ------------------
  |  |  |  |  169|    283|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    283|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    283|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    283|		return _ret; \
  |  |  |  |  172|    283|	} \
  |  |  |  |  173|  1.14k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 858]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3368|       |
 3369|       |	/* Now update the ODF if we have to */
 3370|    858|	if (update_odf)
  ------------------
  |  Branch (3370:6): [True: 844, False: 14]
  ------------------
 3371|    844|		r = sc_pkcs15init_update_odf(p15card, profile);
 3372|    858|	LOG_TEST_RET(ctx, r, "Failed to encode or update ODF");
  ------------------
  |  |  174|    858|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    858|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    858|	int _ret = (r); \
  |  |  |  |  168|    858|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 103, False: 755]
  |  |  |  |  ------------------
  |  |  |  |  169|    103|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    103|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    103|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    103|		return _ret; \
  |  |  |  |  172|    103|	} \
  |  |  |  |  173|    858|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 755]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3373|       |
 3374|    755|	LOG_FUNC_RETURN(ctx, r > 0 ? SC_SUCCESS : r);
  ------------------
  |  |  164|    755|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    755|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.51k|	int _ret = r; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (154:13): [True: 754, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  155|    755|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 755, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    755|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 755]
  |  |  |  |  ------------------
  |  |  |  |  157|    755|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    755|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    755|	return _ret; \
  |  |  |  |  163|    755|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3375|    755|}
sc_pkcs15init_add_object:
 3383|  1.64k|{
 3384|  1.64k|	struct sc_context *ctx = p15card->card->ctx;
 3385|  1.64k|	struct sc_pkcs15_df *df;
 3386|  1.64k|	int is_new = 0, r = 0, object_added = 0;
 3387|       |
 3388|  1.64k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  1.64k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.64k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.64k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.64k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.64k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3389|  1.64k|	sc_log(ctx, "add object %p to DF of type %u", object, df_type);
  ------------------
  |  |   71|  1.64k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3390|       |
 3391|  1.64k|	df = find_df_by_type(p15card, df_type);
 3392|  1.64k|	if (df == NULL) {
  ------------------
  |  Branch (3392:6): [True: 1.56k, False: 80]
  ------------------
 3393|  1.56k|		struct sc_file	*file;
 3394|  1.56k|		file = profile->df[df_type];
 3395|  1.56k|		if (file == NULL) {
  ------------------
  |  Branch (3395:7): [True: 433, False: 1.13k]
  ------------------
 3396|    433|			sc_log(ctx, "Profile doesn't define a DF file %u", df_type);
  ------------------
  |  |   71|    433|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3397|    433|			LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "DF not found in profile");
  ------------------
  |  |  174|    433|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    433|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    433|	int _ret = (r); \
  |  |  |  |  168|    433|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 433, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    433|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    433|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    433|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    433|		return _ret; \
  |  |  |  |  172|    433|	} \
  |  |  |  |  173|    433|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3398|    433|		}
 3399|  1.13k|		sc_pkcs15_add_df(p15card, df_type, &file->path);
 3400|  1.13k|		df = find_df_by_type(p15card, df_type);
 3401|  1.13k|		if (df == NULL)
  ------------------
  |  Branch (3401:7): [True: 0, False: 1.13k]
  ------------------
 3402|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 3403|  1.13k|		is_new = 1;
 3404|       |
 3405|       |		/* Mark the df as enumerated, so libopensc doesn't try
 3406|       |		 * to load the file at a most inconvenient moment */
 3407|  1.13k|		df->enumerated = 1;
 3408|  1.13k|	}
 3409|       |
 3410|  1.21k|	if (object == NULL) {
  ------------------
  |  Branch (3410:6): [True: 824, False: 391]
  ------------------
 3411|    824|		sc_log(ctx, "Add nothing; just instantiate this directory file");
  ------------------
  |  |   71|    824|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3412|    824|	}
 3413|    391|	else if (object->df == NULL) {
  ------------------
  |  Branch (3413:11): [True: 391, False: 0]
  ------------------
 3414|    391|		sc_log(ctx, "Append object");
  ------------------
  |  |   71|    391|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3415|    391|		object->df = df;
 3416|    391|		r = sc_pkcs15_add_object(p15card, object);
 3417|    391|		LOG_TEST_RET(ctx, r, "Failed to add pkcs15 object");
  ------------------
  |  |  174|    391|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    391|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    391|	int _ret = (r); \
  |  |  |  |  168|    391|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 391]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|    391|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 391]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3418|    391|		object_added = 1;
 3419|    391|	}
 3420|      0|	else {
 3421|      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__
  |  |  ------------------
  ------------------
 3422|      0|		if (object->df != df)
  ------------------
  |  Branch (3422:7): [True: 0, False: 0]
  ------------------
 3423|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 3424|      0|	}
 3425|       |
 3426|  1.21k|	if (profile->ops->emu_update_any_df)
  ------------------
  |  Branch (3426:6): [True: 74, False: 1.14k]
  ------------------
 3427|     74|		r = profile->ops->emu_update_any_df(profile, p15card, SC_AC_OP_CREATE, object);
  ------------------
  |  |  169|     74|#define SC_AC_OP_CREATE			3
  ------------------
 3428|  1.14k|	else
 3429|  1.14k|		r = sc_pkcs15init_update_any_df(p15card, profile, df, is_new);
 3430|       |
 3431|  1.21k|	if (r < 0 && object_added)
  ------------------
  |  Branch (3431:6): [True: 418, False: 797]
  |  Branch (3431:15): [True: 281, False: 137]
  ------------------
 3432|    281|		sc_pkcs15_remove_object(p15card, object);
 3433|       |
 3434|  1.21k|	LOG_FUNC_RETURN(ctx, r > 0 ? SC_SUCCESS : r);
  ------------------
  |  |  164|  1.21k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.21k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.43k|	int _ret = r; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (154:13): [True: 18, False: 1.19k]
  |  |  |  |  ------------------
  |  |  |  |  155|  1.21k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.21k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.21k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    418|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 418, False: 797]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.21k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.21k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|  1.21k|	return _ret; \
  |  |  |  |  163|  1.21k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3435|  1.21k|}
sc_pkcs15init_new_object:
 3440|  25.0k|{
 3441|  25.0k|	struct sc_pkcs15_object	*object;
 3442|  25.0k|	unsigned int data_size = 0;
 3443|       |
 3444|  25.0k|	object = calloc(1, sizeof(*object));
 3445|  25.0k|	if (object == NULL)
  ------------------
  |  Branch (3445:6): [True: 0, False: 25.0k]
  ------------------
 3446|      0|		return NULL;
 3447|  25.0k|	object->type = type;
 3448|       |
 3449|  25.0k|	switch (type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|  25.0k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  |  Branch (3449:10): [True: 25.0k, False: 0]
  ------------------
 3450|  4.79k|	case SC_PKCS15_TYPE_AUTH:
  ------------------
  |  |  444|  4.79k|#define SC_PKCS15_TYPE_AUTH			0x600
  ------------------
  |  Branch (3450:2): [True: 4.79k, False: 20.2k]
  ------------------
 3451|  4.79k|		object->flags = DEFAULT_PIN_FLAGS;
  ------------------
  |  |   78|  4.79k|#define DEFAULT_PIN_FLAGS		(SC_PKCS15_CO_FLAG_PRIVATE|SC_PKCS15_CO_FLAG_MODIFIABLE)
  |  |  ------------------
  |  |  |  |   50|  4.79k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  |  |  ------------------
  |  |               #define DEFAULT_PIN_FLAGS		(SC_PKCS15_CO_FLAG_PRIVATE|SC_PKCS15_CO_FLAG_MODIFIABLE)
  |  |  ------------------
  |  |  |  |   51|  4.79k|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  |  |  ------------------
  ------------------
 3452|  4.79k|		data_size = sizeof(struct sc_pkcs15_auth_info);
 3453|  4.79k|		break;
 3454|  4.35k|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|  4.35k|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (3454:2): [True: 4.35k, False: 20.7k]
  ------------------
 3455|  4.35k|		object->flags = DEFAULT_PRKEY_FLAGS;
  ------------------
  |  |   79|  4.35k|#define DEFAULT_PRKEY_FLAGS		(SC_PKCS15_CO_FLAG_PRIVATE|SC_PKCS15_CO_FLAG_MODIFIABLE)
  |  |  ------------------
  |  |  |  |   50|  4.35k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  |  |  ------------------
  |  |               #define DEFAULT_PRKEY_FLAGS		(SC_PKCS15_CO_FLAG_PRIVATE|SC_PKCS15_CO_FLAG_MODIFIABLE)
  |  |  ------------------
  |  |  |  |   51|  4.35k|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  |  |  ------------------
  ------------------
 3456|  4.35k|		data_size = sizeof(struct sc_pkcs15_prkey_info);
 3457|  4.35k|		break;
 3458|  11.9k|	case SC_PKCS15_TYPE_SKEY:
  ------------------
  |  |  432|  11.9k|#define SC_PKCS15_TYPE_SKEY			0x300
  ------------------
  |  Branch (3458:2): [True: 11.9k, False: 13.1k]
  ------------------
 3459|  11.9k|		object->flags = DEFAULT_SKEY_FLAGS;
  ------------------
  |  |   81|  11.9k|#define DEFAULT_SKEY_FLAGS		(SC_PKCS15_CO_FLAG_PRIVATE|SC_PKCS15_CO_FLAG_MODIFIABLE)
  |  |  ------------------
  |  |  |  |   50|  11.9k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  |  |  ------------------
  |  |               #define DEFAULT_SKEY_FLAGS		(SC_PKCS15_CO_FLAG_PRIVATE|SC_PKCS15_CO_FLAG_MODIFIABLE)
  |  |  ------------------
  |  |  |  |   51|  11.9k|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  |  |  ------------------
  ------------------
 3460|  11.9k|		data_size = sizeof(struct sc_pkcs15_skey_info);
 3461|  11.9k|		break;
 3462|     10|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|     10|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (3462:2): [True: 10, False: 25.0k]
  ------------------
 3463|     10|		object->flags = DEFAULT_PUBKEY_FLAGS;
  ------------------
  |  |   80|     10|#define DEFAULT_PUBKEY_FLAGS		(SC_PKCS15_CO_FLAG_MODIFIABLE)
  |  |  ------------------
  |  |  |  |   51|     10|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  |  |  ------------------
  ------------------
 3464|     10|		data_size = sizeof(struct sc_pkcs15_pubkey_info);
 3465|     10|		break;
 3466|      0|	case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (3466:2): [True: 0, False: 25.0k]
  ------------------
 3467|      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
  |  |  ------------------
  ------------------
 3468|      0|		data_size = sizeof(struct sc_pkcs15_cert_info);
 3469|      0|		break;
 3470|  3.97k|	case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|  3.97k|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (3470:2): [True: 3.97k, False: 21.0k]
  ------------------
 3471|  3.97k|		object->flags = DEFAULT_DATA_FLAGS;
  ------------------
  |  |   83|  3.97k|#define DEFAULT_DATA_FLAGS		(SC_PKCS15_CO_FLAG_MODIFIABLE)
  |  |  ------------------
  |  |  |  |   51|  3.97k|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  |  |  ------------------
  ------------------
 3472|  3.97k|		if (auth_id->len != 0)
  ------------------
  |  Branch (3472:7): [True: 0, False: 3.97k]
  ------------------
 3473|      0|			object->flags |= SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|      0|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
 3474|  3.97k|		data_size = sizeof(struct sc_pkcs15_data_info);
 3475|  3.97k|		break;
 3476|  25.0k|	}
 3477|       |
 3478|  25.0k|	if (data_size) {
  ------------------
  |  Branch (3478:6): [True: 25.0k, False: 0]
  ------------------
 3479|  25.0k|		object->data = calloc(1, data_size);
 3480|  25.0k|		if (!object->data) {
  ------------------
  |  Branch (3480:7): [True: 0, False: 25.0k]
  ------------------
 3481|      0|			free(object);
 3482|      0|			return NULL;
 3483|      0|		}
 3484|       |
 3485|  25.0k|		if (data)
  ------------------
  |  Branch (3485:7): [True: 1.38k, False: 23.6k]
  ------------------
 3486|  1.38k|			memcpy(object->data, data, data_size);
 3487|  25.0k|	}
 3488|       |
 3489|  25.0k|	if (label)
  ------------------
  |  Branch (3489:6): [True: 25.0k, False: 0]
  ------------------
 3490|  25.0k|		strlcpy(object->label, label, sizeof(object->label));
  ------------------
  |  |   43|  25.0k|#define strlcpy _strlcpy
  ------------------
 3491|  25.0k|	if (auth_id)
  ------------------
  |  Branch (3491:6): [True: 20.2k, False: 4.79k]
  ------------------
 3492|  20.2k|		object->auth_id = *auth_id;
 3493|       |
 3494|  25.0k|	return object;
 3495|  25.0k|}
sc_pkcs15init_free_object:
 3500|  16.2k|{
 3501|  16.2k|	if (object) {
  ------------------
  |  Branch (3501:6): [True: 7.44k, False: 8.85k]
  ------------------
 3502|  7.44k|		free(object->data);
 3503|  7.44k|		free(object);
 3504|  7.44k|	}
 3505|  16.2k|}
sc_pkcs15init_verify_secret:
 3913|    812|{
 3914|    812|	struct sc_context *ctx = p15card->card->ctx;
 3915|    812|	struct sc_pkcs15_object *pin_obj = NULL;
 3916|    812|	struct sc_pkcs15_auth_info auth_info;
 3917|    812|	struct sc_path	*path;
 3918|    812|	int		r, use_pinpad = 0, pin_id = -1;
 3919|    812|	const char	*ident, *label = NULL;
 3920|    812|	unsigned char	pinbuf[0x100];
 3921|    812|	size_t		pinsize = 0;
 3922|       |
 3923|       |
 3924|    812|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    812|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    812|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    812|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    812|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 812]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3925|    812|	path = file? &file->path : NULL;
  ------------------
  |  Branch (3925:9): [True: 812, False: 0]
  ------------------
 3926|       |
 3927|    812|	ident = get_pin_ident_name(type, reference);
 3928|    812|	sc_log(ctx, "get and verify PIN('%s',type:0x%X,reference:0x%X)", ident, type, reference);
  ------------------
  |  |   71|    812|#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|       |
 3930|    812|	if (type == SC_AC_SEN)   {
  ------------------
  |  |  156|    812|#define SC_AC_SEN                       0x00000020 /* Security Environment. */
  ------------------
  |  Branch (3930:6): [True: 13, False: 799]
  ------------------
 3931|     13|		r = sc_card_ctl(p15card->card, SC_CARDCTL_GET_CHV_REFERENCE_IN_SE, (void *)(&reference));
 3932|     13|		sc_log(ctx, "Card CTL(GET_CHV_REFERENCE_IN_SE) returned %i", r);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3933|     13|		if (r > 0)   {
  ------------------
  |  Branch (3933:7): [True: 0, False: 13]
  ------------------
 3934|      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__
  |  |  ------------------
  ------------------
 3935|      0|			type = SC_AC_CHV;
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 3936|      0|			reference = r;
 3937|      0|		}
 3938|     13|		else if (r != SC_ERROR_NOT_SUPPORTED)
  ------------------
  |  |   89|     13|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  |  Branch (3938:12): [True: 1, False: 12]
  ------------------
 3939|      1|			LOG_TEST_RET(ctx, r, "Card CTL error: cannot get CHV 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3940|     13|	}
 3941|       |
 3942|    811|	memset(&auth_info, 0, sizeof(auth_info));
 3943|    811|	auth_info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|    811|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
 3944|    811|	auth_info.auth_method = type;
 3945|    811|	auth_info.attrs.pin.reference = reference;
 3946|       |
 3947|    811|	pin_id = sc_pkcs15init_get_pin_reference(p15card, profile, type, reference);
 3948|    811|	sc_log(ctx, "found PIN reference %i", pin_id);
  ------------------
  |  |   71|    811|#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|    811|	if (type == SC_AC_SYMBOLIC) {
  ------------------
  |  |  155|    811|#define SC_AC_SYMBOLIC			0x00000010 /* internal use only */
  ------------------
  |  Branch (3949:6): [True: 92, False: 719]
  ------------------
 3950|     92|		if (pin_id == -1)
  ------------------
  |  Branch (3950:7): [True: 42, False: 50]
  ------------------
 3951|     92|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3952|     50|		reference = pin_id;
 3953|     50|		type = SC_AC_CHV;
  ------------------
  |  |  151|     50|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 3954|     50|		sc_log(ctx, "Symbolic PIN resolved to PIN(type:CHV,reference:%i)", reference);
  ------------------
  |  |   71|     50|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3955|     50|	}
 3956|       |
 3957|    769|	if (path && path->len && path->len <= SC_MAX_PATH_SIZE) {
  ------------------
  |  |   47|    634|#define SC_MAX_PATH_SIZE		16
  ------------------
  |  Branch (3957:6): [True: 769, False: 0]
  |  Branch (3957:14): [True: 634, False: 135]
  |  Branch (3957:27): [True: 634, False: 0]
  ------------------
 3958|    634|		struct sc_path tmp_path = *path;
 3959|    634|		int iter;
 3960|    634|		r = SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|    634|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
 3961|  2.30k|		for (iter = (int)tmp_path.len / 2; iter >= 0 && r == SC_ERROR_OBJECT_NOT_FOUND; iter--) {
  ------------------
  |  |   88|  1.71k|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  |  Branch (3961:38): [True: 1.71k, False: 586]
  |  Branch (3961:51): [True: 1.66k, False: 48]
  ------------------
 3962|  1.66k|			r = sc_pkcs15_find_pin_by_type_and_reference(p15card,
 3963|  1.66k|					tmp_path.len ? &tmp_path : NULL,
  ------------------
  |  Branch (3963:6): [True: 1.08k, False: 586]
  ------------------
 3964|  1.66k|					type, reference, &pin_obj);
 3965|  1.66k|			tmp_path.len = tmp_path.len >= 2 ? tmp_path.len - 2 : 0;
  ------------------
  |  Branch (3965:19): [True: 1.08k, False: 586]
  ------------------
 3966|  1.66k|		}
 3967|    634|	}
 3968|    135|	else {
 3969|    135|		r = sc_pkcs15_find_pin_by_type_and_reference(p15card, NULL, type, reference, &pin_obj);
 3970|    135|	}
 3971|       |
 3972|    769|	if (!r && pin_obj)   {
  ------------------
  |  Branch (3972:6): [True: 214, False: 555]
  |  Branch (3972:12): [True: 214, False: 0]
  ------------------
 3973|    214|		memcpy(&auth_info, pin_obj->data, sizeof(auth_info));
 3974|    214|		sc_log(ctx, "found PIN object '%.*s'", (int) sizeof pin_obj->label, pin_obj->label);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3975|       |
 3976|       |		/* Check if the PIN has been already verified and the access condition
 3977|       |		 * is still open on card to avoid needless card operations and user
 3978|       |		 * prompts. */
 3979|    214|		if (pinsize == 0) {
  ------------------
  |  Branch (3979:7): [True: 214, False: 0]
  ------------------
 3980|    214|			r = sc_pkcs15_get_pin_info(p15card, pin_obj);
 3981|       |			/* update local copy of auth info */
 3982|    214|			memcpy(&auth_info, pin_obj->data, sizeof(auth_info));
 3983|       |
 3984|    214|			if (r == SC_SUCCESS && auth_info.logged_in & SC_PIN_STATE_LOGGED_IN)
  ------------------
  |  |   28|    428|#define SC_SUCCESS				0
  ------------------
              			if (r == SC_SUCCESS && auth_info.logged_in & SC_PIN_STATE_LOGGED_IN)
  ------------------
  |  |  432|    126|#define SC_PIN_STATE_LOGGED_IN  2
  ------------------
  |  Branch (3984:8): [True: 126, False: 88]
  |  Branch (3984:27): [True: 126, False: 0]
  ------------------
 3985|    214|				LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3986|    214|		}
 3987|    214|	}
 3988|       |
 3989|    643|	if (pin_obj)   {
  ------------------
  |  Branch (3989:6): [True: 88, False: 555]
  ------------------
 3990|     88|		sc_log(ctx, "PIN object '%.*s'; pin_obj->content.len:%zu",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3991|     88|				(int)sizeof(pin_obj->label), pin_obj->label, pin_obj->content.len);
 3992|     88|		if (pin_obj->content.value && pin_obj->content.len)   {
  ------------------
  |  Branch (3992:7): [True: 10, False: 78]
  |  Branch (3992:33): [True: 10, False: 0]
  ------------------
 3993|     10|			if (pin_obj->content.len > sizeof(pinbuf))
  ------------------
  |  Branch (3993:8): [True: 0, False: 10]
  ------------------
 3994|     10|				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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3995|     10|			memcpy(pinbuf, pin_obj->content.value, pin_obj->content.len);
 3996|     10|			pinsize = pin_obj->content.len;
 3997|     10|			sc_log(ctx, "'ve got '%s' value from cache", ident);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3998|     10|			goto found;
 3999|     10|		}
 4000|     88|	}
 4001|       |
 4002|    633|	if (pin_obj && pin_obj->label[0])
  ------------------
  |  Branch (4002:6): [True: 78, False: 555]
  |  Branch (4002:17): [True: 78, False: 0]
  ------------------
 4003|     78|		label = pin_obj->label;
 4004|       |
 4005|    633|	switch (type) {
 4006|    440|	case SC_AC_CHV:
  ------------------
  |  |  151|    440|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (4006:2): [True: 440, False: 193]
  ------------------
 4007|    440|		if (callbacks.get_pin)   {
  ------------------
  |  Branch (4007:7): [True: 0, False: 440]
  ------------------
 4008|      0|			pinsize = sizeof(pinbuf);
 4009|      0|			r = callbacks.get_pin(profile, pin_id, &auth_info, label, pinbuf, &pinsize);
 4010|      0|			sc_log(ctx, "'get_pin' callback returned %i; pinsize:%zu", r, pinsize);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4011|      0|		}
 4012|    440|		break;
 4013|     40|	case SC_AC_SCB:
  ------------------
  |  |  157|     40|#define SC_AC_SCB                       0x00000040 /* IAS/ECC SCB byte. */
  ------------------
  |  Branch (4013:2): [True: 40, False: 593]
  ------------------
 4014|     73|	case SC_AC_PRO:
  ------------------
  |  |  153|     73|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  |  Branch (4014:2): [True: 33, False: 600]
  ------------------
 4015|     73|		pinsize = 0;
 4016|     73|		r = 0;
 4017|     73|		break;
 4018|    120|	default:
  ------------------
  |  Branch (4018:2): [True: 120, False: 513]
  ------------------
 4019|    120|		pinsize = sizeof(pinbuf);
 4020|    120|		r = sc_pkcs15init_get_transport_key(profile, p15card, type, reference, pinbuf, &pinsize);
 4021|    120|		break;
 4022|    633|	}
 4023|       |
 4024|    633|	if (r == SC_ERROR_OBJECT_NOT_FOUND)   {
  ------------------
  |  |   88|    633|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  |  Branch (4024:6): [True: 362, False: 271]
  ------------------
 4025|    362|		if (p15card->card->reader->capabilities & SC_READER_CAP_PIN_PAD)
  ------------------
  |  |  376|    362|#define SC_READER_CAP_PIN_PAD	0x00000002
  ------------------
  |  Branch (4025:7): [True: 0, False: 362]
  ------------------
 4026|      0|			r = 0, use_pinpad = 1;
 4027|    362|		else
 4028|    362|			r = SC_ERROR_SECURITY_STATUS_NOT_SATISFIED;
  ------------------
  |  |   61|    362|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
 4029|    362|	}
 4030|       |
 4031|    633|	LOG_TEST_RET(ctx, r, "Failed to get secret");
  ------------------
  |  |  174|    633|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    633|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    633|	int _ret = (r); \
  |  |  |  |  168|    633|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 546, False: 87]
  |  |  |  |  ------------------
  |  |  |  |  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|    633|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 87]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4032|     87|	if (type == SC_AC_PRO)   {
  ------------------
  |  |  153|     87|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  |  Branch (4032:6): [True: 33, False: 54]
  ------------------
 4033|     33|		sc_log(ctx, "No 'verify' for secure messaging");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 4034|     33|		LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|     33|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     33|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     33|	int _ret = r; \
  |  |  |  |  155|     33|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 33, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     33|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 33]
  |  |  |  |  ------------------
  |  |  |  |  157|     33|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     33|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     33|	return _ret; \
  |  |  |  |  163|     33|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4035|     33|	}
 4036|       |
 4037|     64|found:
 4038|     64|	if (pin_obj) {
  ------------------
  |  Branch (4038:6): [True: 10, False: 54]
  ------------------
 4039|     10|		r = sc_pkcs15_verify_pin(p15card, pin_obj, use_pinpad || pinsize == 0 ? NULL : pinbuf, use_pinpad ? 0 : pinsize);
  ------------------
  |  Branch (4039:46): [True: 0, False: 10]
  |  Branch (4039:60): [True: 0, False: 10]
  |  Branch (4039:90): [True: 0, False: 10]
  ------------------
 4040|     10|		LOG_TEST_RET(ctx, r, "Cannot validate pkcs15 PIN");
  ------------------
  |  |  174|     10|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     10|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     10|	int _ret = (r); \
  |  |  |  |  168|     10|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  169|      6|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      6|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      6|		return _ret; \
  |  |  |  |  172|      6|	} \
  |  |  |  |  173|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4041|     10|	}
 4042|       |
 4043|     58|	if (file)   {
  ------------------
  |  Branch (4043:6): [True: 58, False: 0]
  ------------------
 4044|     58|		r = sc_select_file(p15card->card, &file->path, NULL);
 4045|     58|		LOG_TEST_RET(ctx, r, "Failed to select PIN path");
  ------------------
  |  |  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: 20, False: 38]
  |  |  |  |  ------------------
  |  |  |  |  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|     58|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 38]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4046|     58|	}
 4047|       |
 4048|     38|	if (!pin_obj) {
  ------------------
  |  Branch (4048:6): [True: 35, False: 3]
  ------------------
 4049|     35|		struct sc_pin_cmd_data pin_cmd;
 4050|       |
 4051|     35|		memset(&pin_cmd, 0, sizeof(pin_cmd));
 4052|     35|		pin_cmd.cmd = SC_PIN_CMD_VERIFY;
  ------------------
  |  |  415|     35|#define SC_PIN_CMD_VERIFY	0
  ------------------
 4053|     35|		pin_cmd.pin_type = type;
 4054|     35|		pin_cmd.pin_reference = reference;
 4055|     35|		pin_cmd.pin1.data = use_pinpad ? NULL : pinbuf;
  ------------------
  |  Branch (4055:23): [True: 0, False: 35]
  ------------------
 4056|     35|		pin_cmd.pin1.len = use_pinpad ? 0: pinsize;
  ------------------
  |  Branch (4056:22): [True: 0, False: 35]
  ------------------
 4057|       |
 4058|     35|		r = sc_pin_cmd(p15card->card, &pin_cmd);
 4059|     35|		LOG_TEST_RET(ctx, r, "'VERIFY' pin cmd 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: 28, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  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|     35|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4060|     35|	}
 4061|       |
 4062|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4063|     10|}
sc_pkcs15init_authenticate:
 4082|  7.72k|{
 4083|  7.72k|	struct sc_context *ctx = p15card->card->ctx;
 4084|  7.72k|	const struct sc_acl_entry *acl = NULL;
 4085|  7.72k|	struct sc_file *file_tmp = NULL;
 4086|  7.72k|	int  r = 0;
 4087|       |
 4088|  7.72k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  7.72k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  7.72k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  7.72k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  7.72k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 7.72k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4089|  7.72k|	if (file == NULL)
  ------------------
  |  Branch (4089:6): [True: 0, False: 7.72k]
  ------------------
 4090|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 4091|  7.72k|	sc_log(ctx, "path '%s', op=%u", sc_print_path(&file->path), op);
  ------------------
  |  |   71|  7.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__
  |  |  ------------------
  ------------------
 4092|       |
 4093|  7.72k|	if (file->acl_inactive) {
  ------------------
  |  Branch (4093:6): [True: 2.33k, False: 5.38k]
  ------------------
 4094|  2.33k|		sc_log(ctx, "access control mechanism is not active (always allowed)");
  ------------------
  |  |   71|  2.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__
  |  |  ------------------
  ------------------
 4095|  2.33k|		LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  2.33k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.33k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.33k|	int _ret = r; \
  |  |  |  |  155|  2.33k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.33k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.33k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 2.33k]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.33k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.33k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|  2.33k|	return _ret; \
  |  |  |  |  163|  2.33k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4096|  2.33k|	}
 4097|       |
 4098|  5.38k|	if (p15card->card->caps & SC_CARD_CAP_USE_FCI_AC) {
  ------------------
  |  |  557|  5.38k|#define SC_CARD_CAP_USE_FCI_AC		0x00000010
  ------------------
  |  Branch (4098:6): [True: 963, False: 4.42k]
  ------------------
 4099|    963|		r = sc_select_file(p15card->card, &file->path, &file_tmp);
 4100|    963|		LOG_TEST_RET(ctx, r, "Authentication failed: cannot select file.");
  ------------------
  |  |  174|    963|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    963|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    963|	int _ret = (r); \
  |  |  |  |  168|    963|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 333, False: 630]
  |  |  |  |  ------------------
  |  |  |  |  169|    333|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    333|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    333|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    333|		return _ret; \
  |  |  |  |  172|    333|	} \
  |  |  |  |  173|    963|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 630]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4101|       |
 4102|    630|		acl = sc_file_get_acl_entry(file_tmp, op);
 4103|    630|	}
 4104|  4.42k|	else   {
 4105|  4.42k|		acl = sc_file_get_acl_entry(file, op);
 4106|  4.42k|	}
 4107|  5.05k|	sc_log(ctx, "acl %p",acl);
  ------------------
  |  |   71|  5.05k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4108|       |
 4109|  5.86k|	for (; r == 0 && acl; acl = acl->next) {
  ------------------
  |  Branch (4109:9): [True: 5.26k, False: 601]
  |  Branch (4109:19): [True: 2.05k, False: 3.20k]
  ------------------
 4110|  2.05k|		if (acl->method == SC_AC_NEVER)   {
  ------------------
  |  |  163|  2.05k|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (4110:7): [True: 22, False: 2.03k]
  ------------------
 4111|     22|			sc_file_free(file_tmp);
 4112|     22|			LOG_TEST_RET(ctx, SC_ERROR_SECURITY_STATUS_NOT_SATISFIED, "Authentication failed: never allowed");
  ------------------
  |  |  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: 22, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|     22|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4113|     22|		}
 4114|  2.03k|		else if (acl->method == SC_AC_NONE)   {
  ------------------
  |  |  150|  2.03k|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (4114:12): [True: 1.20k, False: 831]
  ------------------
 4115|  1.20k|			sc_log(ctx, "always allowed");
  ------------------
  |  |   71|  1.20k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4116|  1.20k|			break;
 4117|  1.20k|		}
 4118|    831|		else if (acl->method == SC_AC_UNKNOWN)  {
  ------------------
  |  |  162|    831|#define SC_AC_UNKNOWN			0xFFFFFFFE
  ------------------
  |  Branch (4118:12): [True: 19, False: 812]
  ------------------
 4119|     19|			sc_log(ctx, "unknown acl method");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 4120|     19|			break;
 4121|     19|		}
 4122|    812|		sc_log(ctx, "verify acl(method:%i,reference:%i)", acl->method, acl->key_ref);
  ------------------
  |  |   71|    812|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4123|    812|		r = sc_pkcs15init_verify_secret(profile, p15card, file_tmp ? file_tmp : file, acl->method, acl->key_ref);
  ------------------
  |  Branch (4123:53): [True: 33, False: 779]
  ------------------
 4124|    812|	}
 4125|       |
 4126|  5.03k|	sc_file_free(file_tmp);
 4127|       |
 4128|  5.03k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  5.03k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  5.03k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  5.03k|	int _ret = r; \
  |  |  |  |  155|  5.03k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 5.03k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  5.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|    601|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 601, False: 4.43k]
  |  |  |  |  ------------------
  |  |  |  |  157|  5.03k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  5.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|  5.03k|	return _ret; \
  |  |  |  |  163|  5.03k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4129|  5.03k|}
sc_pkcs15init_create_file:
 4193|  3.54k|{
 4194|  3.54k|	struct sc_context *ctx = p15card->card->ctx;
 4195|  3.54k|	struct sc_file	*parent = NULL;
 4196|  3.54k|	int		r;
 4197|       |
 4198|  3.54k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  3.54k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.54k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.54k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.54k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.54k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4199|  3.54k|	if (!file) {
  ------------------
  |  Branch (4199:6): [True: 0, False: 3.54k]
  ------------------
 4200|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 4201|      0|	}
 4202|       |
 4203|  3.54k|	sc_log(ctx, "create file '%s'", sc_print_path(&file->path));
  ------------------
  |  |   71|  3.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__
  |  |  ------------------
  ------------------
 4204|       |	/* Select parent DF and verify PINs/key as necessary */
 4205|  3.54k|	r = do_select_parent(profile, p15card, file, &parent);
 4206|  3.54k|	LOG_TEST_RET(ctx, r, "Cannot create file: select parent error");
  ------------------
  |  |  174|  3.54k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  3.54k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  3.54k|	int _ret = (r); \
  |  |  |  |  168|  3.54k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 769, False: 2.77k]
  |  |  |  |  ------------------
  |  |  |  |  169|    769|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    769|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    769|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    769|		return _ret; \
  |  |  |  |  172|    769|	} \
  |  |  |  |  173|  3.54k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.77k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4207|       |
 4208|  2.77k|	r = sc_pkcs15init_authenticate(profile, p15card, parent, SC_AC_OP_CREATE);
  ------------------
  |  |  169|  2.77k|#define SC_AC_OP_CREATE			3
  ------------------
 4209|  2.77k|	LOG_TEST_GOTO_ERR(ctx, r, "Cannot create file: 'CREATE' authentication failed");
  ------------------
  |  |  184|  2.77k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  2.77k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  2.77k|	int _ret = (r); \
  |  |  |  |  178|  2.77k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 140, False: 2.63k]
  |  |  |  |  ------------------
  |  |  |  |  179|    140|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    140|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    140|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    140|		goto err; \
  |  |  |  |  182|    140|	} \
  |  |  |  |  183|  2.77k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 2.63k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4210|       |
 4211|       |	/* Fix up the file's ACLs */
 4212|  2.63k|	r = sc_pkcs15init_fixup_file(profile, p15card, file);
 4213|  2.63k|	LOG_TEST_GOTO_ERR(ctx, r, "Cannot create file: file fixup failed");
  ------------------
  |  |  184|  2.63k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  2.63k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  2.63k|	int _ret = (r); \
  |  |  |  |  178|  2.63k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 18, False: 2.61k]
  |  |  |  |  ------------------
  |  |  |  |  179|     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
  |  |  |  |  ------------------
  |  |  |  |  180|     18|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     18|		goto err; \
  |  |  |  |  182|     18|	} \
  |  |  |  |  183|  2.63k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 2.61k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4214|       |
 4215|       |	/* ensure we are in the correct lifecycle */
 4216|  2.61k|	r = sc_pkcs15init_set_lifecycle(p15card->card, SC_CARDCTRL_LIFECYCLE_ADMIN);
 4217|  2.61k|	if (r != SC_ERROR_NOT_SUPPORTED)
  ------------------
  |  |   89|  2.61k|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  |  Branch (4217:6): [True: 94, False: 2.52k]
  ------------------
 4218|  2.61k|		LOG_TEST_GOTO_ERR(ctx, r, "Cannot create file: failed to set lifecycle 'ADMIN'");
  ------------------
  |  |  184|     94|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     94|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     94|	int _ret = (r); \
  |  |  |  |  178|     94|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 13, False: 81]
  |  |  |  |  ------------------
  |  |  |  |  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|     94|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 81]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4219|       |
 4220|  2.60k|	r = sc_create_file(p15card->card, file);
 4221|  2.60k|	LOG_TEST_GOTO_ERR(ctx, r, "Create file failed");
  ------------------
  |  |  184|  2.60k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  2.60k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  2.60k|	int _ret = (r); \
  |  |  |  |  178|  2.60k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 539, False: 2.06k]
  |  |  |  |  ------------------
  |  |  |  |  179|    539|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    539|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    539|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    539|		goto err; \
  |  |  |  |  182|    539|	} \
  |  |  |  |  183|  2.60k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 2.06k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4222|       |
 4223|  2.77k|err:
 4224|  2.77k|	sc_file_free(parent);
 4225|  2.77k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  2.77k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.77k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.77k|	int _ret = r; \
  |  |  |  |  155|  2.77k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.77k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.77k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    710|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 710, False: 2.06k]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.77k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.77k|	} else { \
  |  |  |  |  159|      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.77k|	return _ret; \
  |  |  |  |  163|  2.77k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4226|  2.77k|}
sc_pkcs15init_update_file:
 4233|  2.49k|{
 4234|  2.49k|	struct sc_context *ctx = p15card->card->ctx;
 4235|  2.49k|	struct sc_file	*selected_file = NULL;
 4236|  2.49k|	void		*copy = NULL;
 4237|  2.49k|	int		r, need_to_zap = 0;
 4238|       |
 4239|  2.49k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  2.49k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  2.49k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  2.49k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  2.49k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2.49k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4240|  2.49k|	if (!file)
  ------------------
  |  Branch (4240:6): [True: 48, False: 2.44k]
  ------------------
 4241|  2.49k|		LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|     48|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     48|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     48|	int _ret = r; \
  |  |  |  |  155|     48|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 48, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     48|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     48|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 48, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     48|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     48|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     48|	return _ret; \
  |  |  |  |  163|     48|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4242|       |
 4243|  2.44k|	sc_log(ctx, "path:%s; datalen:%zu", sc_print_path(&file->path), datalen);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 4244|       |
 4245|  2.44k|	r = sc_select_file(p15card->card, &file->path, &selected_file);
 4246|  2.44k|	if (!r)   {
  ------------------
  |  Branch (4246:6): [True: 849, False: 1.59k]
  ------------------
 4247|    849|		need_to_zap = 1;
 4248|    849|	}
 4249|  1.59k|	else if (r == SC_ERROR_FILE_NOT_FOUND)   {
  ------------------
  |  |   51|  1.59k|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (4249:11): [True: 1.40k, False: 188]
  ------------------
 4250|       |		/* Create file if it doesn't exist */
 4251|  1.40k|		if (file->size < datalen)
  ------------------
  |  Branch (4251:7): [True: 364, False: 1.04k]
  ------------------
 4252|    364|			file->size = datalen;
 4253|       |
 4254|  1.40k|		r = sc_pkcs15init_create_file(profile, p15card, file);
 4255|  1.40k|		LOG_TEST_RET(ctx, r, "Failed to create file");
  ------------------
  |  |  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: 301, False: 1.10k]
  |  |  |  |  ------------------
  |  |  |  |  169|    301|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    301|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    301|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    301|		return _ret; \
  |  |  |  |  172|    301|	} \
  |  |  |  |  173|  1.40k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.10k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4256|       |
 4257|  1.10k|		r = sc_select_file(p15card->card, &file->path, &selected_file);
 4258|  1.10k|		LOG_TEST_RET(ctx, r, "Failed to select newly created file");
  ------------------
  |  |  174|  1.10k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.10k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.10k|	int _ret = (r); \
  |  |  |  |  168|  1.10k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 63, False: 1.04k]
  |  |  |  |  ------------------
  |  |  |  |  169|     63|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     63|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     63|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     63|		return _ret; \
  |  |  |  |  172|     63|	} \
  |  |  |  |  173|  1.10k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.04k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4259|  1.10k|	}
 4260|    188|	else   {
 4261|    188|		LOG_TEST_RET(ctx, r, "Failed to select file");
  ------------------
  |  |  174|    188|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    188|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    188|	int _ret = (r); \
  |  |  |  |  168|    188|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 188, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    188|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    188|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    188|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    188|		return _ret; \
  |  |  |  |  172|    188|	} \
  |  |  |  |  173|    188|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4262|    188|	}
 4263|       |
 4264|  1.89k|	if (selected_file->size < datalen) {
  ------------------
  |  Branch (4264:6): [True: 55, False: 1.83k]
  ------------------
 4265|     55|		sc_log(ctx, "File %s too small (require %zu, have %zu)",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 4266|     55|				sc_print_path(&file->path), datalen, selected_file->size);
 4267|     55|		sc_file_free(selected_file);
 4268|     55|		LOG_TEST_RET(ctx, SC_ERROR_FILE_TOO_SMALL, "Update file 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: 55, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|     55|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4269|     55|	}
 4270|  1.83k|	else if (selected_file->size > datalen && need_to_zap) {
  ------------------
  |  Branch (4270:11): [True: 1.71k, False: 124]
  |  Branch (4270:44): [True: 776, False: 936]
  ------------------
 4271|       |		/* zero out the rest of the file - we may have shrunk
 4272|       |		 * the file contents */
 4273|    776|		if (selected_file->size > MAX_FILE_SIZE) {
  ------------------
  |  |  220|    776|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (4273:7): [True: 29, False: 747]
  ------------------
 4274|     29|			sc_file_free(selected_file);
 4275|     29|			LOG_FUNC_RETURN(ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  164|     29|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     29|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     29|	int _ret = r; \
  |  |  |  |  155|     29|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 29, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     29|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     29|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 29, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     29|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     29|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     29|	return _ret; \
  |  |  |  |  163|     29|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4276|     29|		}
 4277|       |
 4278|    747|		copy = calloc(1, selected_file->size);
 4279|    747|		if (copy == NULL) {
  ------------------
  |  Branch (4279:7): [True: 0, False: 747]
  ------------------
 4280|      0|			sc_file_free(selected_file);
 4281|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 4282|      0|		}
 4283|    747|		memcpy(copy, data, datalen);
 4284|    747|		datalen = selected_file->size;
 4285|    747|		data = copy;
 4286|    747|	}
 4287|       |
 4288|       |	/* Present authentication info needed */
 4289|  1.80k|	r = sc_pkcs15init_authenticate(profile, p15card, selected_file, SC_AC_OP_UPDATE);
  ------------------
  |  |  189|  1.80k|#define SC_AC_OP_UPDATE			23
  ------------------
 4290|  1.80k|	if (r >= 0 && datalen)
  ------------------
  |  Branch (4290:6): [True: 1.77k, False: 33]
  |  Branch (4290:16): [True: 989, False: 785]
  ------------------
 4291|    989|		r = sc_update_binary(p15card->card, 0, (const unsigned char *) data, datalen, 0);
 4292|       |
 4293|  1.80k|	if (copy)
  ------------------
  |  Branch (4293:6): [True: 747, False: 1.06k]
  ------------------
 4294|    747|		free(copy);
 4295|  1.80k|	sc_file_free(selected_file);
 4296|  1.80k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  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: 909, False: 898]
  |  |  |  |  ------------------
  |  |  |  |  156|    909|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    123|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 123, False: 786]
  |  |  |  |  ------------------
  |  |  |  |  157|    909|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    909|	} else { \
  |  |  |  |  159|    898|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    898|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    898|	} \
  |  |  |  |  162|  1.80k|	return _ret; \
  |  |  |  |  163|  1.80k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4297|  1.80k|}
sc_pkcs15init_fixup_file:
 4369|  4.17k|{
 4370|  4.17k|	struct sc_context	*ctx = profile->card->ctx;
 4371|  4.17k|	struct sc_acl_entry	so_acl, user_acl;
 4372|  4.17k|	unsigned int	op, needfix = 0;
 4373|  4.17k|	int		rv, pin_ref;
 4374|       |
 4375|  4.17k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  4.17k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  4.17k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  4.17k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  4.17k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 4.17k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4376|       |	/* First, loop over all ACLs to find out whether there
 4377|       |	 * are still any symbolic references.
 4378|       |	 */
 4379|   133k|	for (op = 0; op < SC_MAX_AC_OPS; op++) {
  ------------------
  |  |  198|   133k|#define SC_MAX_AC_OPS			31
  ------------------
  |  Branch (4379:15): [True: 129k, False: 4.17k]
  ------------------
 4380|   129k|		const struct sc_acl_entry *acl;
 4381|       |
 4382|   129k|		acl = sc_file_get_acl_entry(file, op);
 4383|   258k|		for (; acl; acl = acl->next)
  ------------------
  |  Branch (4383:10): [True: 129k, False: 129k]
  ------------------
 4384|   129k|			if (acl->method == SC_AC_SYMBOLIC)
  ------------------
  |  |  155|   129k|#define SC_AC_SYMBOLIC			0x00000010 /* internal use only */
  ------------------
  |  Branch (4384:8): [True: 3.39k, False: 125k]
  ------------------
 4385|  3.39k|				needfix++;
 4386|   129k|	}
 4387|       |
 4388|  4.17k|	if (!needfix)
  ------------------
  |  Branch (4388:6): [True: 3.05k, False: 1.12k]
  ------------------
 4389|  4.17k|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  3.05k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.05k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.05k|	int _ret = r; \
  |  |  |  |  155|  3.05k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.05k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.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: 3.05k]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.05k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.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|  3.05k|	return _ret; \
  |  |  |  |  163|  3.05k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4390|       |
 4391|  1.12k|	pin_ref = sc_pkcs15init_get_pin_reference(p15card, profile, SC_AC_SYMBOLIC, SC_PKCS15INIT_SO_PIN);
  ------------------
  |  |  155|  1.12k|#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.12k|#define SC_PKCS15INIT_SO_PIN		0
  ------------------
 4392|  1.12k|	if (pin_ref < 0) {
  ------------------
  |  Branch (4392:6): [True: 343, False: 779]
  ------------------
 4393|    343|		so_acl.method = SC_AC_NONE;
  ------------------
  |  |  150|    343|#define SC_AC_NONE			0x00000000
  ------------------
 4394|    343|		so_acl.key_ref = 0;
 4395|    343|	}
 4396|    779|	else {
 4397|    779|		so_acl.method = SC_AC_CHV;
  ------------------
  |  |  151|    779|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 4398|    779|		so_acl.key_ref = pin_ref;
 4399|    779|	}
 4400|       |
 4401|  1.12k|	pin_ref = sc_pkcs15init_get_pin_reference(p15card, profile, SC_AC_SYMBOLIC, SC_PKCS15INIT_USER_PIN);
  ------------------
  |  |  155|  1.12k|#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.12k|#define SC_PKCS15INIT_USER_PIN		2
  ------------------
 4402|  1.12k|	if (pin_ref < 0) {
  ------------------
  |  Branch (4402:6): [True: 249, False: 873]
  ------------------
 4403|    249|		user_acl.method = SC_AC_NONE;
  ------------------
  |  |  150|    249|#define SC_AC_NONE			0x00000000
  ------------------
 4404|    249|		user_acl.key_ref = 0;
 4405|    249|	}
 4406|    873|	else {
 4407|    873|		user_acl.method = SC_AC_CHV;
  ------------------
  |  |  151|    873|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 4408|    873|		user_acl.key_ref = pin_ref;
 4409|    873|	}
 4410|  1.12k|	sc_log(ctx, "so_acl(method:%X,ref:%X), user_acl(method:%X,ref:%X)",
  ------------------
  |  |   71|  1.12k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4411|  1.12k|			so_acl.method, so_acl.key_ref, user_acl.method, user_acl.key_ref);
 4412|       |
 4413|  1.12k|	rv = sc_pkcs15init_fixup_acls(p15card, file, &so_acl, &user_acl);
 4414|       |
 4415|  1.12k|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|  1.12k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.12k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.12k|	int _ret = r; \
  |  |  |  |  155|  1.12k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.12k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.12k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     49|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 49, False: 1.07k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.12k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.12k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|  1.12k|	return _ret; \
  |  |  |  |  163|  1.12k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4416|  1.12k|}
sc_pkcs15init_get_pin_info:
 4436|  13.2k|{
 4437|  13.2k|	sc_profile_get_pin_info(profile, id, pin);
 4438|  13.2k|	return SC_SUCCESS;
  ------------------
  |  |   28|  13.2k|#define SC_SUCCESS				0
  ------------------
 4439|  13.2k|}
sc_pkcs15init_set_serial:
 4459|    124|{
 4460|    124|	if (profile->p15_spec->tokeninfo->serial_number)
  ------------------
  |  Branch (4460:6): [True: 124, False: 0]
  ------------------
 4461|    124|		free(profile->p15_spec->tokeninfo->serial_number);
 4462|    124|	profile->p15_spec->tokeninfo->serial_number = strdup(serial);
 4463|       |
 4464|    124|	return SC_SUCCESS;
  ------------------
  |  |   28|    124|#define SC_SUCCESS				0
  ------------------
 4465|    124|}
sc_pkcs15init_sanity_check:
 4473|  3.97k|{
 4474|  3.97k|	struct sc_context *ctx = p15card->card->ctx;
 4475|  3.97k|	int rv = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|  3.97k|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 4476|       |
 4477|  3.97k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  3.97k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.97k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.97k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.97k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.97k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4478|  3.97k|	if (profile->ops->sanity_check)
  ------------------
  |  Branch (4478:6): [True: 410, False: 3.56k]
  ------------------
 4479|    410|		rv = profile->ops->sanity_check(profile, p15card);
 4480|       |
 4481|  3.97k|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|  3.97k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.97k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.97k|	int _ret = r; \
  |  |  |  |  155|  3.97k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.97k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.97k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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.56k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 3.56k, False: 410]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.97k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.97k|	} else { \
  |  |  |  |  159|      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.97k|	return _ret; \
  |  |  |  |  163|  3.97k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4482|  3.97k|}
fuzz_pkcs15init.c:sc_pkcs15init_create_pin:
 1114|  2.85k|{
 1115|  2.85k|	struct sc_context *ctx = p15card->card->ctx;
 1116|  2.85k|	struct sc_pkcs15_auth_info *auth_info = (struct sc_pkcs15_auth_info *) pin_obj->data;
 1117|  2.85k|	struct sc_pkcs15_pin_attributes *pin_attrs = &auth_info->attrs.pin;
 1118|  2.85k|	struct sc_file	*df = profile->df_info->file;
 1119|  2.85k|	int		r, retry = 0;
 1120|       |
 1121|  2.85k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  2.85k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  2.85k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  2.85k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  2.85k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2.85k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 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|  2.85k|	if (profile->pin_domains) {
  ------------------
  |  Branch (1126:6): [True: 7, False: 2.85k]
  ------------------
 1127|      7|		if (!profile->ops->create_domain)
  ------------------
  |  Branch (1127:7): [True: 6, False: 1]
  ------------------
 1128|      7|			LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "PIN domains not supported.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1129|       |
 1130|      1|		r = profile->ops->create_domain(profile, p15card, &auth_info->auth_id, &df);
 1131|      1|		LOG_TEST_RET(ctx, r, "Card specific create domain 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1132|      1|	}
 1133|       |
 1134|       |	/* Path encoded only for local PINs */
 1135|  2.85k|	if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_LOCAL)
  ------------------
  |  |   55|  2.85k|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
  |  Branch (1135:6): [True: 2.82k, False: 22]
  ------------------
 1136|  2.82k|		auth_info->path = df->path;
 1137|       |
 1138|       |	/* pin_info->reference = 0; */
 1139|       |
 1140|       |	/* Loop until we come up with an acceptable pin reference */
 1141|  2.85k|	while (1) {
  ------------------
  |  Branch (1141:9): [True: 2.85k, Folded]
  ------------------
 1142|  2.85k|		if (profile->ops->select_pin_reference) {
  ------------------
  |  Branch (1142:7): [True: 2.58k, False: 272]
  ------------------
 1143|  2.58k|			r = profile->ops->select_pin_reference(profile, p15card, auth_info);
 1144|  2.58k|			LOG_TEST_RET(ctx, r, "Card specific select PIN reference failed");
  ------------------
  |  |  174|  2.58k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.58k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.58k|	int _ret = (r); \
  |  |  |  |  168|  2.58k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 974, False: 1.60k]
  |  |  |  |  ------------------
  |  |  |  |  169|    974|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    974|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    974|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    974|		return _ret; \
  |  |  |  |  172|    974|	} \
  |  |  |  |  173|  2.58k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.60k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1145|       |
 1146|  1.60k|			retry = 1;
 1147|  1.60k|		}
 1148|       |
 1149|  1.87k|		r = sc_pkcs15_find_pin_by_reference(p15card, &auth_info->path, pin_attrs->reference, NULL);
 1150|  1.87k|		if (r == SC_ERROR_OBJECT_NOT_FOUND)
  ------------------
  |  |   88|  1.87k|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  |  Branch (1150:7): [True: 1.87k, False: 2]
  ------------------
 1151|  1.87k|			break;
 1152|       |
 1153|      2|		if (r != 0 || !retry)
  ------------------
  |  Branch (1153:7): [True: 0, False: 2]
  |  Branch (1153:17): [True: 0, False: 2]
  ------------------
 1154|       |			/* Other error trying to retrieve pin obj */
 1155|      2|			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|      2|		pin_attrs->reference++;
 1158|      2|	}
 1159|       |
 1160|  1.87k|	if (args->puk_len == 0)
  ------------------
  |  Branch (1160:6): [True: 0, False: 1.87k]
  ------------------
 1161|      0|		pin_attrs->flags |= SC_PKCS15_PIN_FLAG_UNBLOCK_DISABLED;
  ------------------
  |  |   57|      0|#define SC_PKCS15_PIN_FLAG_UNBLOCK_DISABLED		0x0008
  ------------------
 1162|       |
 1163|  1.87k|	sc_log(ctx, "create PIN with reference:%X, flags:%X, path:%s",
  ------------------
  |  |   71|  1.87k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1164|  1.87k|			pin_attrs->reference, pin_attrs->flags, sc_print_path(&auth_info->path));
 1165|  1.87k|	r = profile->ops->create_pin(profile, p15card,
 1166|  1.87k|			df, pin_obj,
 1167|  1.87k|			args->pin, args->pin_len,
 1168|  1.87k|			args->puk, args->puk_len);
 1169|       |
 1170|  1.87k|	if (df != profile->df_info->file)
  ------------------
  |  Branch (1170:6): [True: 0, False: 1.87k]
  ------------------
 1171|      0|		sc_file_free(df);
 1172|       |
 1173|  1.87k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  1.87k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.87k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.87k|	int _ret = r; \
  |  |  |  |  155|  1.87k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.87k, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.87k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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.67k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.67k, False: 206]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.87k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.87k|	} 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.87k|	return _ret; \
  |  |  |  |  163|  1.87k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1174|  1.87k|}
fuzz_pkcs15init.c:sc_pkcs15init_init_prkdf:
 1228|  4.35k|{
 1229|  4.35k|	struct sc_context *ctx = p15card->card->ctx;
 1230|  4.35k|	struct sc_pkcs15_prkey_info *key_info = NULL;
 1231|  4.35k|	struct sc_pkcs15_keyinfo_gostparams *keyinfo_gostparams;
 1232|  4.35k|	struct sc_pkcs15_object *object = NULL;
 1233|  4.35k|	const char	*label;
 1234|  4.35k|	unsigned int	usage;
 1235|  4.35k|	int		r = 0, key_type;
 1236|  4.35k|	struct sc_ec_parameters *new_ecparams = NULL;
 1237|       |
 1238|  4.35k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  4.35k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  4.35k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  4.35k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  4.35k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 4.35k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1239|  4.35k|	if (!res_obj || !keybits) {
  ------------------
  |  Branch (1239:6): [True: 0, False: 4.35k]
  |  Branch (1239:18): [True: 0, False: 4.35k]
  ------------------
 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|  4.35k|	*res_obj = NULL;
 1245|       |
 1246|  4.35k|	if ((usage = keyargs->usage) == 0) {
  ------------------
  |  Branch (1246:6): [True: 4.35k, False: 0]
  ------------------
 1247|  4.35k|		if (keyargs->key.algorithm == SC_ALGORITHM_XEDDSA) {
  ------------------
  |  |   73|  4.35k|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (1247:7): [True: 0, False: 4.35k]
  ------------------
 1248|       |			/* Can not sign. To create a cert, see: openssl x509 -force_pubkey */
 1249|      0|			usage = SC_PKCS15_PRKEY_USAGE_DERIVE;
  ------------------
  |  |  313|      0|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
 1250|  4.35k|		} else {
 1251|  4.35k|			usage = SC_PKCS15_PRKEY_USAGE_SIGN;
  ------------------
  |  |  307|  4.35k|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
 1252|  4.35k|			if (keyargs->x509_usage)
  ------------------
  |  Branch (1252:8): [True: 0, False: 4.35k]
  ------------------
 1253|      0|				usage = sc_pkcs15init_map_usage(keyargs->x509_usage, 1);
 1254|  4.35k|		}
 1255|  4.35k|	}
 1256|       |
 1257|  4.35k|	if ((label = keyargs->label) == NULL)
  ------------------
  |  Branch (1257:6): [True: 4.35k, False: 0]
  ------------------
 1258|  4.35k|		label = DEFAULT_PRIVATE_KEY_LABEL;
  ------------------
  |  |   30|  4.35k|#define DEFAULT_PRIVATE_KEY_LABEL "Private Key"
  ------------------
 1259|       |
 1260|       |	/* Create the prkey object now.
 1261|       |	 * If we find out below that we're better off reusing an
 1262|       |	 * existing object, we'll ditch this one */
 1263|  4.35k|	key_type = key_pkcs15_algo(p15card, key->algorithm);
 1264|  4.35k|	r = key_type;
 1265|  4.35k|	LOG_TEST_GOTO_ERR(ctx, r, "Unsupported key type");
  ------------------
  |  |  184|  4.35k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  4.35k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  4.35k|	int _ret = (r); \
  |  |  |  |  178|  4.35k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 4.35k]
  |  |  |  |  ------------------
  |  |  |  |  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|  4.35k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 4.35k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1266|       |
 1267|  4.35k|	object = sc_pkcs15init_new_object(key_type, label, &keyargs->auth_id, NULL);
 1268|  4.35k|	if (object == NULL) {
  ------------------
  |  Branch (1268:6): [True: 0, False: 4.35k]
  ------------------
 1269|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1270|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1271|      0|	}
 1272|       |
 1273|  4.35k|	key_info = (struct sc_pkcs15_prkey_info *) object->data;
 1274|  4.35k|	key_info->usage = usage;
 1275|  4.35k|	key_info->native = 1;
 1276|  4.35k|	key_info->key_reference = 0;
 1277|  4.35k|	key_info->modulus_length = keybits;
 1278|  4.35k|	key_info->access_flags = keyargs->access_flags;
 1279|  4.35k|	object->user_consent = keyargs->user_consent;
 1280|       |	/* Path is selected below */
 1281|       |
 1282|  4.35k|	if (keyargs->access_flags & SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE) {
  ------------------
  |  |  317|  4.35k|#define SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE	0x02
  ------------------
  |  Branch (1282:6): [True: 0, False: 4.35k]
  ------------------
 1283|      0|		key_info->access_flags &= ~SC_PKCS15_PRKEY_ACCESS_NEVEREXTRACTABLE;
  ------------------
  |  |  319|      0|#define SC_PKCS15_PRKEY_ACCESS_NEVEREXTRACTABLE	0x08
  ------------------
 1284|      0|	}
 1285|       |
 1286|       |	/* Select a Key ID if the user didn't specify one,
 1287|       |	 * otherwise make sure it's compatible with our intended use */
 1288|  4.35k|	r = select_id(p15card, SC_PKCS15_TYPE_PRKEY, &keyargs->id);
  ------------------
  |  |  418|  4.35k|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
 1289|  4.35k|	LOG_TEST_GOTO_ERR(ctx, r, "Cannot select ID for PrKey object");
  ------------------
  |  |  184|  4.35k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  4.35k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  4.35k|	int _ret = (r); \
  |  |  |  |  178|  4.35k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 4.35k]
  |  |  |  |  ------------------
  |  |  |  |  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|  4.35k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 4.35k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1290|       |
 1291|  4.35k|	key_info->id = keyargs->id;
 1292|       |
 1293|  4.35k|	if (key->algorithm == SC_ALGORITHM_GOSTR3410) {
  ------------------
  |  |   71|  4.35k|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (1293:6): [True: 0, False: 4.35k]
  ------------------
 1294|      0|		key_info->params.len = sizeof(*keyinfo_gostparams);
 1295|       |		/* FIXME: malloc() call in pkcs15init, but free() call
 1296|       |		 * in libopensc (sc_pkcs15_free_prkey_info) */
 1297|      0|		key_info->params.data = malloc(key_info->params.len);
 1298|      0|		if (!key_info->params.data) {
  ------------------
  |  Branch (1298:7): [True: 0, False: 0]
  ------------------
 1299|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1300|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1301|      0|		}
 1302|      0|		keyinfo_gostparams = key_info->params.data;
 1303|      0|		keyinfo_gostparams->gostr3410 = keyargs->params.gost.gostr3410;
 1304|      0|		keyinfo_gostparams->gostr3411 = keyargs->params.gost.gostr3411;
 1305|      0|		keyinfo_gostparams->gost28147 = keyargs->params.gost.gost28147;
 1306|  4.35k|	} else if (key->algorithm == SC_ALGORITHM_EC ||
  ------------------
  |  |   70|  8.71k|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (1306:13): [True: 1.03k, False: 3.32k]
  ------------------
 1307|  3.32k|			key->algorithm == SC_ALGORITHM_EDDSA ||
  ------------------
  |  |   72|  7.67k|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (1307:4): [True: 0, False: 3.32k]
  ------------------
 1308|  3.32k|			key->algorithm == SC_ALGORITHM_XEDDSA) {
  ------------------
  |  |   73|  3.32k|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (1308:4): [True: 0, False: 3.32k]
  ------------------
 1309|       |		/* keyargs->key.u.ec.params.der.value is allocated in keyargs, which is on stack */
 1310|  1.03k|		struct sc_ec_parameters *ecparams = &keyargs->key.u.ec.params;
 1311|       |
 1312|  1.03k|		new_ecparams = calloc(1, sizeof(struct sc_ec_parameters));
 1313|  1.03k|		if (!new_ecparams) {
  ------------------
  |  Branch (1313:7): [True: 0, False: 1.03k]
  ------------------
 1314|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1315|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1316|      0|		}
 1317|  1.03k|		r = sc_copy_ec_params(new_ecparams, &keyargs->key.u.ec.params);
 1318|  1.03k|		LOG_TEST_GOTO_ERR(ctx, r, "Cannot copy EC parameters");
  ------------------
  |  |  184|  1.03k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  1.03k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  1.03k|	int _ret = (r); \
  |  |  |  |  178|  1.03k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 1.03k]
  |  |  |  |  ------------------
  |  |  |  |  179|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|  1.03k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1.03k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1319|       |
 1320|  1.03k|		key_info->params.data = new_ecparams;
 1321|  1.03k|		key_info->params.free_params = sc_pkcs15init_free_ec_params;
 1322|  1.03k|		key_info->field_length = ecparams->field_length;
 1323|  1.03k|		key_info->modulus_length = 0;
 1324|  1.03k|	}
 1325|       |
 1326|  4.35k|	r = select_object_path(p15card, profile, object, &key_info->path);
 1327|  4.35k|	LOG_TEST_GOTO_ERR(ctx, r, "Failed to select private key object path");
  ------------------
  |  |  184|  4.35k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  4.35k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  4.35k|	int _ret = (r); \
  |  |  |  |  178|  4.35k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 207, False: 4.14k]
  |  |  |  |  ------------------
  |  |  |  |  179|    207|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    207|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    207|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    207|		goto err; \
  |  |  |  |  182|    207|	} \
  |  |  |  |  183|  4.35k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 4.14k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1328|       |
 1329|       |	/* See if we need to select a key reference for this object */
 1330|  4.14k|	if (profile->ops->select_key_reference) {
  ------------------
  |  Branch (1330:6): [True: 2.17k, False: 1.97k]
  ------------------
 1331|  2.17k|		while (1) {
  ------------------
  |  Branch (1331:10): [True: 2.17k, Folded]
  ------------------
 1332|  2.17k|			sc_log(ctx, "Look for usable key reference starting from %i", key_info->key_reference);
  ------------------
  |  |   71|  2.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__
  |  |  ------------------
  ------------------
 1333|  2.17k|			r = profile->ops->select_key_reference(profile, p15card, key_info);
 1334|  2.17k|			LOG_TEST_GOTO_ERR(ctx, r, "Failed to select card specific key reference");
  ------------------
  |  |  184|  2.17k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  2.17k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  2.17k|	int _ret = (r); \
  |  |  |  |  178|  2.17k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 486, False: 1.68k]
  |  |  |  |  ------------------
  |  |  |  |  179|    486|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    486|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    486|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    486|		goto err; \
  |  |  |  |  182|    486|	} \
  |  |  |  |  183|  2.17k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1.68k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1335|       |
 1336|  1.68k|			r = sc_pkcs15_find_prkey_by_reference(p15card, &key_info->path, key_info->key_reference, NULL);
 1337|  1.68k|			if (r == SC_ERROR_OBJECT_NOT_FOUND)   {
  ------------------
  |  |   88|  1.68k|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  |  Branch (1337:8): [True: 1.68k, False: 0]
  ------------------
 1338|  1.68k|				sc_log(ctx, "Will use key reference %i", key_info->key_reference);
  ------------------
  |  |   71|  1.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__
  |  |  ------------------
  ------------------
 1339|  1.68k|				break;
 1340|  1.68k|			}
 1341|       |
 1342|      0|			if (r != 0) {
  ------------------
  |  Branch (1342:8): [True: 0, False: 0]
  ------------------
 1343|       |				/* Other error trying to retrieve pin obj */
 1344|      0|				r = SC_ERROR_TOO_MANY_OBJECTS;
  ------------------
  |  |   86|      0|#define SC_ERROR_TOO_MANY_OBJECTS		-1405
  ------------------
 1345|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1346|      0|			}
 1347|       |
 1348|      0|			key_info->key_reference++;
 1349|      0|		}
 1350|  2.17k|	}
 1351|       |
 1352|  3.66k|	*res_obj = object;
 1353|  3.66k|	object = NULL;
 1354|  3.66k|	new_ecparams = NULL;
 1355|  3.66k|	r = SC_SUCCESS;
  ------------------
  |  |   28|  3.66k|#define SC_SUCCESS				0
  ------------------
 1356|       |
 1357|  4.35k|err:
 1358|  4.35k|	if (new_ecparams) {
  ------------------
  |  Branch (1358:6): [True: 138, False: 4.21k]
  ------------------
 1359|    138|		sc_clear_ec_params(new_ecparams);
 1360|    138|		free(new_ecparams);
 1361|    138|		key_info->params.data = NULL;
 1362|    138|	}
 1363|  4.35k|	sc_pkcs15init_free_object(object);
 1364|  4.35k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  4.35k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  4.35k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  4.35k|	int _ret = r; \
  |  |  |  |  155|  4.35k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4.35k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  4.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|    693|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 693, False: 3.66k]
  |  |  |  |  ------------------
  |  |  |  |  157|  4.35k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  4.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|  4.35k|	return _ret; \
  |  |  |  |  163|  4.35k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1365|  4.35k|}
fuzz_pkcs15init.c:key_pkcs15_algo:
 2800|  16.2k|{
 2801|  16.2k|	struct sc_context *ctx = p15card->card->ctx;
 2802|       |
 2803|  16.2k|	switch (algorithm) {
  ------------------
  |  Branch (2803:10): [True: 16.2k, False: 0]
  ------------------
 2804|  3.32k|	case SC_ALGORITHM_RSA:
  ------------------
  |  |   69|  3.32k|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (2804:2): [True: 3.32k, False: 12.9k]
  ------------------
 2805|  3.32k|		return SC_PKCS15_TYPE_PRKEY_RSA;
  ------------------
  |  |  419|  3.32k|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
 2806|      0|	case SC_ALGORITHM_GOSTR3410:
  ------------------
  |  |   71|      0|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (2806:2): [True: 0, False: 16.2k]
  ------------------
 2807|      0|		return SC_PKCS15_TYPE_PRKEY_GOSTR3410;
  ------------------
  |  |  420|      0|#define SC_PKCS15_TYPE_PRKEY_GOSTR3410		0x103
  ------------------
 2808|  1.03k|	case SC_ALGORITHM_EC:
  ------------------
  |  |   70|  1.03k|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (2808:2): [True: 1.03k, False: 15.2k]
  ------------------
 2809|  1.03k|		return SC_PKCS15_TYPE_PRKEY_EC;
  ------------------
  |  |  421|  1.03k|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
 2810|      0|	case SC_ALGORITHM_EDDSA:
  ------------------
  |  |   72|      0|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (2810:2): [True: 0, False: 16.2k]
  ------------------
 2811|      0|		return SC_PKCS15_TYPE_PRKEY_EDDSA;
  ------------------
  |  |  422|      0|#define SC_PKCS15_TYPE_PRKEY_EDDSA		0x105
  ------------------
 2812|      0|	case SC_ALGORITHM_XEDDSA:
  ------------------
  |  |   73|      0|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (2812:2): [True: 0, False: 16.2k]
  ------------------
 2813|      0|		return SC_PKCS15_TYPE_PRKEY_XEDDSA;
  ------------------
  |  |  423|      0|#define SC_PKCS15_TYPE_PRKEY_XEDDSA		0x106
  ------------------
 2814|  3.97k|	case SC_ALGORITHM_DES:
  ------------------
  |  |   76|  3.97k|#define SC_ALGORITHM_DES		64
  ------------------
  |  Branch (2814:2): [True: 3.97k, False: 12.3k]
  ------------------
 2815|  3.97k|		return SC_PKCS15_TYPE_SKEY_DES;
  ------------------
  |  |  434|  3.97k|#define SC_PKCS15_TYPE_SKEY_DES			0x302
  ------------------
 2816|  3.97k|	case SC_ALGORITHM_3DES:
  ------------------
  |  |   77|  3.97k|#define SC_ALGORITHM_3DES		65
  ------------------
  |  Branch (2816:2): [True: 3.97k, False: 12.3k]
  ------------------
 2817|  3.97k|		return SC_PKCS15_TYPE_SKEY_3DES;
  ------------------
  |  |  436|  3.97k|#define SC_PKCS15_TYPE_SKEY_3DES		0x304
  ------------------
 2818|  3.97k|	case SC_ALGORITHM_AES:
  ------------------
  |  |   79|  3.97k|#define SC_ALGORITHM_AES		67
  ------------------
  |  Branch (2818:2): [True: 3.97k, False: 12.3k]
  ------------------
 2819|  3.97k|	case SC_ALGORITHM_UNDEFINED:
  ------------------
  |  |   80|  3.97k|#define SC_ALGORITHM_UNDEFINED		68	/* used with CKK_GENERIC_SECRET type keys */
  ------------------
  |  Branch (2819:2): [True: 0, False: 16.2k]
  ------------------
 2820|  3.97k|		return SC_PKCS15_TYPE_SKEY_GENERIC;
  ------------------
  |  |  433|  3.97k|#define SC_PKCS15_TYPE_SKEY_GENERIC		0x301
  ------------------
 2821|  16.2k|	}
 2822|      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__
  |  |  ------------------
  ------------------
 2823|      0|	return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 2824|  16.2k|}
fuzz_pkcs15init.c:sc_pkcs15init_free_ec_params:
  176|    894|{
  177|    894|	struct sc_ec_parameters *ecparams = (struct sc_ec_parameters *)ptr;
  178|    894|	if (ecparams) {
  ------------------
  |  Branch (178:6): [True: 894, False: 0]
  ------------------
  179|    894|		sc_clear_ec_params(ecparams);
  180|    894|		free(ecparams);
  181|    894|	}
  182|    894|}
fuzz_pkcs15init.c:sc_pkcs15init_init_skdf:
 1373|  11.9k|{
 1374|  11.9k|	struct sc_context *ctx = p15card->card->ctx;
 1375|  11.9k|	struct sc_pkcs15_skey_info *key_info;
 1376|  11.9k|	struct sc_pkcs15_object *object = NULL;
 1377|  11.9k|	const char	*label;
 1378|  11.9k|	unsigned int	usage;
 1379|  11.9k|	unsigned long	keybits = keyargs->value_len;
 1380|  11.9k|	int		r = 0, key_type;
 1381|       |
 1382|  11.9k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  11.9k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  11.9k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  11.9k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  11.9k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 11.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1383|  11.9k|	if (!res_obj || !keybits) {
  ------------------
  |  Branch (1383:6): [True: 0, False: 11.9k]
  |  Branch (1383:18): [True: 0, False: 11.9k]
  ------------------
 1384|      0|		r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1385|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1386|      0|	}
 1387|       |
 1388|  11.9k|	*res_obj = NULL;
 1389|       |
 1390|  11.9k|	if ((usage = keyargs->usage) == 0) {
  ------------------
  |  Branch (1390:6): [True: 0, False: 11.9k]
  ------------------
 1391|      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
  ------------------
 1392|      0|	}
 1393|       |
 1394|  11.9k|	if ((label = keyargs->label) == NULL)
  ------------------
  |  Branch (1394:6): [True: 11.9k, False: 0]
  ------------------
 1395|  11.9k|		label = DEFAULT_SECRET_KEY_LABEL;
  ------------------
  |  |   31|  11.9k|#define DEFAULT_SECRET_KEY_LABEL  "Secret Key"
  ------------------
 1396|       |
 1397|       |	/* Create the skey object now.
 1398|       |	 * If we find out below that we're better off reusing an
 1399|       |	 * existing object, we'll ditch this one */
 1400|  11.9k|	key_type = key_pkcs15_algo(p15card, keyargs->algorithm);
 1401|  11.9k|	r = key_type;
 1402|  11.9k|	LOG_TEST_GOTO_ERR(ctx, r, "Unsupported key type");
  ------------------
  |  |  184|  11.9k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  11.9k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  11.9k|	int _ret = (r); \
  |  |  |  |  178|  11.9k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 11.9k]
  |  |  |  |  ------------------
  |  |  |  |  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|  11.9k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 11.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1403|       |
 1404|  11.9k|	object = sc_pkcs15init_new_object(key_type, label, &keyargs->auth_id, NULL);
 1405|  11.9k|	if (object == NULL) {
  ------------------
  |  Branch (1405:6): [True: 0, False: 11.9k]
  ------------------
 1406|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1407|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1408|      0|	}
 1409|       |
 1410|  11.9k|	key_info = (struct sc_pkcs15_skey_info *) object->data;
 1411|  11.9k|	key_info->usage = usage;
 1412|  11.9k|	key_info->native = 1;
 1413|  11.9k|	key_info->key_reference = 0;
 1414|  11.9k|	switch (keyargs->algorithm) {
 1415|  3.97k|	case SC_ALGORITHM_DES:
  ------------------
  |  |   76|  3.97k|#define SC_ALGORITHM_DES		64
  ------------------
  |  Branch (1415:2): [True: 3.97k, False: 7.95k]
  ------------------
 1416|  3.97k|		key_info->key_type = CKK_DES;
  ------------------
  |  |  473|  3.97k|#define CKK_DES 0x00000013UL
  ------------------
 1417|  3.97k|		break;
 1418|  3.97k|	case SC_ALGORITHM_3DES:
  ------------------
  |  |   77|  3.97k|#define SC_ALGORITHM_3DES		65
  ------------------
  |  Branch (1418:2): [True: 3.97k, False: 7.95k]
  ------------------
 1419|  3.97k|		key_info->key_type = CKK_DES3;
  ------------------
  |  |  475|  3.97k|#define CKK_DES3 0x00000015UL
  ------------------
 1420|  3.97k|		break;
 1421|  3.97k|	case SC_ALGORITHM_AES:
  ------------------
  |  |   79|  3.97k|#define SC_ALGORITHM_AES		67
  ------------------
  |  Branch (1421:2): [True: 3.97k, False: 7.95k]
  ------------------
 1422|  3.97k|		key_info->key_type = CKK_AES;
  ------------------
  |  |  485|  3.97k|#define CKK_AES 0x0000001FUL
  ------------------
 1423|  3.97k|		break;
 1424|      0|	default:
  ------------------
  |  Branch (1424:2): [True: 0, False: 11.9k]
  ------------------
 1425|      0|		key_info->key_type = CKK_GENERIC_SECRET;
  ------------------
  |  |  470|      0|#define CKK_GENERIC_SECRET 0x00000010UL
  ------------------
 1426|      0|		break;
 1427|  11.9k|	}
 1428|  11.9k|	key_info->value_len = keybits;
 1429|  11.9k|	key_info->access_flags = keyargs->access_flags;
 1430|       |	/* Path is selected below */
 1431|       |
 1432|  11.9k|	if (keyargs->access_flags & SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE) {
  ------------------
  |  |  317|  11.9k|#define SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE	0x02
  ------------------
  |  Branch (1432:6): [True: 11.9k, False: 0]
  ------------------
 1433|  11.9k|		key_info->access_flags &= ~SC_PKCS15_PRKEY_ACCESS_NEVEREXTRACTABLE;
  ------------------
  |  |  319|  11.9k|#define SC_PKCS15_PRKEY_ACCESS_NEVEREXTRACTABLE	0x08
  ------------------
 1434|  11.9k|	}
 1435|       |
 1436|  11.9k|	if (keyargs->session_object > 0)
  ------------------
  |  Branch (1436:6): [True: 0, False: 11.9k]
  ------------------
 1437|      0|	    object->session_object = 1;
 1438|       |
 1439|  11.9k|	object->user_consent = keyargs->user_consent;
 1440|       |
 1441|       |	/* Select a Key ID if the user didn't specify one,
 1442|       |	 * otherwise make sure it's compatible with our intended use */
 1443|  11.9k|	r = select_id(p15card, SC_PKCS15_TYPE_SKEY, &keyargs->id);
  ------------------
  |  |  432|  11.9k|#define SC_PKCS15_TYPE_SKEY			0x300
  ------------------
 1444|  11.9k|	LOG_TEST_GOTO_ERR(ctx, r, "Cannot select ID for SKey object");
  ------------------
  |  |  184|  11.9k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  11.9k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  11.9k|	int _ret = (r); \
  |  |  |  |  178|  11.9k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 11.9k]
  |  |  |  |  ------------------
  |  |  |  |  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|  11.9k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 11.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1445|       |
 1446|  11.9k|	key_info->id = keyargs->id;
 1447|       |
 1448|  11.9k|	r = select_object_path(p15card, profile, object, &key_info->path);
 1449|  11.9k|	LOG_TEST_GOTO_ERR(ctx, r, "Failed to select secret key object path");
  ------------------
  |  |  184|  11.9k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  11.9k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  11.9k|	int _ret = (r); \
  |  |  |  |  178|  11.9k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 483, False: 11.4k]
  |  |  |  |  ------------------
  |  |  |  |  179|    483|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    483|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    483|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    483|		goto err; \
  |  |  |  |  182|    483|	} \
  |  |  |  |  183|  11.9k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 11.4k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1450|       |
 1451|       |	/* See if we need to select a key reference for this object */
 1452|  11.4k|	if (profile->ops->select_key_reference) {
  ------------------
  |  Branch (1452:6): [True: 6.26k, False: 5.18k]
  ------------------
 1453|  6.26k|		r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|  6.26k|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1454|  6.26k|		LOG_TEST_GOTO_ERR(ctx, r, "SKey keyreference selection not supported");
  ------------------
  |  |  184|  6.26k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  6.26k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  6.26k|	int _ret = (r); \
  |  |  |  |  178|  6.26k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 6.26k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|  6.26k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.26k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|  6.26k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|  6.26k|		goto err; \
  |  |  |  |  182|  6.26k|	} \
  |  |  |  |  183|  6.26k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1455|  6.26k|	}
 1456|       |
 1457|  5.18k|	*res_obj = object;
 1458|  5.18k|	object = NULL;
 1459|  5.18k|	r = SC_SUCCESS;
  ------------------
  |  |   28|  5.18k|#define SC_SUCCESS				0
  ------------------
 1460|       |
 1461|  11.9k|err:
 1462|  11.9k|	sc_pkcs15init_free_object(object);
 1463|  11.9k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  11.9k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  11.9k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  11.9k|	int _ret = r; \
  |  |  |  |  155|  11.9k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 11.9k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  11.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|  6.74k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 6.74k, False: 5.18k]
  |  |  |  |  ------------------
  |  |  |  |  157|  11.9k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  11.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|  11.9k|	return _ret; \
  |  |  |  |  163|  11.9k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1464|  11.9k|}
fuzz_pkcs15init.c:sc_pkcs15init_store_data:
 2428|  3.98k|{
 2429|  3.98k|	struct sc_context *ctx = p15card->card->ctx;
 2430|  3.98k|	struct sc_file	*file = NULL;
 2431|  3.98k|	int		r;
 2432|       |
 2433|  3.98k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  3.98k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.98k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.98k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.98k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.98k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2434|       |
 2435|  3.98k|	if (profile->ops->emu_store_data)   {
  ------------------
  |  Branch (2435:6): [True: 1.16k, False: 2.81k]
  ------------------
 2436|  1.16k|		r = profile->ops->emu_store_data(p15card, profile, object, data, path);
 2437|  1.16k|		if (r == SC_SUCCESS || r != SC_ERROR_NOT_IMPLEMENTED)
  ------------------
  |  |   28|  2.33k|#define SC_SUCCESS				0
  ------------------
              		if (r == SC_SUCCESS || r != SC_ERROR_NOT_IMPLEMENTED)
  ------------------
  |  |   97|  1.16k|#define SC_ERROR_NOT_IMPLEMENTED		-1416
  ------------------
  |  Branch (2437:7): [True: 3, False: 1.16k]
  |  Branch (2437:26): [True: 794, False: 372]
  ------------------
 2438|  1.16k|			LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    797|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    797|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    797|	int _ret = r; \
  |  |  |  |  155|    797|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 588, False: 209]
  |  |  |  |  ------------------
  |  |  |  |  156|    588|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    585|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 585, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  157|    588|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    588|	} else { \
  |  |  |  |  159|    209|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    209|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    209|	} \
  |  |  |  |  162|    797|	return _ret; \
  |  |  |  |  163|    797|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2439|  1.16k|	}
 2440|       |
 2441|  3.19k|	r = select_object_path(p15card, profile, object, path);
 2442|  3.19k|	LOG_TEST_RET(ctx, r, "Failed to select object path");
  ------------------
  |  |  174|  3.19k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  3.19k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  3.19k|	int _ret = (r); \
  |  |  |  |  168|  3.19k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 166, False: 3.02k]
  |  |  |  |  ------------------
  |  |  |  |  169|    166|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    166|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    166|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    166|		return _ret; \
  |  |  |  |  172|    166|	} \
  |  |  |  |  173|  3.19k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3.02k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2443|       |
 2444|  3.02k|	r = sc_profile_get_file_by_path(profile, path, &file);
 2445|  3.02k|	LOG_TEST_RET(ctx, r, "Failed to get file by path");
  ------------------
  |  |  174|  3.02k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  3.02k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  3.02k|	int _ret = (r); \
  |  |  |  |  168|  3.02k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.71k, False: 1.30k]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.71k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.71k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.71k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.71k|		return _ret; \
  |  |  |  |  172|  1.71k|	} \
  |  |  |  |  173|  3.02k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.30k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2446|       |
 2447|  1.30k|	if (file->path.count == 0) {
  ------------------
  |  Branch (2447:6): [True: 110, False: 1.19k]
  ------------------
 2448|    110|		file->path.index = 0;
 2449|    110|		file->path.count = -1;
 2450|    110|	}
 2451|       |
 2452|  1.30k|	r = sc_pkcs15init_delete_by_path(profile, p15card, &file->path);
 2453|  1.30k|	if (r && r != SC_ERROR_FILE_NOT_FOUND) {
  ------------------
  |  |   51|  1.22k|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (2453:6): [True: 1.22k, False: 80]
  |  Branch (2453:11): [True: 949, False: 279]
  ------------------
 2454|    949|		sc_file_free(file);
 2455|    949|		LOG_TEST_RET(ctx, r, "Cannot delete file");
  ------------------
  |  |  174|    949|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    949|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    949|	int _ret = (r); \
  |  |  |  |  168|    949|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 949, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    949|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    949|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    949|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    949|		return _ret; \
  |  |  |  |  172|    949|	} \
  |  |  |  |  173|    949|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2456|    949|	}
 2457|       |
 2458|    359|	r = sc_pkcs15init_update_file(profile, p15card, file, data->value, data->len);
 2459|       |
 2460|    359|	*path = file->path;
 2461|       |
 2462|    359|	sc_file_free(file);
 2463|    359|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    359|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    359|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    359|	int _ret = r; \
  |  |  |  |  155|    359|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 319, False: 40]
  |  |  |  |  ------------------
  |  |  |  |  156|    319|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    319|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 319, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    319|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    319|	} else { \
  |  |  |  |  159|     40|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     40|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     40|	} \
  |  |  |  |  162|    359|	return _ret; \
  |  |  |  |  163|    359|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2464|    359|}
fuzz_pkcs15init.c:sc_pkcs15init_keybits:
 2522|      2|{
 2523|      2|	unsigned int	mask;
 2524|      2|	size_t bits;
 2525|       |
 2526|      2|	if (!bn || !bn->len)
  ------------------
  |  Branch (2526:6): [True: 0, False: 2]
  |  Branch (2526:13): [True: 0, False: 2]
  ------------------
 2527|      0|		return 0;
 2528|      2|	bits = bn->len << 3;
 2529|     18|	for (mask = 0x80; mask && !(bn->data[0] & mask); mask >>= 1)
  ------------------
  |  Branch (2529:20): [True: 16, False: 2]
  |  Branch (2529:28): [True: 16, False: 0]
  ------------------
 2530|     16|		bits--;
 2531|      2|	return bits;
 2532|      2|}
fuzz_pkcs15init.c:check_keygen_params_consistency:
 2542|  19.8k|{
 2543|  19.8k|	struct sc_context *ctx = card->ctx;
 2544|  19.8k|	int i, rv;
 2545|       |
 2546|  19.8k|	if (prkey && (alg == SC_ALGORITHM_EC ||
  ------------------
  |  |   70|  15.9k|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (2546:6): [True: 7.95k, False: 11.9k]
  |  Branch (2546:16): [True: 3.97k, False: 3.97k]
  ------------------
 2547|  3.97k|				     alg == SC_ALGORITHM_EDDSA ||
  ------------------
  |  |   72|  11.9k|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (2547:10): [True: 0, False: 3.97k]
  ------------------
 2548|  3.97k|				     alg == SC_ALGORITHM_XEDDSA)) {
  ------------------
  |  |   73|  3.97k|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (2548:10): [True: 0, False: 3.97k]
  ------------------
 2549|  3.97k|		struct sc_ec_parameters *ecparams = &prkey->key.u.ec.params;
 2550|       |
 2551|  3.97k|		rv = sc_pkcs15_fix_ec_parameters(ctx, ecparams);
 2552|  3.97k|		LOG_TEST_RET(ctx, rv, "Cannot fix EC parameters");
  ------------------
  |  |  174|  3.97k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  3.97k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  3.97k|	int _ret = (r); \
  |  |  |  |  168|  3.97k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 3.97k]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#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.97k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3.97k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2553|       |
 2554|  3.97k|		sc_log(ctx, "EC parameters: %s", sc_dump_hex(ecparams->der.value, ecparams->der.len));
  ------------------
  |  |   71|  3.97k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2555|  3.97k|		if (!*keybits)
  ------------------
  |  Branch (2555:7): [True: 3.97k, False: 0]
  ------------------
 2556|  3.97k|			*keybits = (unsigned int)ecparams->field_length;
 2557|  3.97k|	}
 2558|       |
 2559|  96.6k|	for (i = 0; i < card->algorithm_count; i++) {
  ------------------
  |  Branch (2559:14): [True: 81.8k, False: 14.8k]
  ------------------
 2560|  81.8k|		struct sc_algorithm_info *info = &card->algorithms[i];
 2561|       |
 2562|  81.8k|		if (info->algorithm != alg)
  ------------------
  |  Branch (2562:7): [True: 71.2k, False: 10.6k]
  ------------------
 2563|  71.2k|			continue;
 2564|       |
 2565|  10.6k|		if (info->key_length != *keybits)
  ------------------
  |  Branch (2565:7): [True: 5.52k, False: 5.09k]
  ------------------
 2566|  5.52k|			continue;
 2567|       |
 2568|  5.09k|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  5.09k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  5.09k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  5.09k|	int _ret = r; \
  |  |  |  |  155|  5.09k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 5.09k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  5.09k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 5.09k]
  |  |  |  |  ------------------
  |  |  |  |  157|  5.09k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  5.09k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|  5.09k|	return _ret; \
  |  |  |  |  163|  5.09k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2569|  5.09k|	}
 2570|       |
 2571|  14.8k|	if (prkey && (alg == SC_ALGORITHM_EC ||
  ------------------
  |  |   70|  7.10k|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (2571:6): [True: 3.55k, False: 11.2k]
  |  Branch (2571:16): [True: 2.94k, False: 606]
  ------------------
 2572|    606|				     alg == SC_ALGORITHM_EDDSA ||
  ------------------
  |  |   72|  4.15k|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (2572:10): [True: 0, False: 606]
  ------------------
 2573|  2.94k|				     alg == SC_ALGORITHM_XEDDSA)) {
  ------------------
  |  |   73|    606|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (2573:10): [True: 0, False: 606]
  ------------------
 2574|       |		/* allocated in sc_pkcs15_fix_ec_parameters */
 2575|  2.94k|		free(prkey->key.u.ec.params.der.value);
 2576|  2.94k|		prkey->key.u.ec.params.der.value = NULL;
 2577|  2.94k|	}
 2578|       |
 2579|  14.8k|	LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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|  14.8k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 14.8k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2580|  14.8k|}
fuzz_pkcs15init.c:check_key_compatibility:
 2589|  17.0k|{
 2590|  17.0k|	struct sc_context *ctx = p15card->card->ctx;
 2591|  17.0k|	struct sc_algorithm_info *info;
 2592|  17.0k|	unsigned int count;
 2593|  17.0k|	unsigned long talg = alg;
 2594|       |
 2595|  17.0k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  17.0k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  17.0k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  17.0k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  17.0k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 17.0k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2596|       |
 2597|  17.0k|	if (alg == SC_ALGORITHM_EDDSA || alg == SC_ALGORITHM_XEDDSA)
  ------------------
  |  |   72|  34.0k|#define SC_ALGORITHM_EDDSA		4
  ------------------
              	if (alg == SC_ALGORITHM_EDDSA || alg == SC_ALGORITHM_XEDDSA)
  ------------------
  |  |   73|  17.0k|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (2597:6): [True: 0, False: 17.0k]
  |  Branch (2597:35): [True: 0, False: 17.0k]
  ------------------
 2598|      0|		talg = SC_ALGORITHM_EC; /* really testing ecparams */
  ------------------
  |  |   70|      0|#define SC_ALGORITHM_EC		2
  ------------------
 2599|       |
 2600|  17.0k|	count = p15card->card->algorithm_count;
 2601|  93.7k|	for (info = p15card->card->algorithms; count--; info++) {
  ------------------
  |  Branch (2601:41): [True: 81.7k, False: 11.9k]
  ------------------
 2602|       |		/* don't check flags if none was specified */
 2603|       |
 2604|  81.7k|		if (alg != SC_ALGORITHM_EDDSA && alg != SC_ALGORITHM_XEDDSA) {
  ------------------
  |  |   72|   163k|#define SC_ALGORITHM_EDDSA		4
  ------------------
              		if (alg != SC_ALGORITHM_EDDSA && alg != SC_ALGORITHM_XEDDSA) {
  ------------------
  |  |   73|  81.7k|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (2604:7): [True: 81.7k, False: 0]
  |  Branch (2604:36): [True: 81.7k, False: 0]
  ------------------
 2605|  81.7k|			if (info->algorithm != alg || info->key_length != key_length)
  ------------------
  |  Branch (2605:8): [True: 70.4k, False: 11.3k]
  |  Branch (2605:34): [True: 5.54k, False: 5.78k]
  ------------------
 2606|  75.9k|				continue;
 2607|  81.7k|		}
 2608|  5.78k|		if (flags != 0 && ((info->flags & flags) != flags))
  ------------------
  |  Branch (2608:7): [True: 5.09k, False: 690]
  |  Branch (2608:21): [True: 740, False: 4.35k]
  ------------------
 2609|    740|			continue;
 2610|       |
 2611|  5.04k|		if (alg == SC_ALGORITHM_RSA && prkey)   {
  ------------------
  |  |   69|  10.0k|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (2611:7): [True: 3.32k, False: 1.72k]
  |  Branch (2611:34): [True: 3.32k, False: 0]
  ------------------
 2612|  3.32k|			if (info->u._rsa.exponent != 0 && prkey->u.rsa.exponent.len != 0) {
  ------------------
  |  Branch (2612:8): [True: 919, False: 2.40k]
  |  Branch (2612:38): [True: 0, False: 919]
  ------------------
 2613|      0|				struct sc_pkcs15_bignum *e = &prkey->u.rsa.exponent;
 2614|      0|				unsigned long	exponent = 0;
 2615|      0|				unsigned int	n;
 2616|       |
 2617|      0|				if (e->len > 4)
  ------------------
  |  Branch (2617:9): [True: 0, False: 0]
  ------------------
 2618|      0|					continue;
 2619|      0|				for (n = 0; n < e->len; n++) {
  ------------------
  |  Branch (2619:17): [True: 0, False: 0]
  ------------------
 2620|      0|					exponent <<= 8;
 2621|      0|					exponent |= e->data[n];
 2622|      0|				}
 2623|      0|				if (info->u._rsa.exponent != exponent)
  ------------------
  |  Branch (2623:9): [True: 0, False: 0]
  ------------------
 2624|      0|					continue;
 2625|      0|			}
 2626|  3.32k|		} else if (talg == SC_ALGORITHM_EC) { /* includes EDDSA and XEDDSA */
  ------------------
  |  |   70|  1.72k|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (2626:14): [True: 1.03k, False: 690]
  ------------------
 2627|  1.03k|			if (!sc_valid_oid(&prkey->u.ec.params.id))
  ------------------
  |  Branch (2627:8): [True: 0, False: 1.03k]
  ------------------
 2628|      0|				if (sc_pkcs15_fix_ec_parameters(ctx, &prkey->u.ec.params))
  ------------------
  |  Branch (2628:9): [True: 0, False: 0]
  ------------------
 2629|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2630|  1.03k|			if (sc_valid_oid(&info->u._ec.params.id))
  ------------------
  |  Branch (2630:8): [True: 494, False: 538]
  ------------------
 2631|    494|				if (!sc_compare_oid(&info->u._ec.params.id, &prkey->u.ec.params.id))
  ------------------
  |  Branch (2631:9): [True: 0, False: 494]
  ------------------
 2632|      0|					continue;
 2633|  1.03k|		}
 2634|       |
 2635|  5.04k|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  5.04k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  5.04k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  5.04k|	int _ret = r; \
  |  |  |  |  155|  5.04k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 5.04k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  5.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: 5.04k]
  |  |  |  |  ------------------
  |  |  |  |  157|  5.04k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  5.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|  5.04k|	return _ret; \
  |  |  |  |  163|  5.04k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2636|  5.04k|	}
 2637|       |
 2638|  11.9k|	LOG_FUNC_RETURN(ctx, SC_ERROR_OBJECT_NOT_VALID);
  ------------------
  |  |  164|  11.9k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  11.9k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  11.9k|	int _ret = r; \
  |  |  |  |  155|  11.9k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 11.9k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  11.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|  11.9k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 11.9k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  11.9k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  11.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|  11.9k|	return _ret; \
  |  |  |  |  163|  11.9k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2639|  11.9k|}
fuzz_pkcs15init.c:select_id:
 2953|  16.3k|{
 2954|  16.3k|	struct sc_context *ctx = p15card->card->ctx;
 2955|  16.3k|	struct sc_pkcs15_id unused_id;
 2956|  16.3k|	struct sc_pkcs15_object *obj;
 2957|  16.3k|	unsigned int nid = DEFAULT_ID;
  ------------------
  |  |   77|  16.3k|#define DEFAULT_ID			0x45
  ------------------
 2958|  16.3k|	int r;
 2959|       |
 2960|  16.3k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  16.3k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  16.3k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  16.3k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  16.3k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 16.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2961|       |	/* If the user provided an ID, make sure we can use it */
 2962|  16.3k|	if (id->len != 0) {
  ------------------
  |  Branch (2962:6): [True: 12.9k, False: 3.40k]
  ------------------
 2963|  12.9k|		r = sc_pkcs15_find_object_by_id(p15card, type, id, &obj);
 2964|       |
 2965|  12.9k|		if (r == SC_ERROR_OBJECT_NOT_FOUND)
  ------------------
  |  |   88|  12.9k|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  |  Branch (2965:7): [True: 12.9k, False: 0]
  ------------------
 2966|  12.9k|			r = 0;
 2967|      0|		else if (!r)
  ------------------
  |  Branch (2967:12): [True: 0, False: 0]
  ------------------
 2968|      0|			r = SC_ERROR_NON_UNIQUE_ID;
  ------------------
  |  |  107|      0|#define SC_ERROR_NON_UNIQUE_ID			-1505
  ------------------
 2969|       |
 2970|  12.9k|		LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  12.9k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  12.9k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  12.9k|	int _ret = r; \
  |  |  |  |  155|  12.9k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 12.9k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  12.9k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 12.9k]
  |  |  |  |  ------------------
  |  |  |  |  157|  12.9k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  12.9k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|  12.9k|	return _ret; \
  |  |  |  |  163|  12.9k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2971|  12.9k|	}
 2972|       |
 2973|  3.40k|	memset(&unused_id, 0, sizeof(unused_id));
 2974|   635k|	while (nid < 255) {
  ------------------
  |  Branch (2974:9): [True: 632k, False: 3.40k]
  ------------------
 2975|   632k|		id->value[0] = nid++;
 2976|   632k|		id->len = 1;
 2977|       |
 2978|   632k|		r = sc_pkcs15_find_object_by_id(p15card, type, id, &obj);
 2979|   632k|		if (r == SC_ERROR_OBJECT_NOT_FOUND) {
  ------------------
  |  |   88|   632k|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  |  Branch (2979:7): [True: 632k, False: 0]
  ------------------
 2980|       |			/* We don't have an object of that type yet.
 2981|       |			 * If we're allocating a PRKEY object, make
 2982|       |			 * sure there's no conflicting pubkey or cert
 2983|       |			 * object either. */
 2984|   632k|			if (type == SC_PKCS15_TYPE_PRKEY) {
  ------------------
  |  |  418|   632k|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (2984:8): [True: 632k, False: 0]
  ------------------
 2985|   632k|				struct sc_pkcs15_search_key search_key;
 2986|       |
 2987|   632k|				memset(&search_key, 0, sizeof(search_key));
 2988|   632k|				search_key.class_mask = SC_PKCS15_SEARCH_CLASS_PUBKEY | SC_PKCS15_SEARCH_CLASS_CERT;
  ------------------
  |  |  451|   632k|#define SC_PKCS15_SEARCH_CLASS_PUBKEY		0x0004U
  ------------------
              				search_key.class_mask = SC_PKCS15_SEARCH_CLASS_PUBKEY | SC_PKCS15_SEARCH_CLASS_CERT;
  ------------------
  |  |  453|   632k|#define SC_PKCS15_SEARCH_CLASS_CERT		0x0010U
  ------------------
 2989|   632k|				search_key.id = id;
 2990|       |
 2991|   632k|				r = sc_pkcs15_search_objects(p15card, &search_key, NULL, 0);
 2992|       |				/* If there is a pubkey or cert with
 2993|       |				 * this ID, skip it. */
 2994|   632k|				if (r > 0)
  ------------------
  |  Branch (2994:9): [True: 1, False: 632k]
  ------------------
 2995|      1|					continue;
 2996|   632k|			}
 2997|   632k|			if (!unused_id.len)
  ------------------
  |  Branch (2997:8): [True: 3.40k, False: 628k]
  ------------------
 2998|  3.40k|				unused_id = *id;
 2999|   632k|			continue;
 3000|   632k|		}
 3001|   632k|	}
 3002|       |
 3003|  3.40k|	if (unused_id.len) {
  ------------------
  |  Branch (3003:6): [True: 3.40k, False: 0]
  ------------------
 3004|  3.40k|		*id = unused_id;
 3005|  3.40k|		LOG_FUNC_RETURN(ctx, 0);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 3.40k]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3006|  3.40k|	}
 3007|       |
 3008|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3009|      0|}
fuzz_pkcs15init.c:sc_pkcs15init_update_dir:
 3178|     75|{
 3179|     75|	struct sc_context *ctx = p15card->card->ctx;
 3180|     75|	struct sc_card	*card = p15card->card;
 3181|     75|	int r, retry = 1;
 3182|       |
 3183|     75|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     75|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     75|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     75|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     75|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 75]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3184|     75|	if (profile->ops->emu_update_dir)   {
  ------------------
  |  Branch (3184:6): [True: 0, False: 75]
  ------------------
 3185|      0|		r = profile->ops->emu_update_dir(profile, p15card, app);
 3186|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3187|      0|	}
 3188|       |
 3189|    118|	do {
 3190|    118|		struct sc_file	*dir_file;
 3191|    118|		struct sc_path	path;
 3192|       |
 3193|    118|		r = sc_enum_apps(card);
 3194|    118|		if (r != SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|    118|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (3194:7): [True: 69, False: 49]
  ------------------
 3195|     69|			break;
 3196|       |		/* DIR file is not yet created. */
 3197|       |
 3198|     49|		sc_format_path("3F002F00", &path);
 3199|     49|		r = sc_profile_get_file_by_path(profile, &path, &dir_file);
 3200|     49|		LOG_TEST_RET(ctx, r, "DIR file not defined in profile");
  ------------------
  |  |  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: 4, False: 45]
  |  |  |  |  ------------------
  |  |  |  |  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|     49|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 45]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3201|       |
 3202|       |		/* Create DIR file */
 3203|     45|		r = sc_pkcs15init_update_file(profile, p15card, dir_file, NULL, 0);
 3204|     45|		sc_file_free(dir_file);
 3205|     45|	} while (retry--);
  ------------------
  |  Branch (3205:11): [True: 43, False: 2]
  ------------------
 3206|       |
 3207|     71|	if (r >= 0) {
  ------------------
  |  Branch (3207:6): [True: 42, False: 29]
  ------------------
 3208|     42|		card->app[card->app_count++] = app;
 3209|     42|		r = sc_update_dir(card, NULL);
 3210|     42|	}
 3211|     71|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|     71|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     71|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     71|	int _ret = r; \
  |  |  |  |  155|     71|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 71, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     71|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     63|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 63, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  157|     71|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     71|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     71|	return _ret; \
  |  |  |  |  163|     71|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3212|     71|}
fuzz_pkcs15init.c:sc_pkcs15init_update_tokeninfo:
 3217|    714|{
 3218|    714|	struct sc_context *ctx = p15card->card->ctx;
 3219|    714|	unsigned char	*buf = NULL;
 3220|    714|	size_t		size;
 3221|    714|	int		rv;
 3222|       |
 3223|    714|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    714|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    714|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    714|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    714|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 714]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3224|       |
 3225|       |	/* set lastUpdate field */
 3226|    714|	if (p15card->tokeninfo->last_update.gtime != NULL)   {
  ------------------
  |  Branch (3226:6): [True: 1, False: 713]
  ------------------
 3227|      1|		free(p15card->tokeninfo->last_update.gtime);
 3228|      1|		p15card->tokeninfo->last_update.gtime = NULL;
 3229|      1|	}
 3230|    714|	rv = sc_pkcs15_get_generalized_time(ctx, &p15card->tokeninfo->last_update.gtime);
 3231|    714|	LOG_TEST_RET(ctx, rv, "Cannot allocate generalized time string");
  ------------------
  |  |  174|    714|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    714|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    714|	int _ret = (r); \
  |  |  |  |  168|    714|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 714]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|    714|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 714]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3232|       |
 3233|    714|	if (profile->ops->emu_update_tokeninfo)
  ------------------
  |  Branch (3233:6): [True: 30, False: 684]
  ------------------
 3234|     30|		return profile->ops->emu_update_tokeninfo(profile, p15card, p15card->tokeninfo);
 3235|       |
 3236|    684|	if (!p15card->file_tokeninfo)   {
  ------------------
  |  Branch (3236:6): [True: 560, False: 124]
  ------------------
 3237|    560|		sc_log(ctx, "No TokenInfo to update");
  ------------------
  |  |   71|    560|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3238|    560|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    560|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    560|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    560|	int _ret = r; \
  |  |  |  |  155|    560|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 560, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    560|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 560]
  |  |  |  |  ------------------
  |  |  |  |  157|    560|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    560|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    560|	return _ret; \
  |  |  |  |  163|    560|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3239|    560|	}
 3240|       |
 3241|    124|	rv = sc_pkcs15_encode_tokeninfo(ctx, p15card->tokeninfo, &buf, &size);
 3242|    124|	if (rv >= 0)
  ------------------
  |  Branch (3242:6): [True: 49, False: 75]
  ------------------
 3243|     49|		rv = sc_pkcs15init_update_file(profile, p15card, p15card->file_tokeninfo, buf, size);
 3244|    124|	if (buf)
  ------------------
  |  Branch (3244:6): [True: 49, False: 75]
  ------------------
 3245|     49|		free(buf);
 3246|       |
 3247|    124|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    124|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    124|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    124|	int _ret = r; \
  |  |  |  |  155|    124|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 121, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  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|      3|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      3|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      3|	} \
  |  |  |  |  162|    124|	return _ret; \
  |  |  |  |  163|    124|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3248|    124|}
fuzz_pkcs15init.c:sc_pkcs15init_update_lastupdate:
 3253|    707|{
 3254|    707|	struct sc_context *ctx = p15card->card->ctx;
 3255|    707|	int		r;
 3256|       |
 3257|    707|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    707|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3258|    707|	if (p15card->tokeninfo->last_update.path.len)    {
  ------------------
  |  Branch (3258:6): [True: 1, False: 706]
  ------------------
 3259|      1|		static const struct sc_asn1_entry c_asn1_last_update[2] = {
 3260|      1|		        { "generalizedTime",    SC_ASN1_GENERALIZEDTIME, SC_ASN1_TAG_GENERALIZEDTIME,   SC_ASN1_OPTIONAL, NULL, NULL },
  ------------------
  |  |  166|      1|#define SC_ASN1_GENERALIZEDTIME         24
  ------------------
              		        { "generalizedTime",    SC_ASN1_GENERALIZEDTIME, SC_ASN1_TAG_GENERALIZEDTIME,   SC_ASN1_OPTIONAL, NULL, NULL },
  ------------------
  |  |  215|      1|#define SC_ASN1_TAG_GENERALIZEDTIME	24
  ------------------
              		        { "generalizedTime",    SC_ASN1_GENERALIZEDTIME, SC_ASN1_TAG_GENERALIZEDTIME,   SC_ASN1_OPTIONAL, NULL, NULL },
  ------------------
  |  |  148|      1|#define SC_ASN1_OPTIONAL		0x00000002
  ------------------
 3261|      1|			{ NULL, 0, 0, 0, NULL, NULL }
 3262|      1|		};
 3263|      1|		struct sc_asn1_entry asn1_last_update[2];
 3264|      1|		size_t lupdate_len;
 3265|      1|		struct sc_file *file = NULL;
 3266|      1|		struct sc_pkcs15_last_update *last_update = &p15card->tokeninfo->last_update;
 3267|      1|		unsigned char *buf = NULL;
 3268|      1|		size_t buflen;
 3269|       |
 3270|       |		/* update 'lastUpdate' file */
 3271|      1|		if (last_update->gtime != NULL)
  ------------------
  |  Branch (3271:7): [True: 0, False: 1]
  ------------------
 3272|      0|			free(last_update->gtime);
 3273|      1|		r = sc_pkcs15_get_generalized_time(ctx, &last_update->gtime);
 3274|      1|		LOG_TEST_RET(ctx, r, "Cannot allocate generalized time string");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3275|       |
 3276|      1|		sc_copy_asn1_entry(c_asn1_last_update, asn1_last_update);
 3277|      1|		lupdate_len = strlen(last_update->gtime);
 3278|      1|		sc_format_asn1_entry(asn1_last_update + 0, last_update->gtime, &lupdate_len, 1);
 3279|       |
 3280|      1|		r = sc_asn1_encode(ctx, asn1_last_update, &buf, &buflen);
 3281|      1|		LOG_TEST_RET(ctx, r, "select object path 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3282|       |
 3283|      1|		r = sc_select_file(p15card->card, &last_update->path, &file);
 3284|      1|		if (r < 0)
  ------------------
  |  Branch (3284:7): [True: 1, False: 0]
  ------------------
 3285|      1|			free(buf);
 3286|      1|		LOG_TEST_RET(ctx, r, "select object path 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3287|       |
 3288|      0|		r = sc_pkcs15init_update_file(profile, p15card, file, buf, buflen);
 3289|      0|		sc_file_free(file);
 3290|      0|		if (buf)
  ------------------
  |  Branch (3290:7): [True: 0, False: 0]
  ------------------
 3291|      0|			free(buf);
 3292|      0|		LOG_TEST_RET(ctx, r, "Cannot update 'LastUpdate' 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3293|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3294|      0|	}
 3295|       |
 3296|    706|	r = sc_pkcs15init_update_tokeninfo(p15card, profile);
 3297|    706|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    706|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    706|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    706|	int _ret = r; \
  |  |  |  |  155|    706|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 706, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    706|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    128|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 128, False: 578]
  |  |  |  |  ------------------
  |  |  |  |  157|    706|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    706|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    706|	return _ret; \
  |  |  |  |  163|    706|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3298|    706|}
fuzz_pkcs15init.c:sc_pkcs15init_update_odf:
 3303|    844|{
 3304|    844|	struct sc_context	*ctx = p15card->card->ctx;
 3305|    844|	unsigned char	*buf = NULL;
 3306|    844|	size_t		size;
 3307|    844|	int		r;
 3308|       |
 3309|    844|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    844|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    844|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    844|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    844|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 844]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3310|    844|	r = sc_pkcs15_encode_odf(ctx, p15card, &buf, &size);
 3311|    844|	if (r >= 0)
  ------------------
  |  Branch (3311:6): [True: 843, False: 1]
  ------------------
 3312|    843|		r = sc_pkcs15init_update_file(profile, p15card, p15card->file_odf, buf, size);
 3313|    844|	if (buf)
  ------------------
  |  Branch (3313:6): [True: 843, False: 1]
  ------------------
 3314|    843|		free(buf);
 3315|    844|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    844|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    844|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    844|	int _ret = r; \
  |  |  |  |  155|    844|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 104, False: 740]
  |  |  |  |  ------------------
  |  |  |  |  156|    104|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    103|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 103, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|    104|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    740|	} else { \
  |  |  |  |  159|    740|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    740|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    740|	} \
  |  |  |  |  162|    844|	return _ret; \
  |  |  |  |  163|    844|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3316|    844|}
fuzz_pkcs15init.c:find_df_by_type:
 2829|  2.78k|{
 2830|  2.78k|	struct sc_pkcs15_df *df = p15card->df_list;
 2831|       |
 2832|  7.66k|	while (df != NULL && df->type != type)
  ------------------
  |  Branch (2832:9): [True: 6.09k, False: 1.56k]
  |  Branch (2832:23): [True: 4.87k, False: 1.21k]
  ------------------
 2833|  4.87k|		df = df->next;
 2834|  2.78k|	return df;
 2835|  2.78k|}
fuzz_pkcs15init.c:get_object_path_from_object:
 3050|  5.80k|{
 3051|  5.80k|	if (!ret_path)
  ------------------
  |  Branch (3051:6): [True: 0, False: 5.80k]
  ------------------
 3052|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 3053|       |
 3054|  5.80k|	memset(ret_path, 0, sizeof(struct sc_path));
 3055|       |
 3056|  5.80k|	switch(obj->type & SC_PKCS15_TYPE_CLASS_MASK)   {
  ------------------
  |  |  416|  5.80k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  |  Branch (3056:9): [True: 5.80k, False: 0]
  ------------------
 3057|  5.80k|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|  5.80k|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (3057:2): [True: 5.80k, False: 0]
  ------------------
 3058|  5.80k|		*ret_path = ((struct sc_pkcs15_prkey_info *)obj->data)->path;
 3059|  5.80k|		return SC_SUCCESS;
  ------------------
  |  |   28|  5.80k|#define SC_SUCCESS				0
  ------------------
 3060|      0|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|      0|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (3060:2): [True: 0, False: 5.80k]
  ------------------
 3061|      0|		*ret_path = ((struct sc_pkcs15_pubkey_info *)obj->data)->path;
 3062|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 3063|      0|	case SC_PKCS15_TYPE_SKEY:
  ------------------
  |  |  432|      0|#define SC_PKCS15_TYPE_SKEY			0x300
  ------------------
  |  Branch (3063:2): [True: 0, False: 5.80k]
  ------------------
 3064|      0|		*ret_path = ((struct sc_pkcs15_skey_info *)obj->data)->path;
 3065|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 3066|      0|	case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (3066:2): [True: 0, False: 5.80k]
  ------------------
 3067|      0|		*ret_path = ((struct sc_pkcs15_cert_info *)obj->data)->path;
 3068|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 3069|      0|	case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|      0|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (3069:2): [True: 0, False: 5.80k]
  ------------------
 3070|      0|		*ret_path = ((struct sc_pkcs15_data_info *)obj->data)->path;
 3071|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 3072|      0|	case SC_PKCS15_TYPE_AUTH:
  ------------------
  |  |  444|      0|#define SC_PKCS15_TYPE_AUTH			0x600
  ------------------
  |  Branch (3072:2): [True: 0, False: 5.80k]
  ------------------
 3073|      0|		*ret_path = ((struct sc_pkcs15_auth_info *)obj->data)->path;
 3074|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 3075|  5.80k|	}
 3076|      0|	return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 3077|  5.80k|}
fuzz_pkcs15init.c:select_object_path:
 3083|  19.4k|{
 3084|  19.4k|	struct sc_context *ctx = p15card->card->ctx;
 3085|  19.4k|	struct sc_file	*file;
 3086|  19.4k|	struct sc_pkcs15_object	*objs[32];
 3087|  19.4k|	struct sc_pkcs15_id index_id;
 3088|  19.4k|	struct sc_path obj_path;
 3089|  19.4k|	int ii, r, nn_objs, index;
 3090|  19.4k|	const char *name;
 3091|       |
 3092|  19.4k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  19.4k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  19.4k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  19.4k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  19.4k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 19.4k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3093|  19.4k|	r = sc_pkcs15_get_objects(p15card, obj->type & SC_PKCS15_TYPE_CLASS_MASK, objs, sizeof(objs)/sizeof(objs[0]));
  ------------------
  |  |  416|  19.4k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
 3094|  19.4k|	LOG_TEST_RET(ctx, r, "Get PKCS#15 objects error");
  ------------------
  |  |  174|  19.4k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  19.4k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  19.4k|	int _ret = (r); \
  |  |  |  |  168|  19.4k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 19.4k]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#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.4k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 19.4k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3095|  19.4k|	nn_objs = r;
 3096|       |
 3097|       |	/* For cards with a pin-domain profile, we need
 3098|       |	 * to put the key below the DF of the specified PIN
 3099|       |	 */
 3100|  19.4k|	memset(path, 0, sizeof(*path));
 3101|  19.4k|	if (obj->auth_id.len && profile->pin_domains != 0) {
  ------------------
  |  Branch (3101:6): [True: 16.2k, False: 3.19k]
  |  Branch (3101:26): [True: 53, False: 16.2k]
  ------------------
 3102|     53|		r = sc_pkcs15init_get_pin_path(p15card, &obj->auth_id, path);
 3103|     53|		LOG_TEST_RET(ctx, r, "Cannot get PIN path");
  ------------------
  |  |  174|     53|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     53|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     53|	int _ret = (r); \
  |  |  |  |  168|     53|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 28, False: 25]
  |  |  |  |  ------------------
  |  |  |  |  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|     53|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 25]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3104|     53|	}
 3105|  19.4k|	else {
 3106|  19.4k|		*path = profile->df_info->file->path;
 3107|  19.4k|	}
 3108|       |
 3109|       |	/* If the profile specifies a key directory template,
 3110|       |	 * instantiate it now and create the DF
 3111|       |	 */
 3112|  19.4k|	name = get_template_name_from_object (obj);
 3113|  19.4k|	if (!name)
  ------------------
  |  Branch (3113:6): [True: 0, False: 19.4k]
  ------------------
 3114|  19.4k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3115|       |
 3116|  19.4k|	sc_log(ctx, "key-domain.%s @%s (auth_id.len=%zu)", name, sc_print_path(path), obj->auth_id.len);
  ------------------
  |  |   71|  19.4k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3117|       |
 3118|  19.4k|	index_id.len = 1;
 3119|  25.0k|	for (index = TEMPLATE_INSTANTIATE_MIN_INDEX; index <= TEMPLATE_INSTANTIATE_MAX_INDEX; index++)   {
  ------------------
  |  |   85|  19.4k|#define TEMPLATE_INSTANTIATE_MIN_INDEX	0x0
  ------------------
              	for (index = TEMPLATE_INSTANTIATE_MIN_INDEX; index <= TEMPLATE_INSTANTIATE_MAX_INDEX; index++)   {
  ------------------
  |  |   86|  25.0k|#define TEMPLATE_INSTANTIATE_MAX_INDEX	0xFE
  ------------------
  |  Branch (3119:47): [True: 25.0k, False: 22]
  ------------------
 3120|  25.0k|		index_id.value[0] = index;
 3121|  25.0k|		r = sc_profile_instantiate_template(profile, "key-domain", path, name, &index_id, &file);
 3122|  25.0k|		if (r == SC_ERROR_TEMPLATE_NOT_FOUND)   {
  ------------------
  |  |  110|  25.0k|#define SC_ERROR_TEMPLATE_NOT_FOUND		-1508
  ------------------
  |  Branch (3122:7): [True: 23.3k, False: 1.65k]
  ------------------
 3123|       |			/* No template in 'key-domain' -- try to instantiate the template-'object name'
 3124|       |			 * outside of the 'key-domain' scope. */
 3125|  23.3k|			char t_name[0x40];
 3126|       |
 3127|  23.3k|			snprintf(t_name, sizeof(t_name), "template-%s", name);
 3128|  23.3k|			sc_log(ctx, "get instance %i of '%s'", index, t_name);
  ------------------
  |  |   71|  23.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__
  |  |  ------------------
  ------------------
 3129|  23.3k|			r = sc_profile_get_file_instance(profile, t_name, index, &file);
 3130|  23.3k|			if (r == SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|  23.3k|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (3130:8): [True: 17.3k, False: 6.07k]
  ------------------
 3131|  23.3k|				LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  17.3k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  17.3k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  17.3k|	int _ret = r; \
  |  |  |  |  155|  17.3k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 17.3k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  17.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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 17.3k]
  |  |  |  |  ------------------
  |  |  |  |  157|  17.3k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  17.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|  17.3k|	return _ret; \
  |  |  |  |  163|  17.3k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3132|  23.3k|		}
 3133|  7.73k|		LOG_TEST_RET(ctx, r, "Template instantiation error");
  ------------------
  |  |  174|  7.73k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  7.73k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  7.73k|	int _ret = (r); \
  |  |  |  |  168|  7.73k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 806, False: 6.92k]
  |  |  |  |  ------------------
  |  |  |  |  169|    806|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    806|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    806|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    806|		return _ret; \
  |  |  |  |  172|    806|	} \
  |  |  |  |  173|  7.73k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 6.92k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3134|       |
 3135|  6.92k|		if (file->type == SC_FILE_TYPE_BSO)
  ------------------
  |  |  217|  6.92k|#define SC_FILE_TYPE_BSO		0x10
  ------------------
  |  Branch (3135:7): [True: 17, False: 6.91k]
  ------------------
 3136|     17|			break;
 3137|       |
 3138|  6.91k|		sc_log(ctx, "instantiated template path %s", sc_print_path(&file->path));
  ------------------
  |  |   71|  6.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__
  |  |  ------------------
  ------------------
 3139|  6.91k|		for (ii=0; ii<nn_objs; ii++)   {
  ------------------
  |  Branch (3139:14): [True: 5.80k, False: 1.11k]
  ------------------
 3140|  5.80k|			r = get_object_path_from_object(objs[ii], &obj_path);
 3141|  5.80k|			LOG_TEST_RET(ctx, r, "Failed to get object path from pkcs15 object");
  ------------------
  |  |  174|  5.80k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  5.80k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  5.80k|	int _ret = (r); \
  |  |  |  |  168|  5.80k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 5.80k]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#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.80k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 5.80k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3142|       |
 3143|  5.80k|			if (obj_path.len != file->path.len)
  ------------------
  |  Branch (3143:8): [True: 189, False: 5.61k]
  ------------------
 3144|    189|				break;
 3145|       |
 3146|  5.61k|			if (!memcmp(obj_path.value, file->path.value, obj_path.len))
  ------------------
  |  Branch (3146:8): [True: 5.61k, False: 1]
  ------------------
 3147|  5.61k|				break;
 3148|  5.61k|		}
 3149|       |
 3150|  6.91k|		if (ii==nn_objs)
  ------------------
  |  Branch (3150:7): [True: 1.11k, False: 5.79k]
  ------------------
 3151|  1.11k|			break;
 3152|       |
 3153|  5.79k|		if (obj_path.len != file->path.len)
  ------------------
  |  Branch (3153:7): [True: 189, False: 5.61k]
  ------------------
 3154|    189|			break;
 3155|       |
 3156|  5.61k|		sc_file_free(file);
 3157|       |
 3158|  5.61k|		index_id.value[0] += 1;
 3159|  5.61k|	}
 3160|       |
 3161|  1.33k|	if (index > TEMPLATE_INSTANTIATE_MAX_INDEX)
  ------------------
  |  |   86|  1.33k|#define TEMPLATE_INSTANTIATE_MAX_INDEX	0xFE
  ------------------
  |  Branch (3161:6): [True: 22, False: 1.31k]
  ------------------
 3162|  1.33k|		LOG_TEST_RET(ctx, SC_ERROR_TOO_MANY_OBJECTS, "Template instantiation 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: 22, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|     22|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3163|       |
 3164|  1.31k|	*path = file->path;
 3165|  1.31k|	sc_file_free(file);
 3166|       |
 3167|  1.31k|	sc_log(ctx, "returns object path '%s'", sc_print_path(path));
  ------------------
  |  |   71|  1.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__
  |  |  ------------------
  ------------------
 3168|  1.31k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  1.31k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.31k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.31k|	int _ret = r; \
  |  |  |  |  155|  1.31k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.31k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.31k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 1.31k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.31k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.31k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|  1.31k|	return _ret; \
  |  |  |  |  163|  1.31k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3169|  1.31k|}
fuzz_pkcs15init.c:sc_pkcs15init_get_pin_path:
 4422|     53|{
 4423|     53|	struct sc_pkcs15_object *obj;
 4424|     53|	int	r;
 4425|       |
 4426|     53|	r = sc_pkcs15_find_pin_by_auth_id(p15card, auth_id, &obj);
 4427|     53|	if (r < 0)
  ------------------
  |  Branch (4427:6): [True: 28, False: 25]
  ------------------
 4428|     28|		return r;
 4429|     25|	*path = ((struct sc_pkcs15_auth_info *) obj->data)->path;
 4430|     25|	return SC_SUCCESS;
  ------------------
  |  |   28|     25|#define SC_SUCCESS				0
  ------------------
 4431|     53|}
fuzz_pkcs15init.c:get_template_name_from_object:
 3026|  19.4k|{
 3027|  19.4k|	switch (obj->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|  19.4k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  |  Branch (3027:10): [True: 19.4k, False: 0]
  ------------------
 3028|  4.35k|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|  4.35k|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (3028:2): [True: 4.35k, False: 15.1k]
  ------------------
 3029|  4.35k|		return "private-key";
 3030|      8|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|      8|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (3030:2): [True: 8, False: 19.4k]
  ------------------
 3031|      8|		return "public-key";
 3032|  11.9k|	case SC_PKCS15_TYPE_SKEY:
  ------------------
  |  |  432|  11.9k|#define SC_PKCS15_TYPE_SKEY			0x300
  ------------------
  |  Branch (3032:2): [True: 11.9k, False: 7.54k]
  ------------------
 3033|  11.9k|		return "secret-key";
 3034|      0|	case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (3034:2): [True: 0, False: 19.4k]
  ------------------
 3035|      0|		return "certificate";
 3036|  3.18k|	case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|  3.18k|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (3036:2): [True: 3.18k, False: 16.2k]
  ------------------
 3037|  3.18k|		if (obj->flags & SC_PKCS15_CO_FLAG_PRIVATE)
  ------------------
  |  |   50|  3.18k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  |  Branch (3037:7): [True: 0, False: 3.18k]
  ------------------
 3038|      0|			return "privdata";
 3039|  3.18k|		else
 3040|  3.18k|			return "data";
 3041|  19.4k|	}
 3042|       |
 3043|      0|	return NULL;
 3044|  19.4k|}
fuzz_pkcs15init.c:get_pin_ident_name:
 3820|    812|{
 3821|    812|	switch (type)   {
  ------------------
  |  Branch (3821:10): [True: 723, False: 89]
  ------------------
 3822|    526|	case SC_AC_CHV:
  ------------------
  |  |  151|    526|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (3822:2): [True: 526, False: 286]
  ------------------
 3823|    526|		return "PIN";
 3824|     33|	case SC_AC_PRO:
  ------------------
  |  |  153|     33|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  |  Branch (3824:2): [True: 33, False: 779]
  ------------------
 3825|     33|		return "secure messaging key";
 3826|     16|	case SC_AC_AUT:
  ------------------
  |  |  154|     16|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  |  Branch (3826:2): [True: 16, False: 796]
  ------------------
 3827|     16|		return "authentication key";
 3828|     13|	case SC_AC_SEN:
  ------------------
  |  |  156|     13|#define SC_AC_SEN                       0x00000020 /* Security Environment. */
  ------------------
  |  Branch (3828:2): [True: 13, False: 799]
  ------------------
 3829|     13|		return "security environment";
 3830|      3|	case SC_AC_IDA:
  ------------------
  |  |  158|      3|#define SC_AC_IDA                       0x00000080 /* PKCS#15 authentication ID */
  ------------------
  |  Branch (3830:2): [True: 3, False: 809]
  ------------------
 3831|      3|		return "PKCS#15 reference";
 3832|     40|	case SC_AC_SCB:
  ------------------
  |  |  157|     40|#define SC_AC_SCB                       0x00000040 /* IAS/ECC SCB byte. */
  ------------------
  |  Branch (3832:2): [True: 40, False: 772]
  ------------------
 3833|     40|		return "SCB byte in IAS/ECC";
 3834|     92|	case SC_AC_SYMBOLIC:
  ------------------
  |  |  155|     92|#define SC_AC_SYMBOLIC			0x00000010 /* internal use only */
  ------------------
  |  Branch (3834:2): [True: 92, False: 720]
  ------------------
 3835|     92|		switch (reference) {
  ------------------
  |  Branch (3835:11): [True: 78, False: 14]
  ------------------
 3836|     17|	        case SC_PKCS15INIT_USER_PIN:
  ------------------
  |  |  171|     17|#define SC_PKCS15INIT_USER_PIN		2
  ------------------
  |  Branch (3836:10): [True: 17, False: 75]
  ------------------
 3837|     17|			return "user PIN";
 3838|     24|		case SC_PKCS15INIT_SO_PIN:
  ------------------
  |  |  169|     24|#define SC_PKCS15INIT_SO_PIN		0
  ------------------
  |  Branch (3838:3): [True: 24, False: 68]
  ------------------
 3839|     24|			return "SO PIN";
 3840|     14|	        case SC_PKCS15INIT_USER_PUK:
  ------------------
  |  |  172|     14|#define SC_PKCS15INIT_USER_PUK		3
  ------------------
  |  Branch (3840:10): [True: 14, False: 78]
  ------------------
 3841|     14|			return "user PUK";
 3842|     23|		case SC_PKCS15INIT_SO_PUK:
  ------------------
  |  |  170|     23|#define SC_PKCS15INIT_SO_PUK		1
  ------------------
  |  Branch (3842:3): [True: 23, False: 69]
  ------------------
 3843|     23|			return "SO PUK";
 3844|     92|		}
 3845|    812|	}
 3846|    103|	return "authentication data";
 3847|    812|}
fuzz_pkcs15init.c:sc_pkcs15init_get_transport_key:
 3853|    120|{
 3854|    120|	struct sc_context *ctx = p15card->card->ctx;
 3855|    120|	struct sc_pkcs15_object *pin_obj = NULL;
 3856|    120|	struct sc_pkcs15_auth_info auth_info;
 3857|    120|	struct sc_cardctl_default_key data;
 3858|    120|	size_t		defsize = 0;
 3859|    120|	unsigned char	defbuf[0x100];
 3860|    120|	int rv;
 3861|       |
 3862|    120|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    120|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    120|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    120|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    120|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 120]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3863|       |
 3864|    120|	data.method = type;
 3865|    120|	data.key_ref = reference;
 3866|    120|	data.len = sizeof(defbuf);
 3867|    120|	data.key_data = defbuf;
 3868|    120|	rv = sc_card_ctl(p15card->card, SC_CARDCTL_GET_DEFAULT_KEY, &data);
 3869|    120|	if (rv >= 0)
  ------------------
  |  Branch (3869:6): [True: 14, False: 106]
  ------------------
 3870|     14|		defsize = data.len;
 3871|       |
 3872|    120|	if (callbacks.get_key)   {
  ------------------
  |  Branch (3872:6): [True: 0, False: 120]
  ------------------
 3873|      0|		rv = callbacks.get_key(profile, type, reference, defbuf, defsize, pinbuf, pinsize);
 3874|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3875|    120|	} else if (rv >= 0) {
  ------------------
  |  Branch (3875:13): [True: 14, False: 106]
  ------------------
 3876|     14|		if (*pinsize < defsize)
  ------------------
  |  Branch (3876:7): [True: 0, False: 14]
  ------------------
 3877|     14|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3878|       |
 3879|     14|		memcpy(pinbuf, data.key_data, data.len);
 3880|     14|		*pinsize = data.len;
 3881|    106|	} else {
 3882|       |		/* pinbuf and pinsize were not filled */
 3883|    106|		LOG_TEST_RET(ctx, SC_ERROR_INTERNAL, "Get transport key error");
  ------------------
  |  |  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: 106, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    106|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    106|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    106|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    106|		return _ret; \
  |  |  |  |  172|    106|	} \
  |  |  |  |  173|    106|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3884|    106|	}
 3885|       |
 3886|     14|	memset(&auth_info, 0, sizeof(auth_info));
 3887|     14|	auth_info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|     14|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
 3888|     14|	auth_info.auth_method = type;
 3889|     14|	auth_info.attrs.pin.reference = reference;
 3890|     14|	auth_info.attrs.pin.stored_length = *pinsize;
 3891|     14|	auth_info.attrs.pin.max_length = *pinsize;
 3892|     14|	auth_info.attrs.pin.min_length = *pinsize;
 3893|       |
 3894|     14|	pin_obj = sc_pkcs15init_new_object(SC_PKCS15_TYPE_AUTH_PIN, "Default transport key", NULL, &auth_info);
  ------------------
  |  |  445|     14|#define SC_PKCS15_TYPE_AUTH_PIN			0x601
  ------------------
 3895|     14|	if (!pin_obj)
  ------------------
  |  Branch (3895:6): [True: 0, False: 14]
  ------------------
 3896|     14|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3897|       |
 3898|     14|	rv = sc_pkcs15_add_object(p15card, pin_obj);
 3899|     14|	LOG_TEST_RET(ctx, rv, "Cannot add PKCS#15 AUTH object");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3900|       |
 3901|     14|	sc_pkcs15_pincache_add(p15card, pin_obj, pinbuf, *pinsize);
 3902|       |
 3903|     14|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|     14|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     14|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     14|	int _ret = r; \
  |  |  |  |  155|     14|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 14, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     14|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 14]
  |  |  |  |  ------------------
  |  |  |  |  157|     14|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     14|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     14|	return _ret; \
  |  |  |  |  163|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3904|     14|}
fuzz_pkcs15init.c:do_select_parent:
 4135|  3.54k|{
 4136|  3.54k|	struct sc_context *ctx = p15card->card->ctx;
 4137|  3.54k|	struct sc_path	path;
 4138|  3.54k|	int		r;
 4139|       |
 4140|  3.54k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  3.54k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.54k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.54k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.54k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.54k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4141|       |	/* Get the parent's path */
 4142|  3.54k|	path = file->path;
 4143|  3.54k|	if (path.len >= 2)
  ------------------
  |  Branch (4143:6): [True: 3.26k, False: 277]
  ------------------
 4144|  3.26k|		path.len -= 2;
 4145|  3.54k|	if (!path.len && !path.aid.len)
  ------------------
  |  Branch (4145:6): [True: 769, False: 2.77k]
  |  Branch (4145:19): [True: 726, False: 43]
  ------------------
 4146|    726|		sc_format_path("3F00", &path);
 4147|       |
 4148|       |	/* Select the parent DF. */
 4149|  3.54k|	*parent = NULL;
 4150|  3.54k|	r = sc_select_file(p15card->card, &path, parent);
 4151|       |	/* If DF doesn't exist, create it (unless it's the MF,
 4152|       |	 * but then something's badly broken anyway :-) */
 4153|  3.54k|	if (r == SC_ERROR_FILE_NOT_FOUND && path.len > 2) {
  ------------------
  |  |   51|  7.09k|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (4153:6): [True: 448, False: 3.09k]
  |  Branch (4153:38): [True: 371, False: 77]
  ------------------
 4154|    371|		r = sc_profile_get_file_by_path(profile, &path, parent);
 4155|    371|		if (r < 0) {
  ------------------
  |  Branch (4155:7): [True: 3, False: 368]
  ------------------
 4156|      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__
  |  |  ------------------
  ------------------
 4157|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4158|      3|		}
 4159|       |
 4160|    368|		r = sc_pkcs15init_create_file(profile, p15card, *parent);
 4161|    368|		if (r < 0) {
  ------------------
  |  Branch (4161:7): [True: 96, False: 272]
  ------------------
 4162|     96|			sc_file_free(*parent);
 4163|     96|			*parent = NULL;
 4164|     96|		}
 4165|    368|		LOG_TEST_RET(ctx, r, "Cannot create parent DF");
  ------------------
  |  |  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: 96, False: 272]
  |  |  |  |  ------------------
  |  |  |  |  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|    368|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 272]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4166|       |
 4167|    272|		r = sc_select_file(p15card->card, &path, NULL);
 4168|    272|		if (r < 0) {
  ------------------
  |  Branch (4168:7): [True: 62, False: 210]
  ------------------
 4169|     62|			sc_file_free(*parent);
 4170|     62|			*parent = NULL;
 4171|     62|		}
 4172|    272|		LOG_TEST_RET(ctx, r, "Cannot select parent DF");
  ------------------
  |  |  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: 62, False: 210]
  |  |  |  |  ------------------
  |  |  |  |  169|     62|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     62|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     62|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     62|		return _ret; \
  |  |  |  |  172|     62|	} \
  |  |  |  |  173|    272|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 210]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4173|    272|	}
 4174|  3.17k|	else if (r == SC_SUCCESS && !strcmp(p15card->card->name, "STARCOS")) {
  ------------------
  |  |   28|  6.34k|#define SC_SUCCESS				0
  ------------------
  |  Branch (4174:11): [True: 2.56k, False: 608]
  |  Branch (4174:30): [True: 0, False: 2.56k]
  ------------------
 4175|       |		/* in case of starcos spk 2.3 SELECT FILE does not
 4176|       |		 * give us the ACLs => ask the profile */
 4177|      0|		sc_file_free(*parent);
 4178|       |
 4179|      0|		r = sc_profile_get_file_by_path(profile, &path, parent);
 4180|      0|		if (r < 0) {
  ------------------
  |  Branch (4180:7): [True: 0, False: 0]
  ------------------
 4181|      0|			sc_log(ctx, "in StarCOS profile there is no template for DF %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__
  |  |  ------------------
  ------------------
 4182|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4183|      0|		}
 4184|      0|	}
 4185|       |
 4186|  3.38k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  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|    608|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 608, False: 2.77k]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4187|  3.38k|}
fuzz_pkcs15init.c:sc_pkcs15init_fixup_acls:
 4306|  1.12k|{
 4307|  1.12k|	struct sc_context *ctx = p15card->card->ctx;
 4308|  1.12k|	unsigned int	op;
 4309|  1.12k|	int		r = 0;
 4310|       |
 4311|  1.12k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  1.12k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.12k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.12k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.12k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.12k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4312|  34.4k|	for (op = 0; r == 0 && op < SC_MAX_AC_OPS; op++) {
  ------------------
  |  |  198|  34.4k|#define SC_MAX_AC_OPS			31
  ------------------
  |  Branch (4312:15): [True: 34.4k, False: 0]
  |  Branch (4312:25): [True: 33.4k, False: 1.07k]
  ------------------
 4313|  33.4k|		struct sc_acl_entry acls[SC_MAX_OP_ACS];
 4314|  33.4k|		const struct sc_acl_entry *acl;
 4315|  33.4k|		const char	*what;
 4316|  33.4k|		int		added = 0, num, ii;
 4317|       |
 4318|       |		/* First, get original ACLs */
 4319|  33.4k|		acl = sc_file_get_acl_entry(file, op);
 4320|  66.8k|		for (num = 0; num < SC_MAX_OP_ACS && acl; num++, acl = acl->next)
  ------------------
  |  |   89|   133k|#define SC_MAX_OP_ACS                   16
  ------------------
  |  Branch (4320:17): [True: 66.8k, False: 0]
  |  Branch (4320:40): [True: 33.4k, False: 33.4k]
  ------------------
 4321|  33.4k|			acls[num] = *acl;
 4322|       |
 4323|  33.4k|		sc_file_clear_acl_entries(file, op);
 4324|  66.7k|		for (ii = 0; ii < num; ii++) {
  ------------------
  |  Branch (4324:16): [True: 33.4k, False: 33.3k]
  ------------------
 4325|  33.4k|			acl = acls + ii;
 4326|  33.4k|			if (acl->method != SC_AC_SYMBOLIC)
  ------------------
  |  |  155|  33.4k|#define SC_AC_SYMBOLIC			0x00000010 /* internal use only */
  ------------------
  |  Branch (4326:8): [True: 30.5k, False: 2.84k]
  ------------------
 4327|  30.5k|				goto next;
 4328|       |
 4329|  2.84k|			if (acl->key_ref == SC_PKCS15INIT_SO_PIN) {
  ------------------
  |  |  169|  2.84k|#define SC_PKCS15INIT_SO_PIN		0
  ------------------
  |  Branch (4329:8): [True: 1.07k, False: 1.77k]
  ------------------
 4330|  1.07k|				acl = so_acl;
 4331|  1.07k|				what = "SO PIN";
 4332|  1.07k|			}
 4333|  1.77k|			else if (acl->key_ref == SC_PKCS15INIT_USER_PIN) {
  ------------------
  |  |  171|  1.77k|#define SC_PKCS15INIT_USER_PIN		2
  ------------------
  |  Branch (4333:13): [True: 1.73k, False: 49]
  ------------------
 4334|  1.73k|				acl = user_acl;
 4335|  1.73k|				what = "user PIN";
 4336|  1.73k|			}
 4337|     49|			else {
 4338|     49|				sc_log(ctx, "ACL references unknown symbolic PIN %d", acl->key_ref);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 4339|     49|				return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|     49|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 4340|     49|			}
 4341|       |
 4342|       |			/* If we weren't given a replacement ACL,
 4343|       |			 * leave the original ACL untouched */
 4344|  2.80k|			if (acl->key_ref == (unsigned int)-1) {
  ------------------
  |  Branch (4344:8): [True: 0, False: 2.80k]
  ------------------
 4345|      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__
  |  |  ------------------
  ------------------
 4346|      0|				return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 4347|      0|			}
 4348|       |
 4349|  2.80k|			if (acl->method == SC_AC_NONE)
  ------------------
  |  |  150|  2.80k|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (4349:8): [True: 674, False: 2.12k]
  ------------------
 4350|    674|				continue;
 4351|  32.6k|		next:
 4352|  32.6k|			sc_file_add_acl_entry(file, op, acl->method, acl->key_ref);
 4353|  32.6k|			added++;
 4354|  32.6k|		}
 4355|  33.3k|		if (!added)
  ------------------
  |  Branch (4355:7): [True: 673, False: 32.6k]
  ------------------
 4356|    673|			sc_file_add_acl_entry(file, op, SC_AC_NONE, 0);
  ------------------
  |  |  150|    673|#define SC_AC_NONE			0x00000000
  ------------------
 4357|  33.3k|	}
 4358|       |
 4359|  1.07k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  1.07k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.07k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.07k|	int _ret = r; \
  |  |  |  |  155|  1.07k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.07k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.07k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 1.07k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.07k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.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|  1.07k|	return _ret; \
  |  |  |  |  163|  1.07k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4360|  1.07k|}
fuzz_pkcs15init.c:sc_pkcs15init_qualify_pin:
 4488|  8.19k|{
 4489|  8.19k|	struct sc_context *ctx = card->ctx;
 4490|  8.19k|	struct sc_pkcs15_pin_attributes *pin_attrs;
 4491|       |
 4492|  8.19k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  8.19k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  8.19k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  8.19k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  8.19k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 8.19k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4493|  8.19k|	if (auth_info == NULL)
  ------------------
  |  Branch (4493:6): [True: 0, False: 8.19k]
  ------------------
 4494|  8.19k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4495|       |
 4496|  8.19k|	if (pin_len == 0 || auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|  8.11k|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (4496:6): [True: 73, False: 8.11k]
  |  Branch (4496:22): [True: 0, False: 8.11k]
  ------------------
 4497|  8.19k|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     73|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     73|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     73|	int _ret = r; \
  |  |  |  |  155|     73|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 73, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     73|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 73]
  |  |  |  |  ------------------
  |  |  |  |  157|     73|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     73|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     73|	return _ret; \
  |  |  |  |  163|     73|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4498|       |
 4499|  8.11k|	pin_attrs = &auth_info->attrs.pin;
 4500|       |
 4501|  8.11k|	if (pin_len < pin_attrs->min_length) {
  ------------------
  |  Branch (4501:6): [True: 19, False: 8.09k]
  ------------------
 4502|     19|		sc_log(ctx, "%s too short (min length %zu)", pin_name, pin_attrs->min_length);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 4503|     19|		LOG_FUNC_RETURN(ctx, SC_ERROR_WRONG_LENGTH);
  ------------------
  |  |  164|     19|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     19|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     19|	int _ret = r; \
  |  |  |  |  155|     19|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 19, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     19|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     19|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 19, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     19|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     19|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     19|	return _ret; \
  |  |  |  |  163|     19|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4504|     19|	}
 4505|  8.09k|	if (pin_len > pin_attrs->max_length) {
  ------------------
  |  Branch (4505:6): [True: 4.90k, False: 3.19k]
  ------------------
 4506|  4.90k|		sc_log(ctx, "%s too long (max length %zu)", pin_name, pin_attrs->max_length);
  ------------------
  |  |   71|  4.90k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4507|  4.90k|		LOG_FUNC_RETURN(ctx, SC_ERROR_WRONG_LENGTH);
  ------------------
  |  |  164|  4.90k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  4.90k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  4.90k|	int _ret = r; \
  |  |  |  |  155|  4.90k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4.90k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  4.90k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  4.90k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 4.90k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  4.90k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  4.90k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|  4.90k|	return _ret; \
  |  |  |  |  163|  4.90k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4508|  4.90k|	}
 4509|       |
 4510|  3.19k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  3.19k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.19k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.19k|	int _ret = r; \
  |  |  |  |  155|  3.19k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.19k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.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: 3.19k]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.19k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.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|  3.19k|	return _ret; \
  |  |  |  |  163|  3.19k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4511|  3.19k|}
fuzz_pkcs15init.c:sc_pkcs15init_read_info:
 4519|  12.2k|{
 4520|  12.2k|	struct sc_path	path;
 4521|  12.2k|	struct sc_file	*file = NULL;
 4522|  12.2k|	unsigned char	*mem = NULL;
 4523|  12.2k|	size_t		len = 0;
 4524|  12.2k|	int		r;
 4525|       |
 4526|  12.2k|	sc_format_path(OPENSC_INFO_FILEPATH, &path);
  ------------------
  |  |   71|  12.2k|#define OPENSC_INFO_FILEPATH		"3F0050154946"
  ------------------
 4527|  12.2k|	r = sc_select_file(card, &path, &file);
 4528|  12.2k|	if (r >= 0) {
  ------------------
  |  Branch (4528:6): [True: 996, False: 11.2k]
  ------------------
 4529|    996|		len = file->size;
 4530|    996|		sc_file_free(file);
 4531|    996|		if (len > MAX_FILE_SIZE)
  ------------------
  |  |  220|    996|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (4531:7): [True: 16, False: 980]
  ------------------
 4532|     16|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     16|#define SC_ERROR_INTERNAL			-1400
  ------------------
 4533|    980|		mem = malloc(len);
 4534|    980|		if (mem != NULL)
  ------------------
  |  Branch (4534:7): [True: 980, False: 0]
  ------------------
 4535|    980|			r = sc_read_binary(card, 0, mem, len, 0);
 4536|      0|		else
 4537|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 4538|    980|	}
 4539|  11.2k|	else   {
 4540|  11.2k|		r = 0;
 4541|  11.2k|		sc_file_free(file);
 4542|  11.2k|	}
 4543|       |
 4544|  12.2k|	if (r >= 0)
  ------------------
  |  Branch (4544:6): [True: 11.9k, False: 254]
  ------------------
 4545|  11.9k|		r = sc_pkcs15init_parse_info(card, mem, r, profile);
 4546|       |
 4547|  12.2k|	if (mem)
  ------------------
  |  Branch (4547:6): [True: 980, False: 11.2k]
  ------------------
 4548|    980|		free(mem);
 4549|  12.2k|	return r;
 4550|  12.2k|}
fuzz_pkcs15init.c:sc_pkcs15init_parse_info:
 4580|  11.9k|{
 4581|  11.9k|	unsigned char	tag;
 4582|  11.9k|	const unsigned char *end;
 4583|  11.9k|	unsigned int	nopts = 0;
 4584|  11.9k|	size_t		n;
 4585|  11.9k|	int	r = 0;
 4586|       |
 4587|  11.9k|	if ((p == NULL) || (len == 0))
  ------------------
  |  Branch (4587:6): [True: 11.2k, False: 726]
  |  Branch (4587:21): [True: 524, False: 202]
  ------------------
 4588|  11.7k|		return 0;
 4589|       |
 4590|    202|	end = p + (len - 1);
 4591|  4.24k|	while (p < end) {	/* more bytes to look at */
  ------------------
  |  Branch (4591:9): [True: 4.21k, False: 27]
  ------------------
 4592|  4.21k|		r = 0;
 4593|       |
 4594|  4.21k|		tag = *p; p++;
 4595|  4.21k|		if ((tag == 0) || (tag == 0xff) || (p >= end))
  ------------------
  |  Branch (4595:7): [True: 68, False: 4.14k]
  |  Branch (4595:21): [True: 16, False: 4.13k]
  |  Branch (4595:38): [True: 25, False: 4.10k]
  ------------------
 4596|    109|			break;
 4597|       |
 4598|  4.10k|		n = *p;
 4599|  4.10k|		p++;
 4600|       |
 4601|  4.10k|		if (p >= end || p + n > end) { /* invalid length byte n */
  ------------------
  |  Branch (4601:7): [True: 9, False: 4.09k]
  |  Branch (4601:19): [True: 56, False: 4.04k]
  ------------------
 4602|     65|			r = SC_ERROR_PKCS15INIT;
  ------------------
  |  |  102|     65|#define SC_ERROR_PKCS15INIT			-1500
  ------------------
 4603|     65|			goto error;
 4604|     65|		}
 4605|       |
 4606|  4.04k|		switch (tag) {
 4607|  3.46k|		case OPENSC_INFO_TAG_PROFILE:
  ------------------
  |  |   73|  3.46k|#define OPENSC_INFO_TAG_PROFILE		0x01
  ------------------
  |  Branch (4607:3): [True: 3.46k, False: 576]
  ------------------
 4608|  3.46k|			r = set_info_string(&profile->name, p, n);
 4609|  3.46k|			if (r < 0)
  ------------------
  |  Branch (4609:8): [True: 0, False: 3.46k]
  ------------------
 4610|      0|				goto error;
 4611|  3.46k|			break;
 4612|  3.46k|		case OPENSC_INFO_TAG_OPTION:
  ------------------
  |  |   74|    175|#define OPENSC_INFO_TAG_OPTION		0x02
  ------------------
  |  Branch (4612:3): [True: 175, False: 3.86k]
  ------------------
 4613|    175|			if (nopts >= SC_PKCS15INIT_MAX_OPTIONS - 1) {
  ------------------
  |  |   95|    175|#define SC_PKCS15INIT_MAX_OPTIONS 16
  ------------------
  |  Branch (4613:8): [True: 1, False: 174]
  ------------------
 4614|      1|				sc_log(card->ctx, "Too many options in OpenSC Info file");
  ------------------
  |  |   71|      1|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4615|      1|				r = SC_ERROR_PKCS15INIT;
  ------------------
  |  |  102|      1|#define SC_ERROR_PKCS15INIT			-1500
  ------------------
 4616|      1|				goto error;
 4617|      1|			}
 4618|    174|			r = set_info_string(&profile->options[nopts], p, n);
 4619|    174|			if (r < 0)
  ------------------
  |  Branch (4619:8): [True: 0, False: 174]
  ------------------
 4620|      0|				goto error;
 4621|    174|			profile->options[++nopts] = NULL;
 4622|    174|			break;
 4623|    401|		default:
  ------------------
  |  Branch (4623:3): [True: 401, False: 3.64k]
  ------------------
 4624|    401|			/* Unknown options ignored */ ;
 4625|  4.04k|		}
 4626|  4.04k|		p += n;
 4627|  4.04k|	}
 4628|    136|	return 0;
 4629|       |
 4630|     66|error:
 4631|     66|	sc_log(card->ctx, "OpenSC info file corrupted");
  ------------------
  |  |   71|     66|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4632|     66|	if (profile->name) {
  ------------------
  |  Branch (4632:6): [True: 66, False: 0]
  ------------------
 4633|     66|		free(profile->name);
 4634|     66|		profile->name = NULL;
 4635|     66|	}
 4636|    113|	for (size_t i = 0; i < nopts; i++) {
  ------------------
  |  Branch (4636:21): [True: 47, False: 66]
  ------------------
 4637|     47|		if (profile->options[i])
  ------------------
  |  Branch (4637:7): [True: 47, False: 0]
  ------------------
 4638|     47|			free(profile->options[i]);
 4639|       |		profile->options[i] = NULL;
 4640|     47|	}
 4641|     66|	return r;
 4642|    202|}
fuzz_pkcs15init.c:set_info_string:
 4555|  3.64k|{
 4556|  3.64k|	char	*s;
 4557|       |
 4558|  3.64k|	if (!(s = malloc(len+1)))
  ------------------
  |  Branch (4558:6): [True: 0, False: 3.64k]
  ------------------
 4559|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 4560|  3.64k|	memcpy(s, p, len);
 4561|  3.64k|	s[len] = '\0';
 4562|  3.64k|	if (*strp)
  ------------------
  |  Branch (4562:6): [True: 3.46k, False: 174]
  ------------------
 4563|  3.46k|		free(*strp);
 4564|  3.64k|	*strp = s;
 4565|  3.64k|	return SC_SUCCESS;
  ------------------
  |  |   28|  3.64k|#define SC_SUCCESS				0
  ------------------
 4566|  3.64k|}
fuzz_pkcs15init.c:sc_pkcs15init_write_info:
 4669|     75|{
 4670|     75|	struct sc_file	*file = NULL, *df = profile->df_info->file;
 4671|     75|	unsigned char	buffer[128], *p, *end;
 4672|     75|	unsigned int	method;
 4673|     75|	unsigned long	key_ref;
 4674|     75|	int		n, r;
 4675|       |
 4676|     75|	if (profile->ops->emu_write_info)
  ------------------
  |  Branch (4676:6): [True: 0, False: 75]
  ------------------
 4677|      0|		return profile->ops->emu_write_info(profile, p15card, pin_obj);
 4678|       |
 4679|     75|	memset(buffer, 0, sizeof(buffer));
 4680|       |
 4681|     75|	file = sc_file_new();
 4682|     75|	file->path.type = SC_PATH_TYPE_PATH;
  ------------------
  |  |  119|     75|#define SC_PATH_TYPE_PATH		2
  ------------------
 4683|     75|	memcpy(file->path.value, df->path.value, df->path.len);
 4684|     75|	file->path.len = df->path.len;
 4685|     75|	sc_append_file_id(&file->path, OPENSC_INFO_FILEID);
  ------------------
  |  |   72|     75|#define OPENSC_INFO_FILEID		0x4946
  ------------------
 4686|     75|	file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|     75|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
 4687|     75|	file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|     75|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
 4688|     75|	file->id = OPENSC_INFO_FILEID;
  ------------------
  |  |   72|     75|#define OPENSC_INFO_FILEID		0x4946
  ------------------
 4689|     75|	file->size = sizeof(buffer);
 4690|       |
 4691|     75|	if (pin_obj != NULL) {
  ------------------
  |  Branch (4691:6): [True: 75, False: 0]
  ------------------
 4692|     75|		method = SC_AC_CHV;
  ------------------
  |  |  151|     75|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 4693|     75|		key_ref = ((struct sc_pkcs15_auth_info *) pin_obj->data)->attrs.pin.reference;
 4694|     75|	}
 4695|      0|	else {
 4696|      0|		method = SC_AC_NONE; /* Unprotected */
  ------------------
  |  |  150|      0|#define SC_AC_NONE			0x00000000
  ------------------
 4697|      0|		key_ref = 0;
 4698|      0|	}
 4699|  2.40k|	for (n = 0; n < SC_MAX_AC_OPS; n++) {
  ------------------
  |  |  198|  2.40k|#define SC_MAX_AC_OPS			31
  ------------------
  |  Branch (4699:14): [True: 2.32k, False: 75]
  ------------------
 4700|  2.32k|		if (n == SC_AC_OP_READ)
  ------------------
  |  |  188|  2.32k|#define SC_AC_OP_READ			22
  ------------------
  |  Branch (4700:7): [True: 75, False: 2.25k]
  ------------------
 4701|     75|			sc_file_add_acl_entry(file, n, SC_AC_NONE, 0);
  ------------------
  |  |  150|     75|#define SC_AC_NONE			0x00000000
  ------------------
 4702|  2.25k|		else
 4703|  2.25k|			sc_file_add_acl_entry(file, n, method, key_ref);
 4704|  2.32k|	}
 4705|       |
 4706|     75|	p = buffer;
 4707|     75|	end = buffer + sizeof(buffer);
 4708|       |
 4709|     75|	r = do_encode_string(&p, end, OPENSC_INFO_TAG_PROFILE, profile->name);
  ------------------
  |  |   73|     75|#define OPENSC_INFO_TAG_PROFILE		0x01
  ------------------
 4710|     75|	for (n = 0; r >= 0 && profile->options[n]; n++)
  ------------------
  |  Branch (4710:14): [True: 75, False: 0]
  |  Branch (4710:24): [True: 0, False: 75]
  ------------------
 4711|      0|		r = do_encode_string(&p, end, OPENSC_INFO_TAG_OPTION, profile->options[n]);
  ------------------
  |  |   74|      0|#define OPENSC_INFO_TAG_OPTION		0x02
  ------------------
 4712|       |
 4713|     75|	if (r >= 0)
  ------------------
  |  Branch (4713:6): [True: 75, False: 0]
  ------------------
 4714|     75|		r = sc_pkcs15init_update_file(profile, p15card, file, buffer, (unsigned int)file->size);
 4715|       |
 4716|     75|	sc_file_free(file);
 4717|     75|	return r;
 4718|     75|}
fuzz_pkcs15init.c:do_encode_string:
 4648|     75|{
 4649|     75|	unsigned char	*p = *memp;
 4650|     75|	size_t	n;
 4651|       |
 4652|     75|	n = s ? strlen(s) : 0;
  ------------------
  |  Branch (4652:6): [True: 75, False: 0]
  ------------------
 4653|     75|	if (n > 255)
  ------------------
  |  Branch (4653:6): [True: 0, False: 75]
  ------------------
 4654|      0|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
 4655|     75|	if (p + 2 + n > end)
  ------------------
  |  Branch (4655:6): [True: 0, False: 75]
  ------------------
 4656|      0|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
 4657|     75|	*p++ = tag;
 4658|     75|	*p++ = n;
 4659|     75|	memcpy(p, s, n);
 4660|     75|	*memp = p + n;
 4661|     75|	return 0;
 4662|     75|}

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

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

cosm_delete_file:
  122|    343|{
  123|    343|	struct sc_context *ctx = p15card->card->ctx;
  124|    343|	struct sc_path  path;
  125|    343|	struct sc_file  *parent;
  126|    343|	int rv = 0;
  127|       |
  128|    343|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    343|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    343|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    343|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 343]
  |  |  ------------------
  ------------------
  129|    343|	sc_log(ctx,  "id %04X", df->id);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  130|    343|	if (df->type==SC_FILE_TYPE_DF)   {
  ------------------
  |  |  214|    343|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (130:6): [True: 290, False: 53]
  ------------------
  131|    290|		rv = sc_pkcs15init_authenticate(profile, p15card, df, SC_AC_OP_DELETE);
  ------------------
  |  |  168|    290|#define SC_AC_OP_DELETE			2
  ------------------
  132|    290|		LOG_TEST_RET(ctx, rv, "Cannot authenticate SC_AC_OP_DELETE");
  ------------------
  |  |  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: 199, False: 91]
  |  |  |  |  ------------------
  |  |  |  |  169|    199|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    199|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    199|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    199|		return _ret; \
  |  |  |  |  172|    199|	} \
  |  |  |  |  173|    290|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 91]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  133|    290|	}
  134|       |
  135|       |	/* Select the parent DF */
  136|    144|	path = df->path;
  137|    144|	if (path.len < 2) {
  ------------------
  |  Branch (137:6): [True: 2, False: 142]
  ------------------
  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|    142|	path.len -= 2;
  141|       |
  142|    142|	rv = sc_select_file(p15card->card, &path, &parent);
  143|    142|	LOG_TEST_RET(ctx, rv, "Cannot select parent");
  ------------------
  |  |  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: 79, False: 63]
  |  |  |  |  ------------------
  |  |  |  |  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|    142|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 63]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  144|       |
  145|     63|	rv = sc_pkcs15init_authenticate(profile, p15card, parent, SC_AC_OP_DELETE);
  ------------------
  |  |  168|     63|#define SC_AC_OP_DELETE			2
  ------------------
  146|     63|	sc_file_free(parent);
  147|     63|	LOG_TEST_RET(ctx, rv, "Cannot authenticate SC_AC_OP_DELETE");
  ------------------
  |  |  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: 3, False: 60]
  |  |  |  |  ------------------
  |  |  |  |  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|     63|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 60]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  148|       |
  149|     60|	memset(&path, 0, sizeof(path));
  150|     60|	path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|     60|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  151|     60|	path.value[0] = df->id >> 8;
  152|     60|	path.value[1] = df->id & 0xFF;
  153|     60|	path.len = 2;
  154|       |
  155|     60|	rv = sc_delete_file(p15card->card, &path);
  156|       |
  157|     60|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|     60|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     60|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     60|	int _ret = r; \
  |  |  |  |  155|     60|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 60, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     60|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     28|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 28, False: 32]
  |  |  |  |  ------------------
  |  |  |  |  157|     60|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     60|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     60|	return _ret; \
  |  |  |  |  163|     60|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  158|     60|}
sc_pkcs15init_get_oberthur_ops:
  936|    806|{
  937|    806|	return &sc_pkcs15init_oberthur_operations;
  938|    806|}
pkcs15-oberthur.c:cosm_erase_card:
  166|    303|{
  167|    303|	struct sc_context *ctx = p15card->card->ctx;
  168|    303|	struct sc_file  *df = profile->df_info->file, *dir;
  169|    303|	int rv;
  170|       |
  171|    303|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    303|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    303|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    303|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 303]
  |  |  ------------------
  ------------------
  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|    303|	if (sc_profile_get_file(profile, "DIR", &dir) >= 0) {
  ------------------
  |  Branch (178:6): [True: 25, False: 278]
  ------------------
  179|     25|		sc_log(ctx,  "erase file dir %04X",dir->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__
  |  |  ------------------
  ------------------
  180|     25|		rv = cosm_delete_file(p15card, profile, dir);
  181|     25|		sc_file_free(dir);
  182|     25|		if (rv < 0 && rv != SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|     18|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (182:7): [True: 18, False: 7]
  |  Branch (182:17): [True: 16, False: 2]
  ------------------
  183|     16|			goto done;
  184|     25|	}
  185|       |
  186|    287|	sc_log(ctx,  "erase file ddf %04X",df->id);
  ------------------
  |  |   71|    287|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  187|    287|	rv = cosm_delete_file(p15card, profile, df);
  188|    287|	if (rv < 0 && rv != SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|    284|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (188:6): [True: 284, False: 3]
  |  Branch (188:16): [True: 282, False: 2]
  ------------------
  189|    282|		goto done;
  190|       |
  191|      5|	if (sc_profile_get_file(profile, "private-DF", &dir) >= 0) {
  ------------------
  |  Branch (191:6): [True: 0, False: 5]
  ------------------
  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|      5|	if (sc_profile_get_file(profile, "public-DF", &dir) >= 0) {
  ------------------
  |  Branch (199:6): [True: 0, False: 5]
  ------------------
  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|      5|	rv = sc_profile_get_file(profile, COSM_TITLE"-AppDF", &dir);
  ------------------
  |  |   33|      5|#define COSM_TITLE "OberthurAWP"
  ------------------
  208|      5|	if (!rv) {
  ------------------
  |  Branch (208:6): [True: 0, False: 5]
  ------------------
  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|      5|	sc_free_apps(p15card->card);
  215|    303|done:
  216|    303|	if (rv == SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|    303|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (216:6): [True: 5, False: 298]
  ------------------
  217|      5|		rv = 0;
  218|       |
  219|    303|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    303|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    303|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    303|	int _ret = r; \
  |  |  |  |  155|    303|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 303, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    303|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    298|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 298, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  157|    303|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    303|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    303|	return _ret; \
  |  |  |  |  163|    303|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  220|    303|}
pkcs15-oberthur.c:cosm_create_dir:
  226|     20|{
  227|     20|	struct sc_context *ctx = p15card->card->ctx;
  228|     20|	struct sc_file *file = NULL;
  229|     20|	size_t ii;
  230|     20|	int rv;
  231|     20|	static const char *create_dfs[] = {
  232|     20|		COSM_TITLE"-AppDF",
  ------------------
  |  |   33|     20|#define COSM_TITLE "OberthurAWP"
  ------------------
  233|     20|		"private-DF",
  234|     20|		"public-DF",
  235|     20|		COSM_TITLE"-token-info",
  ------------------
  |  |   33|     20|#define COSM_TITLE "OberthurAWP"
  ------------------
  236|     20|		COSM_TITLE"-puk-file",
  ------------------
  |  |   33|     20|#define COSM_TITLE "OberthurAWP"
  ------------------
  237|     20|		COSM_TITLE"-container-list",
  ------------------
  |  |   33|     20|#define COSM_TITLE "OberthurAWP"
  ------------------
  238|     20|		COSM_TITLE"-public-list",
  ------------------
  |  |   33|     20|#define COSM_TITLE "OberthurAWP"
  ------------------
  239|     20|		COSM_TITLE"-private-list",
  ------------------
  |  |   33|     20|#define COSM_TITLE "OberthurAWP"
  ------------------
  240|     20|		NULL
  241|     20|	};
  242|       |
  243|     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]
  |  |  ------------------
  ------------------
  244|       |
  245|       |	/* Oberthur AWP file system is expected.*/
  246|       |	/* Create private objects DF */
  247|     22|	for (ii = 0; create_dfs[ii]; ii++)   {
  ------------------
  |  Branch (247:15): [True: 22, False: 0]
  ------------------
  248|     22|		if (sc_profile_get_file(profile, create_dfs[ii], &file))   {
  ------------------
  |  Branch (248:7): [True: 2, False: 20]
  ------------------
  249|      2|			sc_log(ctx,  "Inconsistent profile: cannot find %s", create_dfs[ii]);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  250|      2|			LOG_TEST_RET(ctx, SC_ERROR_INCONSISTENT_PROFILE, "Profile do not contains Oberthur AWP 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  251|      2|		}
  252|       |
  253|     20|		rv = sc_pkcs15init_create_file(profile, p15card, file);
  254|     20|		sc_file_free(file);
  255|     20|		if (rv != SC_ERROR_FILE_ALREADY_EXISTS)
  ------------------
  |  |   65|     20|#define SC_ERROR_FILE_ALREADY_EXISTS		-1215
  ------------------
  |  Branch (255:7): [True: 19, False: 1]
  ------------------
  256|     20|			LOG_TEST_RET(ctx, rv, "Failed to create Oberthur AWP file");
  ------------------
  |  |  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: 18, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  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|     19|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  257|     20|	}
  258|       |
  259|      0|	rv = cosm_write_tokeninfo(p15card, profile, NULL,
  260|      0|		COSM_TOKEN_FLAG_TOKEN_INITIALIZED | COSM_TOKEN_FLAG_PRN_GENERATION);
  ------------------
  |  |   48|      0|#define COSM_TOKEN_FLAG_TOKEN_INITIALIZED	0x0400
  ------------------
              		COSM_TOKEN_FLAG_TOKEN_INITIALIZED | COSM_TOKEN_FLAG_PRN_GENERATION);
  ------------------
  |  |   45|      0|#define COSM_TOKEN_FLAG_PRN_GENERATION		0x01
  ------------------
  261|       |
  262|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  263|      0|}
pkcs15-oberthur.c:cosm_select_pin_reference:
  377|    348|{
  378|    348|	struct sc_context *ctx = p15card->card->ctx;
  379|    348|	struct sc_pkcs15_pin_attributes *pin_attrs;
  380|    348|	struct sc_file *pinfile;
  381|       |
  382|    348|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    348|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    348|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    348|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 348]
  |  |  ------------------
  ------------------
  383|    348|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|    348|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (383:6): [True: 0, False: 348]
  ------------------
  384|      0|		return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  385|       |
  386|    348|	pin_attrs = &auth_info->attrs.pin;
  387|       |
  388|    348|	sc_log(ctx,  "ref %i; flags %X", pin_attrs->reference, pin_attrs->flags);
  ------------------
  |  |   71|    348|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  389|    348|	if (sc_profile_get_file(profile, COSM_TITLE "-AppDF", &pinfile) < 0) {
  ------------------
  |  |   33|    348|#define COSM_TITLE "OberthurAWP"
  ------------------
  |  Branch (389:6): [True: 300, False: 48]
  ------------------
  390|    300|		sc_log(ctx,  "Profile doesn't define \"%s\"", COSM_TITLE "-AppDF");
  ------------------
  |  |   71|    300|#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)
  |  |  ------------------
  |  |  |  |  390|    300|		sc_log(ctx,  "Profile doesn't define \"%s\"", COSM_TITLE "-AppDF");
  |  |  |  |  ------------------
  |  |  |  |  |  |   33|    300|#define COSM_TITLE "OberthurAWP"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  391|    300|		return SC_ERROR_INCONSISTENT_PROFILE;
  ------------------
  |  |  104|    300|#define SC_ERROR_INCONSISTENT_PROFILE		-1502
  ------------------
  392|    300|	}
  393|       |
  394|     48|	if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_LOCAL)
  ------------------
  |  |   55|     48|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
  |  Branch (394:6): [True: 27, False: 21]
  ------------------
  395|     27|		auth_info->path = pinfile->path;
  396|       |
  397|     48|	sc_file_free(pinfile);
  398|       |
  399|     48|	if (pin_attrs->reference <= 0)   {
  ------------------
  |  Branch (399:6): [True: 46, False: 2]
  ------------------
  400|     46|		if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_SO_PIN)
  ------------------
  |  |   61|     46|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (400:7): [True: 7, False: 39]
  ------------------
  401|      7|			pin_attrs->reference = 4;
  402|     39|		else if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN)
  ------------------
  |  |   60|     39|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  ------------------
  |  Branch (402:12): [True: 6, False: 33]
  ------------------
  403|      6|			pin_attrs->reference = 4;
  404|     33|		else
  405|     33|			pin_attrs->reference = 1;
  406|       |
  407|     46|		if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_LOCAL)
  ------------------
  |  |   55|     46|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
  |  Branch (407:7): [True: 27, False: 19]
  ------------------
  408|     27|			pin_attrs->reference |= 0x80;
  409|     46|	}
  410|       |
  411|     48|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     48|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     48|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     48|	int _ret = r; \
  |  |  |  |  155|     48|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 48, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     48|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 48]
  |  |  |  |  ------------------
  |  |  |  |  157|     48|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     48|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     48|	return _ret; \
  |  |  |  |  163|     48|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  412|     48|}
pkcs15-oberthur.c:cosm_create_pin:
  423|     14|{
  424|     14|	struct sc_context *ctx = p15card->card->ctx;
  425|     14|	struct sc_pkcs15_auth_info *auth_info = (struct sc_pkcs15_auth_info *) pin_obj->data;
  426|     14|	struct sc_pkcs15_pin_attributes *pin_attrs;
  427|     14|	struct sc_file *pin_file;
  428|     14|	int rv = 0;
  429|       |
  430|     14|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     14|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     14|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     14|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 14]
  |  |  ------------------
  ------------------
  431|     14|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|     14|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (431:6): [True: 0, False: 14]
  ------------------
  432|      0|		return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  433|       |
  434|     14|	pin_attrs = &auth_info->attrs.pin;
  435|       |
  436|     14|	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|     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__
  |  |  ------------------
  ------------------
  437|     14|	if (sc_profile_get_file(profile, COSM_TITLE "-AppDF", &pin_file) < 0)
  ------------------
  |  |   33|     14|#define COSM_TITLE "OberthurAWP"
  ------------------
  |  Branch (437:6): [True: 0, False: 14]
  ------------------
  438|     14|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  439|       |
  440|     14|	if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_LOCAL)
  ------------------
  |  |   55|     14|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
  |  Branch (440:6): [True: 7, False: 7]
  ------------------
  441|      7|		auth_info->path = pin_file->path;
  442|       |
  443|     14|	sc_file_free(pin_file);
  444|       |
  445|     14|	if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_SO_PIN)   {
  ------------------
  |  |   61|     14|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (445:6): [True: 5, False: 9]
  ------------------
  446|      5|		if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN)   {
  ------------------
  |  |   60|      5|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  ------------------
  |  Branch (446:7): [True: 2, False: 3]
  ------------------
  447|      2|			LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "SOPIN unblocking is not supported");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  448|      2|		}
  449|      3|		else   {
  450|      3|			if (pin_attrs->reference != 4)
  ------------------
  |  Branch (450:8): [True: 2, False: 1]
  ------------------
  451|      3|				LOG_TEST_RET(ctx, SC_ERROR_INVALID_PIN_REFERENCE, "Invalid SOPIN 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  452|      3|		}
  453|      5|	}
  454|      9|	else {
  455|      9|		if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN)   {
  ------------------
  |  |   60|      9|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  ------------------
  |  Branch (455:7): [True: 3, False: 6]
  ------------------
  456|      3|			if (pin_attrs->reference != 0x84)
  ------------------
  |  Branch (456:8): [True: 2, False: 1]
  ------------------
  457|      3|				LOG_TEST_RET(ctx, SC_ERROR_INVALID_PIN_REFERENCE, "Invalid User PUK 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  458|      3|		}
  459|      6|		else   {
  460|      6|			if (pin_attrs->reference != 0x81)
  ------------------
  |  Branch (460:8): [True: 2, False: 4]
  ------------------
  461|      6|				LOG_TEST_RET(ctx, SC_ERROR_INVALID_PIN_REFERENCE, "Invalid User PIN 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  462|      6|		}
  463|      9|	}
  464|       |
  465|      6|	if (pin && pin_len)   {
  ------------------
  |  Branch (465:6): [True: 6, False: 0]
  |  Branch (465:13): [True: 6, False: 0]
  ------------------
  466|      6|		rv = cosm_update_pin(profile, p15card, auth_info, pin, pin_len,  puk, puk_len);
  467|      6|		LOG_TEST_RET(ctx, rv, "Update 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: 5, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  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|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  468|      6|	}
  469|       |
  470|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  471|      1|}
pkcs15-oberthur.c:cosm_update_pin:
  342|      6|{
  343|      6|	struct sc_context *ctx = p15card->card->ctx;
  344|      6|	int rv;
  345|       |
  346|      6|	SC_FUNC_CALLED(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]
  |  |  ------------------
  ------------------
  347|      6|	if (ainfo->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|      6|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (347:6): [True: 0, False: 6]
  ------------------
  348|      0|		return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  349|       |
  350|      6|	sc_log(ctx,  "ref %i; flags 0x%X", ainfo->attrs.pin.reference, ainfo->attrs.pin.flags);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  351|       |
  352|      6|	if (ainfo->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN)   {
  ------------------
  |  |   61|      6|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (352:6): [True: 1, False: 5]
  ------------------
  353|      1|		if (ainfo->attrs.pin.reference != 4)
  ------------------
  |  Branch (353:7): [True: 0, False: 1]
  ------------------
  354|      1|			LOG_TEST_RET(ctx, SC_ERROR_INVALID_PIN_REFERENCE, "cosm_update_pin() 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  355|      1|		sc_log(ctx,  "Update SOPIN ignored");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  356|      1|		rv = SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
  357|      1|	}
  358|      5|	else   {
  359|      5|		rv = cosm_create_reference_data(profile, p15card, ainfo, pin, pin_len, puk, puk_len);
  360|      5|		LOG_TEST_RET(ctx, rv, "cosm_update_pin() failed to change PIN");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  361|       |
  362|      0|		rv = cosm_write_tokeninfo(p15card, profile, NULL,
  363|      0|			COSM_TOKEN_FLAG_TOKEN_INITIALIZED
  ------------------
  |  |   48|      0|#define COSM_TOKEN_FLAG_TOKEN_INITIALIZED	0x0400
  ------------------
  364|      0|			| COSM_TOKEN_FLAG_PRN_GENERATION
  ------------------
  |  |   45|      0|#define COSM_TOKEN_FLAG_PRN_GENERATION		0x01
  ------------------
  365|      0|			| COSM_TOKEN_FLAG_LOGIN_REQUIRED
  ------------------
  |  |   46|      0|#define COSM_TOKEN_FLAG_LOGIN_REQUIRED		0x04
  ------------------
  366|      0|			| COSM_TOKEN_FLAG_USER_PIN_INITIALIZED);
  ------------------
  |  |   47|      0|#define COSM_TOKEN_FLAG_USER_PIN_INITIALIZED	0x08
  ------------------
  367|      0|		LOG_TEST_RET(ctx, rv, "cosm_update_pin() failed to update 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  368|      0|	}
  369|       |
  370|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  371|      1|}
pkcs15-oberthur.c:cosm_create_reference_data:
  271|      5|{
  272|      5|	struct sc_context *ctx = p15card->card->ctx;
  273|      5|	struct sc_card *card = p15card->card;
  274|      5|	struct sc_pkcs15_auth_info profile_auth_pin = {0}, profile_auth_puk = {0};
  275|      5|	struct sc_cardctl_oberthur_createpin_info args;
  276|      5|	int rv;
  277|      5|	unsigned char oberthur_puk[16] = {
  278|      5|		0x6F, 0x47, 0xD9, 0x88, 0x4B, 0x6F, 0x9D, 0xC5,
  279|      5|		0x78, 0x33, 0x79, 0x8F, 0x5B, 0x7D, 0xE1, 0xA5
  280|      5|	};
  281|       |
  282|      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]
  |  |  ------------------
  ------------------
  283|      5|	sc_log(ctx, "pin lens %zu/%zu", pin_len, puk_len);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  284|      5|	if (!pin || pin_len>0x40)
  ------------------
  |  Branch (284:6): [True: 0, False: 5]
  |  Branch (284:14): [True: 0, False: 5]
  ------------------
  285|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  286|      5|	if (puk && !puk_len)
  ------------------
  |  Branch (286:6): [True: 5, False: 0]
  |  Branch (286:13): [True: 0, False: 5]
  ------------------
  287|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  288|      5|	if (ainfo->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|      5|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (288:6): [True: 0, False: 5]
  ------------------
  289|      0|		return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  290|       |
  291|      5|	rv = sc_select_file(card, &ainfo->path, NULL);
  292|      5|	LOG_TEST_RET(ctx, rv, "Cannot select file");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  293|       |
  294|      3|	sc_profile_get_pin_info(profile, SC_PKCS15INIT_USER_PIN, &profile_auth_pin);
  ------------------
  |  |  171|      3|#define SC_PKCS15INIT_USER_PIN		2
  ------------------
  295|      3|	sc_profile_get_pin_info(profile, SC_PKCS15INIT_USER_PUK, &profile_auth_puk);
  ------------------
  |  |  172|      3|#define SC_PKCS15INIT_USER_PUK		3
  ------------------
  296|       |
  297|      3|	memset(&args, 0, sizeof(args));
  298|      3|	args.type = SC_AC_CHV;
  ------------------
  |  |  151|      3|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  299|      3|	args.ref = ainfo->attrs.pin.reference;
  300|      3|	args.pin = pin;
  301|      3|	args.pin_len = pin_len;
  302|       |
  303|      3|	if (!(ainfo->attrs.pin.flags & SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN))   {
  ------------------
  |  |   60|      3|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  ------------------
  |  Branch (303:6): [True: 3, False: 0]
  ------------------
  304|      3|		args.pin_tries = profile_auth_pin.tries_left;
  305|      3|		if (profile_auth_puk.tries_left > 0)   {
  ------------------
  |  Branch (305:7): [True: 3, False: 0]
  ------------------
  306|      3|			args.puk = oberthur_puk;
  307|      3|			args.puk_len = sizeof(oberthur_puk);
  308|      3|			args.puk_tries = 5;
  309|      3|		}
  310|      3|	}
  311|      0|	else   {
  312|      0|		args.pin_tries = profile_auth_puk.tries_left;
  313|      0|	}
  314|       |
  315|      3|	rv = sc_card_ctl(card, SC_CARDCTL_OBERTHUR_CREATE_PIN, &args);
  316|      3|	LOG_TEST_RET(ctx, rv, "'CREATE_PIN' card specific command 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  317|       |
  318|      1|	if (!(ainfo->attrs.pin.flags & SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN)
  ------------------
  |  |   60|      1|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  ------------------
  |  Branch (318:6): [True: 1, False: 0]
  ------------------
  319|      1|			&& (profile_auth_puk.tries_left > 0))   {
  ------------------
  |  Branch (319:7): [True: 1, False: 0]
  ------------------
  320|      1|	        struct sc_file *file = NULL;
  321|       |
  322|      1|		if (sc_profile_get_file(profile, COSM_TITLE"-puk-file", &file))
  ------------------
  |  |   33|      1|#define COSM_TITLE "OberthurAWP"
  ------------------
  |  Branch (322:7): [True: 1, False: 0]
  ------------------
  323|      1|			LOG_TEST_RET(ctx, SC_ERROR_INCONSISTENT_PROFILE, "Cannot find PUKFILE");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  324|       |
  325|      0|		rv = sc_pkcs15init_update_file(profile, p15card, file, oberthur_puk, sizeof(oberthur_puk));
  326|      0|		LOG_TEST_RET(ctx, rv, "Failed to update pukfile");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      0|	int _ret = (r); \
  |  |  |  |  168|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  327|       |
  328|      0|		sc_file_free(file);
  329|      0|	}
  330|       |
  331|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  332|      0|}
pkcs15-oberthur.c:cosm_create_key:
  717|  1.20k|{
  718|  1.20k|	struct sc_context *ctx = p15card->card->ctx;
  719|  1.20k|	struct sc_pkcs15_prkey_info *key_info = (struct sc_pkcs15_prkey_info *)object->data;
  720|  1.20k|	struct sc_file *file = NULL;
  721|  1.20k|	int rv = 0;
  722|       |
  723|  1.20k|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  1.20k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  1.20k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  1.20k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 1.20k]
  |  |  ------------------
  ------------------
  724|  1.20k|	if (object->type != SC_PKCS15_TYPE_PRKEY_RSA)
  ------------------
  |  |  419|  1.20k|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (724:6): [True: 900, False: 300]
  ------------------
  725|  1.20k|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Create key failed: RSA only supported");
  ------------------
  |  |  174|    900|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    900|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    900|	int _ret = (r); \
  |  |  |  |  168|    900|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 900, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    900|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    900|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    900|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    900|		return _ret; \
  |  |  |  |  172|    900|	} \
  |  |  |  |  173|    900|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  726|       |
  727|    300|	if (key_info->path.len < 2) {
  ------------------
  |  Branch (727:6): [True: 137, False: 163]
  ------------------
  728|    137|		LOG_TEST_RET(ctx, SC_ERROR_OBJECT_NOT_VALID,
  ------------------
  |  |  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: 137, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|    137|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  729|    137|				"The path needs to be at least two bytes long");
  730|    137|	}
  731|       |
  732|    163|	sc_log(ctx,  "create private key ID:%s",  sc_pkcs15_print_id(&key_info->id));
  ------------------
  |  |   71|    163|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  733|       |	/* Here, the path of private key file should be defined.
  734|       |	 * Nevertheless, we need to instantiate private key to get the ACLs. */
  735|    163|	rv = cosm_new_file(profile, p15card->card, SC_PKCS15_TYPE_PRKEY_RSA, key_info->key_reference, &file);
  ------------------
  |  |  419|    163|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  736|    163|	LOG_TEST_RET(ctx, rv, "Cannot create key: failed to allocate new key object");
  ------------------
  |  |  174|    163|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    163|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    163|	int _ret = (r); \
  |  |  |  |  168|    163|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 100, False: 63]
  |  |  |  |  ------------------
  |  |  |  |  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|    163|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 63]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  737|       |
  738|     63|	file->size = key_info->modulus_length;
  739|     63|	memcpy(&file->path, &key_info->path, sizeof(file->path));
  740|     63|	file->id = file->path.value[file->path.len - 2] * 0x100
  741|     63|				+ file->path.value[file->path.len - 1];
  742|       |
  743|     63|	sc_log(ctx,  "Path of private key file to create %s", sc_print_path(&file->path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  744|       |
  745|     63|	rv = sc_select_file(p15card->card, &file->path, NULL);
  746|     63|	if (rv == 0)   {
  ------------------
  |  Branch (746:6): [True: 31, False: 32]
  ------------------
  747|     31|		rv = cosm_delete_file(p15card, profile, file);
  748|     31|		SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_VERBOSE, rv, "Failed to delete private key file");
  ------------------
  |  |  176|     31|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  177|     31|	int _ret = (r); \
  |  |  178|     31|	if (_ret < 0) { \
  |  |  ------------------
  |  |  |  Branch (178:6): [True: 9, False: 22]
  |  |  ------------------
  |  |  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|     31|} while(0)
  |  |  ------------------
  |  |  |  Branch (183:9): [Folded, False: 22]
  |  |  ------------------
  ------------------
  749|     31|	}
  750|     32|	else if (rv != SC_ERROR_FILE_NOT_FOUND)    {
  ------------------
  |  |   51|     32|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (750:11): [True: 22, False: 10]
  ------------------
  751|     22|		SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_VERBOSE, rv, "Select private key file error");
  ------------------
  |  |  176|     22|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  177|     22|	int _ret = (r); \
  |  |  178|     22|	if (_ret < 0) { \
  |  |  ------------------
  |  |  |  Branch (178:6): [True: 22, False: 0]
  |  |  ------------------
  |  |  179|     22|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  ------------------
  |  |  |  |   44|     22|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  180|     22|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  181|     22|		goto err; \
  |  |  182|     22|	} \
  |  |  183|     22|} while(0)
  |  |  ------------------
  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  752|     22|	}
  753|       |
  754|     32|	rv = sc_pkcs15init_create_file(profile, p15card, file);
  755|     32|	SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_VERBOSE, rv, "Failed to create private key file");
  ------------------
  |  |  176|     32|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  177|     32|	int _ret = (r); \
  |  |  178|     32|	if (_ret < 0) { \
  |  |  ------------------
  |  |  |  Branch (178:6): [True: 23, False: 9]
  |  |  ------------------
  |  |  179|     23|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  ------------------
  |  |  |  |   44|     23|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  180|     23|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  181|     23|		goto err; \
  |  |  182|     23|	} \
  |  |  183|     32|} while(0)
  |  |  ------------------
  |  |  |  Branch (183:9): [Folded, False: 9]
  |  |  ------------------
  ------------------
  756|       |
  757|      9|	key_info->key_reference = file->path.value[file->path.len - 1];
  758|       |
  759|     63|err:
  760|     63|	sc_file_free(file);
  761|       |
  762|     63|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|     63|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     63|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     63|	int _ret = r; \
  |  |  |  |  155|     63|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 63, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     63|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     54|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 54, False: 9]
  |  |  |  |  ------------------
  |  |  |  |  157|     63|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     63|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     63|	return _ret; \
  |  |  |  |  163|     63|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  763|     63|}
pkcs15-oberthur.c:cosm_new_file:
  480|    163|{
  481|    163|	struct sc_file	*file;
  482|    163|	const char *_template = NULL, *desc = NULL;
  483|    163|	unsigned int structure = 0xFFFFFFFF;
  484|       |
  485|    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]
  |  |  ------------------
  ------------------
  486|    163|	sc_log(card->ctx,  "cosm_new_file() type %X; num %i",type, num);
  ------------------
  |  |   71|    163|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  487|    163|	while (1) {
  ------------------
  |  Branch (487:9): [True: 163, Folded]
  ------------------
  488|    163|		switch (type) {
  ------------------
  |  Branch (488:11): [True: 163, False: 0]
  ------------------
  489|    163|		case SC_PKCS15_TYPE_PRKEY_RSA:
  ------------------
  |  |  419|    163|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (489:3): [True: 163, False: 0]
  ------------------
  490|    163|		case COSM_TYPE_PRKEY_RSA:
  ------------------
  |  |   42|    163|#define COSM_TYPE_PRKEY_RSA (SC_DEVICE_SPECIFIC_TYPE | SC_PKCS15_TYPE_PRKEY_RSA)
  |  |  ------------------
  |  |  |  |   40|    163|#define SC_DEVICE_SPECIFIC_TYPE	 0x1000
  |  |  ------------------
  |  |               #define COSM_TYPE_PRKEY_RSA (SC_DEVICE_SPECIFIC_TYPE | SC_PKCS15_TYPE_PRKEY_RSA)
  |  |  ------------------
  |  |  |  |  419|    163|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  |  |  ------------------
  ------------------
  |  Branch (490:3): [True: 0, False: 163]
  ------------------
  491|    163|			desc = "RSA private key";
  492|    163|			_template = "template-private-key";
  493|    163|			structure = SC_CARDCTL_OBERTHUR_KEY_RSA_CRT;
  494|    163|			break;
  495|      0|		case SC_PKCS15_TYPE_PUBKEY_RSA:
  ------------------
  |  |  426|      0|#define SC_PKCS15_TYPE_PUBKEY_RSA		0x201
  ------------------
  |  Branch (495:3): [True: 0, False: 163]
  ------------------
  496|      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 (496:3): [True: 0, False: 163]
  ------------------
  497|      0|			desc = "RSA public key";
  498|      0|			_template = "template-public-key";
  499|      0|			structure = SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC;
  500|      0|			break;
  501|      0|		case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (501:3): [True: 0, False: 163]
  ------------------
  502|      0|			desc = "certificate";
  503|      0|			_template = "template-certificate";
  504|      0|			break;
  505|      0|		case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|      0|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (505:3): [True: 0, False: 163]
  ------------------
  506|      0|			desc = "data object";
  507|      0|			_template = "template-public-data";
  508|      0|			break;
  509|    163|		}
  510|    163|		if (_template)
  ------------------
  |  Branch (510:7): [True: 163, False: 0]
  ------------------
  511|    163|			break;
  512|       |		/* If this is a specific type such as
  513|       |		 * SC_PKCS15_TYPE_CERT_FOOBAR, fall back to
  514|       |		 * the generic class (SC_PKCS15_TYPE_CERT)
  515|       |		 */
  516|      0|		if (!(type & ~SC_PKCS15_TYPE_CLASS_MASK)) {
  ------------------
  |  |  416|      0|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  |  Branch (516:7): [True: 0, False: 0]
  ------------------
  517|      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__
  |  |  ------------------
  ------------------
  518|      0|				type);
  519|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  520|      0|		}
  521|      0|		type &= SC_PKCS15_TYPE_CLASS_MASK;
  ------------------
  |  |  416|      0|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  522|      0|	}
  523|       |
  524|    163|	sc_log(card->ctx,  "cosm_new_file() template %s; num %i",_template, num);
  ------------------
  |  |   71|    163|#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|    163|	if (sc_profile_get_file(profile, _template, &file) < 0) {
  ------------------
  |  Branch (525:6): [True: 100, False: 63]
  ------------------
  526|    100|		sc_log(card->ctx,  "Profile doesn't define %s template '%s'",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  527|    100|				desc, _template);
  528|    100|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|    100|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  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|    100|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 100, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  529|    100|	}
  530|       |
  531|     63|	file->id |= (num & 0xFF);
  532|     63|	if (file->path.len) {
  ------------------
  |  Branch (532:6): [True: 63, False: 0]
  ------------------
  533|     63|		file->path.value[file->path.len - 1] |= (num & 0xFF);
  534|     63|	}
  535|     63|	if (file->type == SC_FILE_TYPE_INTERNAL_EF)   {
  ------------------
  |  |  215|     63|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (535:6): [True: 4, False: 59]
  ------------------
  536|      4|		file->ef_structure = structure;
  537|      4|	}
  538|       |
  539|     63|	sc_log(card->ctx, "cosm_new_file() file size %zu; ef type %i/%i; id %04X",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  540|     63|			file->size, file->type, file->ef_structure, file->id);
  541|     63|	*out = file;
  542|       |
  543|     63|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|     63|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     63|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     63|	int _ret = r; \
  |  |  |  |  155|     63|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 63, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     63|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 63]
  |  |  |  |  ------------------
  |  |  |  |  157|     63|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     63|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     63|	return _ret; \
  |  |  |  |  163|     63|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  544|     63|}
pkcs15-oberthur.c:cosm_generate_key:
  599|      9|{
  600|      9|	struct sc_context *ctx = p15card->card->ctx;
  601|      9|	struct sc_pkcs15_prkey_info *key_info = (struct sc_pkcs15_prkey_info *)object->data;
  602|      9|	struct sc_cardctl_oberthur_genkey_info args;
  603|      9|	struct sc_file *prkf = NULL, *tmpf = NULL;
  604|      9|	struct sc_path path;
  605|      9|	int rv = 0;
  606|       |
  607|      9|	SC_FUNC_CALLED(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]
  |  |  ------------------
  ------------------
  608|       |
  609|      9|	if (object->type != SC_PKCS15_TYPE_PRKEY_RSA)
  ------------------
  |  |  419|      9|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (609:6): [True: 0, False: 9]
  ------------------
  610|      9|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  611|       |
  612|      9|	if (key_info->path.len < 4) {
  ------------------
  |  Branch (612:6): [True: 1, False: 8]
  ------------------
  613|      1|		LOG_TEST_RET(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  614|      1|				"The path needs to be at least four bytes long");
  615|      1|	}
  616|       |
  617|      8|	path = key_info->path;
  618|      8|	path.len -= 2;
  619|       |
  620|      8|	rv = sc_select_file(p15card->card, &path, &tmpf);
  621|      8|	LOG_TEST_RET(ctx, rv, "Cannot generate key: failed to select private object DF");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  622|       |
  623|      7|	rv = sc_pkcs15init_authenticate(profile, p15card, tmpf, SC_AC_OP_CRYPTO);
  ------------------
  |  |  173|      7|#define SC_AC_OP_CRYPTO			7
  ------------------
  624|      7|	if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|      7|#define SC_SUCCESS				0
  ------------------
  |  Branch (624:6): [True: 1, False: 6]
  ------------------
  625|      1|		sc_file_free(tmpf);
  626|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  627|      1|	}
  628|       |
  629|      6|	rv = sc_pkcs15init_authenticate(profile, p15card, tmpf, SC_AC_OP_CREATE);
  ------------------
  |  |  169|      6|#define SC_AC_OP_CREATE			3
  ------------------
  630|      6|	sc_file_free(tmpf);
  631|      6|	tmpf = NULL;
  632|      6|	LOG_TEST_RET(ctx, rv, "Cannot generate key: 'CREATE' authentication failed");
  ------------------
  |  |  174|      6|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      6|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      6|	int _ret = (r); \
  |  |  |  |  168|      6|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  633|       |
  634|      5|	rv = sc_select_file(p15card->card, &key_info->path, &prkf);
  635|      5|	LOG_TEST_RET(ctx, rv, "Failed to generate key: cannot select private key file");
  ------------------
  |  |  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: 4, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  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|      5|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  636|       |
  637|       |	/* In the private key DF create the temporary public RSA file. */
  638|      1|	rv = cosm_get_temporary_public_key_file(p15card->card, prkf, &tmpf);
  639|      1|	if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
  |  Branch (639:6): [True: 1, False: 0]
  ------------------
  640|      1|		sc_file_free(prkf);
  641|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  642|      1|	}
  643|       |
  644|      0|	rv = sc_pkcs15init_create_file(profile, p15card, tmpf);
  645|      0|	if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (645:6): [True: 0, False: 0]
  ------------------
  646|      0|		sc_file_free(prkf);
  647|      0|		sc_file_free(tmpf);
  648|      0|		LOG_TEST_RET(ctx, rv, "cosm_generate_key() failed to create temporary public key 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  649|      0|	}
  650|       |
  651|      0|	memset(&args, 0, sizeof(args));
  652|      0|	args.id_prv = prkf->id;
  653|      0|	args.id_pub = tmpf->id;
  654|      0|	args.exponent = 0x10001;
  655|      0|	args.key_bits = key_info->modulus_length;
  656|      0|	args.pubkey_len = key_info->modulus_length / 8;
  657|      0|	args.pubkey = malloc(key_info->modulus_length / 8);
  658|      0|	if (!args.pubkey) {
  ------------------
  |  Branch (658:6): [True: 0, False: 0]
  ------------------
  659|      0|		sc_file_free(prkf);
  660|      0|		sc_file_free(tmpf);
  661|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  662|      0|	}
  663|       |
  664|      0|	rv = sc_card_ctl(p15card->card, SC_CARDCTL_OBERTHUR_GENERATE_KEY, &args);
  665|      0|	if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (665:6): [True: 0, False: 0]
  ------------------
  666|      0|		sc_file_free(prkf);
  667|      0|		sc_file_free(tmpf);
  668|      0|		free(args.pubkey);
  669|      0|	}
  670|      0|	LOG_TEST_RET(ctx, rv, "cosm_generate_key() CARDCTL_OBERTHUR_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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  671|       |
  672|       |	/* extract public key */
  673|      0|	pubkey->algorithm = SC_ALGORITHM_RSA;
  ------------------
  |  |   69|      0|#define SC_ALGORITHM_RSA		0
  ------------------
  674|      0|	pubkey->u.rsa.modulus.len   = key_info->modulus_length / 8;
  675|      0|	pubkey->u.rsa.modulus.data  = malloc(key_info->modulus_length / 8);
  676|      0|	if (!pubkey->u.rsa.modulus.data) {
  ------------------
  |  Branch (676:6): [True: 0, False: 0]
  ------------------
  677|      0|		sc_file_free(prkf);
  678|      0|		sc_file_free(tmpf);
  679|      0|		free(args.pubkey);
  680|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  681|      0|	}
  682|       |
  683|       |	/* FIXME and if the exponent length is not 3? */
  684|      0|	pubkey->u.rsa.exponent.len  = 3;
  685|      0|	pubkey->u.rsa.exponent.data = malloc(3);
  686|      0|	if (!pubkey->u.rsa.exponent.data) {
  ------------------
  |  Branch (686:6): [True: 0, False: 0]
  ------------------
  687|      0|		sc_file_free(prkf);
  688|      0|		sc_file_free(tmpf);
  689|      0|		free(args.pubkey);
  690|      0|		free(pubkey->u.rsa.modulus.data);
  691|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  692|      0|	}
  693|      0|	memcpy(pubkey->u.rsa.exponent.data, "\x01\x00\x01", 3);
  694|      0|	memcpy(pubkey->u.rsa.modulus.data, args.pubkey, args.pubkey_len);
  695|      0|	pubkey->u.rsa.modulus.len = args.pubkey_len;
  696|       |
  697|      0|	key_info->key_reference = prkf->path.value[prkf->path.len - 1] & 0xFF;
  698|      0|	key_info->path = prkf->path;
  699|       |
  700|      0|	sc_log(ctx,  "cosm_generate_key() now delete temporary public key");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  701|      0|	rv =  cosm_delete_file(p15card, profile, tmpf);
  702|       |
  703|      0|	sc_file_free(tmpf);
  704|      0|	sc_file_free(prkf);
  705|      0|	free(args.pubkey);
  706|       |
  707|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  708|      0|}
pkcs15-oberthur.c:cosm_get_temporary_public_key_file:
  550|      1|{
  551|      1|	struct sc_context *ctx = card->ctx;
  552|      1|	const struct sc_acl_entry *entry = NULL;
  553|      1|	struct sc_file *file = NULL;
  554|      1|	int rv;
  555|       |
  556|      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]
  |  |  ------------------
  ------------------
  557|      1|	if (!pubkey_file || !prvkey_file)
  ------------------
  |  Branch (557:6): [True: 0, False: 1]
  |  Branch (557:22): [True: 0, False: 1]
  ------------------
  558|      1|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  559|       |
  560|      1|	file = sc_file_new();
  561|      1|	if (!file)
  ------------------
  |  Branch (561:6): [True: 0, False: 1]
  ------------------
  562|      1|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  563|       |
  564|      1|	file->status = SC_FILE_STATUS_ACTIVATED;
  ------------------
  |  |  236|      1|#define SC_FILE_STATUS_ACTIVATED	0x00 /* ISO7816-4: Operational state (activated)   (5, 7) */
  ------------------
  565|      1|        file->type = SC_FILE_TYPE_INTERNAL_EF;
  ------------------
  |  |  215|      1|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  566|      1|	file->ef_structure = SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC;
  567|      1|	file->id = 0x1012;
  568|      1|	memcpy(&file->path, &prvkey_file->path, sizeof(file->path));
  569|      1|        file->path.value[file->path.len - 2] = 0x10;
  570|      1|	file->path.value[file->path.len - 1] = 0x12;
  571|      1|	file->size = prvkey_file->size;
  572|       |
  573|      1|	entry = sc_file_get_acl_entry(prvkey_file, SC_AC_OP_UPDATE);
  ------------------
  |  |  189|      1|#define SC_AC_OP_UPDATE			23
  ------------------
  574|      1|	if (!entry) {
  ------------------
  |  Branch (574:6): [True: 1, False: 0]
  ------------------
  575|      1|		sc_file_free(file);
  576|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  577|      1|	}
  578|      0|	rv = sc_file_add_acl_entry(file, SC_AC_OP_UPDATE, entry->method, entry->key_ref);
  ------------------
  |  |  189|      0|#define SC_AC_OP_UPDATE			23
  ------------------
  579|      0|	if (!rv)
  ------------------
  |  Branch (579:6): [True: 0, False: 0]
  ------------------
  580|      0|		rv = sc_file_add_acl_entry(file, SC_AC_OP_PSO_ENCRYPT, SC_AC_NONE, 0);
  ------------------
  |  |  176|      0|#define SC_AC_OP_PSO_ENCRYPT		10
  ------------------
              		rv = sc_file_add_acl_entry(file, SC_AC_OP_PSO_ENCRYPT, SC_AC_NONE, 0);
  ------------------
  |  |  150|      0|#define SC_AC_NONE			0x00000000
  ------------------
  581|      0|	if (!rv)
  ------------------
  |  Branch (581:6): [True: 0, False: 0]
  ------------------
  582|      0|		rv = sc_file_add_acl_entry(file, SC_AC_OP_PSO_VERIFY_SIGNATURE, SC_AC_NONE, 0);
  ------------------
  |  |  178|      0|#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|      0|#define SC_AC_NONE			0x00000000
  ------------------
  583|      0|	if (!rv)
  ------------------
  |  Branch (583:6): [True: 0, False: 0]
  ------------------
  584|      0|		rv = sc_file_add_acl_entry(file, SC_AC_OP_EXTERNAL_AUTHENTICATE, SC_AC_NONE, 0);
  ------------------
  |  |  182|      0|#define SC_AC_OP_EXTERNAL_AUTHENTICATE	16
  ------------------
              		rv = sc_file_add_acl_entry(file, SC_AC_OP_EXTERNAL_AUTHENTICATE, SC_AC_NONE, 0);
  ------------------
  |  |  150|      0|#define SC_AC_NONE			0x00000000
  ------------------
  585|      0|	if (rv < 0)
  ------------------
  |  Branch (585:6): [True: 0, False: 0]
  ------------------
  586|      0|		sc_file_free(file);
  587|      0|	LOG_TEST_RET(ctx, rv, "Failed to add ACL entry to the temporary public 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  588|       |
  589|      0|	*pubkey_file = file;
  590|       |
  591|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  592|      0|}

sc_pkcs15init_get_openpgp_ops:
  620|    883|{
  621|    883|	return &sc_pkcs15init_openpgp_operations;
  622|    883|}
pkcs15-openpgp.c:openpgp_erase:
   46|    322|{
   47|    322|	return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    322|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
   48|    322|}
pkcs15-openpgp.c:openpgp_select_pin_reference:
   71|    279|{
   72|    279|	return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    279|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
   73|    279|}
pkcs15-openpgp.c:openpgp_create_key:
   98|  1.22k|{
   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|  1.22k|	LOG_FUNC_CALLED(p15card->card->ctx);
  ------------------
  |  |  151|  1.22k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.22k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.22k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.22k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.22k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  104|  1.22k|	LOG_FUNC_RETURN(p15card->card->ctx, SC_SUCCESS);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 1.22k]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  105|  1.22k|}
pkcs15-openpgp.c:openpgp_store_key:
  173|    951|{
  174|    951|	sc_card_t *card = p15card->card;
  175|    951|	sc_pkcs15_prkey_info_t *kinfo = (sc_pkcs15_prkey_info_t *) obj->data;
  176|    951|	sc_cardctl_openpgp_key_gen_store_info_t key_info = {0};
  177|    951|	int r;
  178|       |
  179|    951|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    951|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    951|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    951|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    951|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 951]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  180|       |
  181|    951|	switch(obj->type)
  182|    951|	{
  183|      0|	case SC_PKCS15_TYPE_PRKEY_RSA:
  ------------------
  |  |  419|      0|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (183:2): [True: 0, False: 951]
  ------------------
  184|      0|		memset(&key_info, 0, sizeof(sc_cardctl_openpgp_key_gen_store_info_t));
  185|      0|		key_info.algorithm = SC_OPENPGP_KEYALGO_RSA;
  ------------------
  |  |  870|      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: 951]
  ------------------
  201|      0|	case SC_PKCS15_TYPE_PRKEY_EDDSA:
  ------------------
  |  |  422|      0|#define SC_PKCS15_TYPE_PRKEY_EDDSA		0x105
  ------------------
  |  Branch (201:2): [True: 0, False: 951]
  ------------------
  202|      0|	case SC_PKCS15_TYPE_PRKEY_XEDDSA:
  ------------------
  |  |  423|      0|#define SC_PKCS15_TYPE_PRKEY_XEDDSA		0x106
  ------------------
  |  Branch (202:2): [True: 0, False: 951]
  ------------------
  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|    951|	default:
  ------------------
  |  Branch (230:2): [True: 951, False: 0]
  ------------------
  231|    951|		r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    951|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  232|    951|		sc_log(card->ctx, "%s: Key generation failed: Unknown/unsupported key type.", strerror(r));
  ------------------
  |  |   71|    951|#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|    951|	}
  234|       |
  235|    951|err:
  236|    951|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    951|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    951|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    951|	int _ret = r; \
  |  |  |  |  155|    951|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 951, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    951|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    951|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 951, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    951|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    951|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    951|	return _ret; \
  |  |  |  |  163|    951|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  237|    951|}
pkcs15-openpgp.c:openpgp_generate_key:
  438|    271|{
  439|    271|	sc_card_t *card = p15card->card;
  440|    271|	sc_context_t *ctx = card->ctx;
  441|    271|	int r;
  442|       |
  443|    271|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    271|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    271|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    271|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    271|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 271]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  444|       |
  445|    271|	switch(obj->type)
  446|    271|	{
  447|    246|	case SC_PKCS15_TYPE_PRKEY_RSA:
  ------------------
  |  |  419|    246|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (447:2): [True: 246, False: 25]
  ------------------
  448|    246|		r = openpgp_generate_key_rsa(card, obj, pubkey);
  449|    246|		break;
  450|     25|	case SC_PKCS15_TYPE_PRKEY_EC:
  ------------------
  |  |  421|     25|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  |  Branch (450:2): [True: 25, False: 246]
  ------------------
  451|     25|		if (card->type < SC_CARD_TYPE_OPENPGP_V3) {
  ------------------
  |  Branch (451:7): [True: 10, False: 15]
  ------------------
  452|     10|			sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "only RSA is supported on this card");
  ------------------
  |  |   70|     10|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  453|     10|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|     10|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  454|     10|		}
  455|     15|		r = openpgp_generate_key_ec(card, obj, pubkey);
  456|     15|		break;
  457|      0|	case SC_PKCS15_TYPE_PRKEY_EDDSA:
  ------------------
  |  |  422|      0|#define SC_PKCS15_TYPE_PRKEY_EDDSA		0x105
  ------------------
  |  Branch (457:2): [True: 0, False: 271]
  ------------------
  458|      0|	case SC_PKCS15_TYPE_PRKEY_XEDDSA:
  ------------------
  |  |  423|      0|#define SC_PKCS15_TYPE_PRKEY_XEDDSA		0x106
  ------------------
  |  Branch (458:2): [True: 0, False: 271]
  ------------------
  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: 271]
  ------------------
  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|    271|	}
  469|       |
  470|    261|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    261|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    261|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    261|	int _ret = r; \
  |  |  |  |  155|    261|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 261, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    261|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    257|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 257, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  157|    261|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    261|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    261|	return _ret; \
  |  |  |  |  163|    261|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  471|    261|}
pkcs15-openpgp.c:openpgp_generate_key_rsa:
  248|    246|{
  249|    246|	sc_context_t *ctx = card->ctx;
  250|    246|	sc_cardctl_openpgp_key_gen_store_info_t key_info;
  251|    246|	sc_pkcs15_prkey_info_t *required = (sc_pkcs15_prkey_info_t *)obj->data;
  252|    246|	sc_pkcs15_id_t *kid = &(required->id);
  253|    246|	int r;
  254|       |
  255|    246|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    246|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    246|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    246|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    246|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 246]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  256|    246|	memset(&key_info, 0, sizeof(key_info));
  257|    246|	sc_log(ctx, "Key ID to be generated: %s", sc_dump_hex(kid->value, kid->len));
  ------------------
  |  |   71|    246|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  258|       |
  259|       |	/* Accept KeyID = 45, which is default value set by pkcs15init */
  260|    246|	if (kid->len == 1 && kid->value[0] == 0x45) {
  ------------------
  |  Branch (260:6): [True: 246, False: 0]
  |  Branch (260:23): [True: 246, 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|    246|		sc_log(ctx, "Authentication key is to be generated.");
  ------------------
  |  |   71|    246|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  264|    246|		key_info.key_id = 3;
  265|    246|	}
  266|    246|	if (!key_info.key_id && (kid->len > 1 || kid->value[0] > 3)) {
  ------------------
  |  Branch (266:6): [True: 0, False: 246]
  |  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|    246|	if (!key_info.key_id)
  ------------------
  |  Branch (271:6): [True: 0, False: 246]
  ------------------
  272|      0|		key_info.key_id = kid->value[0];
  273|       |
  274|    246|	if (obj->type != SC_PKCS15_TYPE_PRKEY_RSA) {
  ------------------
  |  |  419|    246|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (274:6): [True: 0, False: 246]
  ------------------
  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|    246|	key_info.algorithm = SC_OPENPGP_KEYALGO_RSA;
  ------------------
  |  |  870|    246|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  281|       |
  282|       |	/* Prepare buffer */
  283|    246|	key_info.u.rsa.modulus_len = required->modulus_length;
  284|    246|	key_info.u.rsa.modulus = calloc(1, BYTES4BITS(required->modulus_length));
  ------------------
  |  |  146|    246|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  285|    246|	if (key_info.u.rsa.modulus == NULL)
  ------------------
  |  Branch (285:6): [True: 0, False: 246]
  ------------------
  286|    246|		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|    246|	key_info.u.rsa.exponent_len = 32;
  290|    246|	key_info.u.rsa.exponent = calloc(1, BYTES4BITS(key_info.u.rsa.exponent_len));
  ------------------
  |  |  146|    246|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  291|    246|	if (key_info.u.rsa.exponent == NULL) {
  ------------------
  |  Branch (291:6): [True: 0, False: 246]
  ------------------
  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|    246|	r = sc_card_ctl(card, SC_CARDCTL_OPENPGP_GENERATE_KEY, &key_info);
  297|    246|	LOG_TEST_GOTO_ERR(card->ctx, r, "on-card EC key generation failed");
  ------------------
  |  |  184|    246|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    246|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    246|	int _ret = (r); \
  |  |  |  |  178|    246|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 242, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  179|    242|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    242|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    242|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    242|		goto err; \
  |  |  |  |  182|    242|	} \
  |  |  |  |  183|    246|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  298|       |
  299|      4|	pubkey->algorithm = SC_ALGORITHM_RSA;
  ------------------
  |  |   69|      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|    246|err:
  315|    246|	free(key_info.u.rsa.modulus);
  316|    246|	key_info.u.rsa.modulus = NULL;
  317|    246|	free(key_info.u.rsa.exponent);
  318|    246|	key_info.u.rsa.exponent = NULL;
  319|    246|	free(key_info.data);
  320|    246|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    246|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    246|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    246|	int _ret = r; \
  |  |  |  |  155|    246|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 246, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    246|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    242|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 242, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  157|    246|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    246|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    246|	return _ret; \
  |  |  |  |  163|    246|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  321|    246|}
pkcs15-openpgp.c:openpgp_generate_key_ec:
  333|     15|{
  334|     15|	sc_context_t *ctx = card->ctx;
  335|     15|	sc_cardctl_openpgp_key_gen_store_info_t key_info;
  336|     15|	sc_pkcs15_prkey_info_t *required = (sc_pkcs15_prkey_info_t *)obj->data;
  337|     15|	sc_pkcs15_id_t *kid = &(required->id);
  338|     15|	struct sc_ec_parameters *info_ec =
  339|     15|			(struct sc_ec_parameters *)required->params.data;
  340|     15|	int r;
  341|       |
  342|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  343|     15|	memset(&key_info, 0, sizeof(key_info));
  344|       |
  345|     15|	sc_log(ctx, "Key ID to be generated: %s", sc_dump_hex(kid->value, kid->len));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  346|       |
  347|       |	/* Accept KeyID = 45, which is default value set by pkcs15init */
  348|     15|	if (kid->len == 1 && kid->value[0] == 0x45) {
  ------------------
  |  Branch (348:6): [True: 15, False: 0]
  |  Branch (348:23): [True: 15, 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|     15|		sc_log(ctx, "Authentication key is to be generated.");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  352|     15|		key_info.key_id = 3;
  353|     15|	}
  354|     15|	if (!key_info.key_id && (kid->len > 1 || kid->value[0] > 3)) {
  ------------------
  |  Branch (354:6): [True: 0, False: 15]
  |  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|     15|	if (!key_info.key_id)
  ------------------
  |  Branch (359:6): [True: 0, False: 15]
  ------------------
  360|      0|		key_info.key_id = kid->value[0];
  361|     15|	key_info.key_type = pubkey->algorithm;
  362|       |	/* set algorithm id based on key reference and key type */
  363|     15|	switch (pubkey->algorithm) {
  ------------------
  |  Branch (363:10): [True: 15, 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|     15|	case SC_ALGORITHM_EC:
  ------------------
  |  |   70|     15|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (372:2): [True: 15, False: 0]
  ------------------
  373|     15|		key_info.algorithm = (key_info.key_id == SC_OPENPGP_KEY_ENCR)
  ------------------
  |  |  867|     15|#define SC_OPENPGP_KEY_ENCR		2
  ------------------
  |  Branch (373:24): [True: 0, False: 15]
  ------------------
  374|     15|						     ? SC_OPENPGP_KEYALGO_ECDH	 /* ECDH for slot 2 only */
  ------------------
  |  |  871|      0|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  375|     15|						     : SC_OPENPGP_KEYALGO_ECDSA; /* ECDSA for slot 1 and 3 */
  ------------------
  |  |  872|     30|#define	SC_OPENPGP_KEYALGO_ECDSA	0x13
  ------------------
  376|     15|		key_info.u.ec.ecpointQ_len = 1 + 2 * BYTES4BITS(required->field_length);
  ------------------
  |  |  146|     15|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  377|     15|		break;
  378|      0|	case SC_ALGORITHM_EDDSA:
  ------------------
  |  |   72|      0|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (378:2): [True: 0, False: 15]
  ------------------
  379|      0|		key_info.algorithm = SC_OPENPGP_KEYALGO_EDDSA; /* only sign */
  ------------------
  |  |  873|      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:
  ------------------
  |  |   73|      0|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (382:2): [True: 0, False: 15]
  ------------------
  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 */
  ------------------
  |  |  871|      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|     15|	}
  388|       |
  389|       |	/* copying info_ec.id works for any EC ECDH EdDSA keys */
  390|     15|	if (info_ec->der.len > 2 && info_ec->der.len == (size_t)(info_ec->der.value[1] + 2))
  ------------------
  |  Branch (390:6): [True: 15, False: 0]
  |  Branch (390:30): [True: 15, False: 0]
  ------------------
  391|     15|		key_info.u.ec.oidv_len = info_ec->der.value[1];
  392|      0|	else
  393|     15|		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|    135|	for (size_t i = 0; (i < key_info.u.ec.oidv_len) && (i + 2 < info_ec->der.len); i++) {
  ------------------
  |  Branch (395:21): [True: 120, False: 15]
  |  Branch (395:53): [True: 120, False: 0]
  ------------------
  396|    120|		key_info.u.ec.oidv.value[i] = info_ec->der.value[i + 2];
  397|    120|	}
  398|     15|	key_info.u.ec.oidv.value[key_info.data_len] = -1;
  399|       |
  400|       |	/* copy  id also */
  401|     15|	key_info.u.ec.oid = info_ec->id;
  402|       |
  403|       |	/* generate key on card */
  404|     15|	r = sc_card_ctl(card, SC_CARDCTL_OPENPGP_GENERATE_KEY, &key_info);
  405|     15|	LOG_TEST_GOTO_ERR(card->ctx, r, "on-card EC key generation failed");
  ------------------
  |  |  184|     15|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     15|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     15|	int _ret = (r); \
  |  |  |  |  178|     15|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 15, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|     15|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     15|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     15|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     15|		goto err; \
  |  |  |  |  182|     15|	} \
  |  |  |  |  183|     15|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  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|     15|err:
  421|     15|	free(key_info.u.ec.ecpointQ);
  422|     15|	free(key_info.data);
  423|       |
  424|     15|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|     15|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     15|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     15|	int _ret = r; \
  |  |  |  |  155|     15|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 15, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     15|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     15|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 15, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     15|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     15|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     15|	return _ret; \
  |  |  |  |  163|     15|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  425|     15|}
pkcs15-openpgp.c:openpgp_emu_update_any_df:
  475|      3|{
  476|      3|	LOG_FUNC_CALLED(p15card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  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|      3|	LOG_FUNC_RETURN(p15card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  480|      3|}
pkcs15-openpgp.c:openpgp_emu_update_tokeninfo:
  484|      1|{
  485|      1|	LOG_FUNC_CALLED(p15card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  486|       |	/* When unbinding pkcs15init, this function will be called.
  487|       |	 * But for OpenPGP, token info does not need to change, we do nothing. */
  488|      1|	LOG_FUNC_RETURN(p15card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  489|      1|}
pkcs15-openpgp.c:openpgp_store_data:
  494|    326|{
  495|    326|	sc_card_t *card = p15card->card;
  496|    326|	sc_context_t *ctx = card->ctx;
  497|    326|	sc_file_t *file = NULL;
  498|    326|	sc_pkcs15_cert_info_t *cinfo;
  499|    326|	sc_pkcs15_id_t *cid;
  500|    326|	sc_pkcs15_data_info_t *dinfo;
  501|    326|	u8 buf[254];
  502|    326|	int r;
  503|       |
  504|    326|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    326|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    326|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    326|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    326|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 326]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  505|       |
  506|    326|	switch (obj->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|    326|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  507|      2|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|      2|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (507:2): [True: 2, False: 324]
  ------------------
  508|      4|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|      4|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (508:2): [True: 2, False: 324]
  ------------------
  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|      4|		r = SC_SUCCESS;
  ------------------
  |  |   28|      4|#define SC_SUCCESS				0
  ------------------
  512|      4|		break;
  513|       |
  514|      0|	case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (514:2): [True: 0, False: 326]
  ------------------
  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, "Data to write is %zu long", content->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__
  |  |  ------------------
  ------------------
  552|      0|		if (r >= 0 && content->len)
  ------------------
  |  Branch (552:7): [True: 0, False: 0]
  |  Branch (552:17): [True: 0, False: 0]
  ------------------
  553|      0|			r = sc_put_data(p15card->card, tag, (const unsigned char *) content->value, content->len);
  554|      0|		break;
  555|       |
  556|    322|	case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|    322|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (556:2): [True: 322, False: 4]
  ------------------
  557|    322|		dinfo = (sc_pkcs15_data_info_t *) obj->data;
  558|       |		/* dinfo->app_label contains filename */
  559|    322|		sc_log(ctx, "===== App label %s", dinfo->app_label);
  ------------------
  |  |   71|    322|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  560|       |		/* Currently, we only support DO 0101. The reason is that when initializing this
  561|       |		 * pkcs15 emulation, PIN authentication is not applied and we can expose only this DO,
  562|       |		 * which is "read always".
  563|       |		 * If we support other DOs, they will not be exposed, and not helpful to user.
  564|       |		 * I haven't found a way to refresh the list of exposed DOs after verifying PIN yet.
  565|       |		 * http://sourceforge.net/mailarchive/message.php?msg_id=30646373
  566|       |		 **/
  567|    322|		sc_log(ctx, "About to write to DO 0101");
  ------------------
  |  |   71|    322|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  568|    322|		sc_format_path("0101", path);
  569|    322|		r = sc_select_file(card, path, &file);
  570|    322|		LOG_TEST_RET(card->ctx, r, "Cannot select private DO");
  ------------------
  |  |  174|    322|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    322|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    322|	int _ret = (r); \
  |  |  |  |  168|    322|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 322]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|    322|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 322]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  571|    322|		r = sc_read_binary(card, 0, buf, sizeof(buf), 0);
  572|    322|		if (r < 0) {
  ------------------
  |  Branch (572:7): [True: 262, False: 60]
  ------------------
  573|    262|			sc_log(ctx, "Cannot read DO 0101");
  ------------------
  |  |   71|    262|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  574|    262|			break;
  575|    262|		}
  576|     60|		if (r > 0) {
  ------------------
  |  Branch (576:7): [True: 21, False: 39]
  ------------------
  577|     21|			sc_log(ctx, "DO 0101 is full.");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  578|     21|			r = SC_ERROR_NOT_ENOUGH_MEMORY;
  ------------------
  |  |   67|     21|#define SC_ERROR_NOT_ENOUGH_MEMORY		-1217
  ------------------
  579|     21|			break;
  580|     21|		}
  581|     39|		r = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_UPDATE);
  ------------------
  |  |  189|     39|#define SC_AC_OP_UPDATE			23
  ------------------
  582|     39|		if (r >= 0 && content->len) {
  ------------------
  |  Branch (582:7): [True: 24, False: 15]
  |  Branch (582:17): [True: 24, False: 0]
  ------------------
  583|     24|			r = sc_update_binary(p15card->card, 0,
  584|     24|			                     (const unsigned char *) content->value,
  585|     24|			                     content->len, 0);
  586|     24|		}
  587|     39|		break;
  588|       |
  589|      0|	default:
  ------------------
  |  Branch (589:2): [True: 0, False: 326]
  ------------------
  590|      0|		r = SC_ERROR_NOT_IMPLEMENTED;
  ------------------
  |  |   97|      0|#define SC_ERROR_NOT_IMPLEMENTED		-1416
  ------------------
  591|    326|	}
  592|       |
  593|    326|	sc_file_free(file);
  594|    326|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    326|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    326|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    326|	int _ret = r; \
  |  |  |  |  155|    326|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 320, False: 6]
  |  |  |  |  ------------------
  |  |  |  |  156|    320|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    315|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 315, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  157|    320|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    320|	} 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|    326|	return _ret; \
  |  |  |  |  163|    326|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  595|    326|}

sc_pkcs15init_get_rtecp_ops:
  714|    149|{
  715|    149|	return &sc_pkcs15init_rtecp_operations;
  716|    149|}
pkcs15-rtecp.c:rtecp_erase:
   41|      9|{
   42|      9|	int r;
   43|       |
   44|      9|	if (!profile || !p15card || !p15card->card)
  ------------------
  |  Branch (44:6): [True: 0, False: 9]
  |  Branch (44:18): [True: 0, False: 9]
  |  Branch (44:30): [True: 0, False: 9]
  ------------------
   45|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   46|      9|	r = sc_card_ctl(p15card->card, SC_CARDCTL_RTECP_INIT, NULL);
   47|      9|	if (r == SC_SUCCESS)
  ------------------
  |  |   28|      9|#define SC_SUCCESS				0
  ------------------
  |  Branch (47:6): [True: 1, False: 8]
  ------------------
   48|      1|		sc_free_apps(p15card->card);
   49|      9|	return r;
   50|      9|}
pkcs15-rtecp.c:rtecp_init:
   91|     62|{
   92|     62|	sc_card_t *card;
   93|     62|	sc_file_t *file;
   94|     62|	int r;
   95|       |
   96|     62|	if (!profile || !p15card || !p15card->card || !p15card->card->ctx)
  ------------------
  |  Branch (96:6): [True: 0, False: 62]
  |  Branch (96:18): [True: 0, False: 62]
  |  Branch (96:30): [True: 0, False: 62]
  |  Branch (96:48): [True: 0, False: 62]
  ------------------
   97|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   98|       |
   99|     62|	card = p15card->card;
  100|       |
  101|     62|	r = sc_profile_get_file(profile, "MF", &file);
  102|     62|	LOG_TEST_RET(card->ctx, r, "Get MF info failed");
  ------------------
  |  |  174|     62|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     62|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     62|	int _ret = (r); \
  |  |  |  |  168|     62|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 62]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|     62|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 62]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  103|     62|	if (file == NULL)
  ------------------
  |  Branch (103:6): [True: 0, False: 62]
  ------------------
  104|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  105|     62|	r = sc_create_file(card, file);
  106|     62|	sc_file_free(file);
  107|     62|	LOG_TEST_RET(card->ctx, r, "Create MF failed");
  ------------------
  |  |  174|     62|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     62|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     62|	int _ret = (r); \
  |  |  |  |  168|     62|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 58, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  169|     58|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     58|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     58|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     58|		return _ret; \
  |  |  |  |  172|     58|	} \
  |  |  |  |  173|     62|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  108|       |
  109|      4|	r = sc_profile_get_file(profile, "DIR", &file);
  110|      4|	LOG_TEST_RET(card->ctx, r, "Get DIR file info 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  111|      3|	if (!file)
  ------------------
  |  Branch (111:6): [True: 0, False: 3]
  ------------------
  112|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  113|      3|	r = sc_create_file(card, file);
  114|      3|	sc_file_free(file);
  115|      3|	LOG_TEST_RET(card->ctx, r, "Create DIR 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  116|       |
  117|      1|	create_sysdf(profile, card, "Sys-DF");
  118|      1|	create_sysdf(profile, card, "SysKey-DF");
  119|      1|	create_sysdf(profile, card, "PuKey-DF");
  120|      1|	create_sysdf(profile, card, "PrKey-DF");
  121|      1|	create_sysdf(profile, card, "SKey-DF");
  122|      1|	create_sysdf(profile, card, "Cer-DF");
  123|      1|	create_sysdf(profile, card, "LCHV-DF");
  124|       |
  125|      1|	create_sysdf(profile, card, "Resrv1-DF");
  126|      1|	create_sysdf(profile, card, "Resrv2-DF");
  127|      1|	create_sysdf(profile, card, "Resrv3-DF");
  128|      1|	create_sysdf(profile, card, "Resrv4-DF");
  129|      1|	create_sysdf(profile, card, "Resrv5-DF");
  130|      1|	create_sysdf(profile, card, "Resrv6-DF");
  131|       |
  132|       |	return sc_select_file(card, sc_get_mf_path(), NULL);
  133|      3|}
pkcs15-rtecp.c:create_sysdf:
   53|     13|{
   54|     13|	sc_file_t *file;
   55|     13|	sc_path_t path;
   56|     13|	int r;
   57|       |
   58|     13|	if (profile == NULL || card == NULL || card->ctx == NULL || name == NULL)
  ------------------
  |  Branch (58:6): [True: 0, False: 13]
  |  Branch (58:25): [True: 0, False: 13]
  |  Branch (58:41): [True: 0, False: 13]
  |  Branch (58:62): [True: 0, False: 13]
  ------------------
   59|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
   60|     13|	r = sc_profile_get_file(profile, name, &file);
   61|     13|	if (r == SC_SUCCESS)
  ------------------
  |  |   28|     13|#define SC_SUCCESS				0
  ------------------
  |  Branch (61:6): [True: 0, False: 13]
  ------------------
   62|      0|	{
   63|      0|		if (!file)
  ------------------
  |  Branch (63:7): [True: 0, False: 0]
  ------------------
   64|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
   65|      0|		path = file->path;
   66|      0|		if (path.len <= 2) {
  ------------------
  |  Branch (66:7): [True: 0, False: 0]
  ------------------
   67|      0|			sc_file_free(file);
   68|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
   69|      0|		}
   70|      0|		if (path.len > 2)
  ------------------
  |  Branch (70:7): [True: 0, False: 0]
  ------------------
   71|      0|			path.len -= 2;
   72|      0|		r = sc_select_file(card, &path, NULL);
   73|      0|		if (r == SC_SUCCESS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (73:7): [True: 0, False: 0]
  ------------------
   74|      0|			r = sc_file_add_acl_entry(file, SC_AC_OP_CREATE,
  ------------------
  |  |  169|      0|#define SC_AC_OP_CREATE			3
  ------------------
   75|      0|					SC_AC_CHV, RTECP_USER_PIN_REF);
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
              					SC_AC_CHV, RTECP_USER_PIN_REF);
  ------------------
  |  |   35|      0|#define RTECP_USER_PIN_REF      2
  ------------------
   76|      0|		if (r == SC_SUCCESS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (76:7): [True: 0, False: 0]
  ------------------
   77|      0|			r = sc_file_add_acl_entry(file, SC_AC_OP_DELETE,
  ------------------
  |  |  168|      0|#define SC_AC_OP_DELETE			2
  ------------------
   78|      0|					SC_AC_NEVER, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  163|      0|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
              					SC_AC_NEVER, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|      0|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
   79|      0|		if (r == SC_SUCCESS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (79:7): [True: 0, False: 0]
  ------------------
   80|      0|			r = sc_create_file(card, file);
   81|      0|		sc_file_free(file);
   82|      0|	}
   83|     13|	sc_log(card->ctx, "Create %s failed: %s\n", name, sc_strerror(r));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
   84|     13|	return r;
   85|     13|}
pkcs15-rtecp.c:rtecp_select_pin_reference:
  150|    104|{
  151|    104|	int pin_ref;
  152|       |
  153|    104|	if (!profile || !p15card || !p15card->card || !p15card->card->ctx || !auth_info)
  ------------------
  |  Branch (153:6): [True: 0, False: 104]
  |  Branch (153:18): [True: 0, False: 104]
  |  Branch (153:30): [True: 0, False: 104]
  |  Branch (153:48): [True: 0, False: 104]
  |  Branch (153:71): [True: 0, False: 104]
  ------------------
  154|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  155|       |
  156|    104|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|    104|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (156:6): [True: 0, False: 104]
  ------------------
  157|      0|	                return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  158|       |
  159|    104|	if (auth_info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN)
  ------------------
  |  |   61|    104|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (159:6): [True: 2, False: 102]
  ------------------
  160|      2|		pin_ref = RTECP_SO_PIN_REF;
  ------------------
  |  |   34|      2|#define RTECP_SO_PIN_REF        1
  ------------------
  161|    102|	else
  162|    102|		pin_ref = RTECP_USER_PIN_REF;
  ------------------
  |  |   35|    102|#define RTECP_USER_PIN_REF      2
  ------------------
  163|    104|	if (auth_info->attrs.pin.reference != pin_ref)
  ------------------
  |  Branch (163:6): [True: 42, False: 62]
  ------------------
  164|    104|		LOG_FUNC_RETURN(p15card->card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  165|       |
  166|     62|	return SC_SUCCESS;
  ------------------
  |  |   28|     62|#define SC_SUCCESS				0
  ------------------
  167|    104|}
pkcs15-rtecp.c:rtecp_select_key_reference:
  267|      9|{
  268|      9|	sc_file_t *df;
  269|      9|	int r;
  270|       |
  271|      9|	if (!profile || !p15card || !p15card->card || !p15card->card->ctx || !key_info)
  ------------------
  |  Branch (271:6): [True: 0, False: 9]
  |  Branch (271:18): [True: 0, False: 9]
  |  Branch (271:30): [True: 0, False: 9]
  |  Branch (271:48): [True: 0, False: 9]
  |  Branch (271:71): [True: 0, False: 9]
  ------------------
  272|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  273|       |
  274|      9|	if (key_info->key_reference <= 0)
  ------------------
  |  Branch (274:6): [True: 9, False: 0]
  ------------------
  275|      9|		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|      9|	r = sc_profile_get_file(profile, "PrKey-DF", &df);
  280|      9|	LOG_TEST_RET(p15card->card->ctx, r, "Get PrKey-DF info 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: 9, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|      9|} 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|      9|{
  645|      9|	if (!card)
  ------------------
  |  Branch (645:6): [True: 0, False: 9]
  ------------------
  646|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  647|      9|	return sc_card_ctl(card, SC_CARDCTL_RTECP_INIT_END, NULL);
  648|      9|}

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

sc_pkcs15init_get_sc_hsm_ops:
  693|    488|{
  694|    488|	return &sc_pkcs15init_sc_hsm_operations;
  695|    488|}
pkcs15-sc-hsm.c:sc_hsm_create_key:
  114|  1.11k|{
  115|       |	// Keys are automatically generated in GENERATE ASYMMETRIC KEY PAIR command
  116|  1.11k|	LOG_FUNC_CALLED(p15card->card->ctx);
  ------------------
  |  |  151|  1.11k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.11k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.11k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.11k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.11k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  117|  1.11k|	LOG_FUNC_RETURN(p15card->card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|  1.11k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.11k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.11k|	int _ret = r; \
  |  |  |  |  155|  1.11k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.11k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.11k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 1.11k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.11k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.11k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|  1.11k|	return _ret; \
  |  |  |  |  163|  1.11k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  118|  1.11k|}
pkcs15-sc-hsm.c:sc_hsm_store_key:
  124|    666|{
  125|    666|	LOG_FUNC_CALLED(p15card->card->ctx);
  ------------------
  |  |  151|    666|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    666|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    666|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    666|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 666]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  126|    666|	LOG_FUNC_RETURN(p15card->card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|    666|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    666|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    666|	int _ret = r; \
  |  |  |  |  155|    666|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 666, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    666|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    666|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 666, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    666|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    666|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    666|	return _ret; \
  |  |  |  |  163|    666|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  127|    666|}
pkcs15-sc-hsm.c:sc_hsm_generate_key:
  248|    444|{
  249|    444|	struct sc_card *card = p15card->card;
  250|    444|	sc_hsm_private_data_t *priv = (sc_hsm_private_data_t *) card->drv_data;
  251|    444|	struct sc_pkcs15_prkey_info *key_info = (struct sc_pkcs15_prkey_info *)object->data;
  252|    444|	sc_cardctl_sc_hsm_keygen_info_t sc_hsm_keyinfo;
  253|    444|	sc_hsm_keygen_data_t *keygen_data;
  254|    444|	sc_cvc_t cvc;
  255|    444|	u8 *cvcbin, *cvcpo;
  256|    444|	unsigned int cla,tag;
  257|    444|	size_t taglen, cvclen;
  258|    444|	u8 gakp[512];
  259|    444|	int r;
  260|       |
  261|    444|	LOG_FUNC_CALLED(p15card->card->ctx);
  ------------------
  |  |  151|    444|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    444|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    444|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    444|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 444]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  262|       |
  263|    444|	key_info->key_reference = sc_hsm_determine_free_id(p15card, KEY_PREFIX);
  ------------------
  |  |   33|    444|#define KEY_PREFIX		0xCC		/* Hi byte in file identifier for key objects */
  ------------------
  264|    444|	LOG_TEST_RET(card->ctx, key_info->key_reference, "Could not determine key reference");
  ------------------
  |  |  174|    444|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    444|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    444|	int _ret = (r); \
  |  |  |  |  168|    444|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 14, False: 430]
  |  |  |  |  ------------------
  |  |  |  |  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|    444|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 430]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  265|       |
  266|    430|	memset(&cvc, 0, sizeof(cvc));
  267|       |
  268|    430|	strlcpy(cvc.car, "UTCA00001", sizeof cvc.car);
  ------------------
  |  |   43|    430|#define strlcpy _strlcpy
  ------------------
  269|    430|	cvc.carLen = strlen(cvc.car);
  270|    430|	if (priv->serialno)
  ------------------
  |  Branch (270:6): [True: 0, False: 430]
  ------------------
  271|      0|		strlcpy(cvc.chr, priv->serialno, sizeof cvc.chr);
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
  272|    430|	strlcat(cvc.chr, "00001", sizeof cvc.chr);
  273|    430|	cvc.chrLen = strlen(cvc.chr);
  274|       |
  275|    430|	switch(object->type) {
  276|    216|	case SC_PKCS15_TYPE_PRKEY_RSA:
  ------------------
  |  |  419|    216|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (276:2): [True: 216, False: 214]
  ------------------
  277|    216|		r = sc_hsm_encode_gakp_rsa(p15card, &cvc, key_info->modulus_length);
  278|    216|		break;
  279|    214|	case SC_PKCS15_TYPE_PRKEY_EC:
  ------------------
  |  |  421|    214|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  |  Branch (279:2): [True: 214, False: 216]
  ------------------
  280|    214|		r = sc_hsm_encode_gakp_ec(p15card, &cvc, key_info);
  281|    214|		break;
  282|      0|	default:
  ------------------
  |  Branch (282:2): [True: 0, False: 430]
  ------------------
  283|      0|		r = SC_ERROR_NOT_IMPLEMENTED;
  ------------------
  |  |   97|      0|#define SC_ERROR_NOT_IMPLEMENTED		-1416
  ------------------
  284|      0|		break;
  285|    430|	}
  286|    430|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|    430|#define SC_SUCCESS				0
  ------------------
  |  Branch (286:6): [True: 0, False: 430]
  ------------------
  287|      0|		sc_pkcs15emu_sc_hsm_free_cvc(&cvc);
  288|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  289|      0|	}
  290|       |
  291|    430|	r = sc_pkcs15emu_sc_hsm_encode_cvc(p15card, &cvc, &cvcbin, &cvclen);
  292|    430|	sc_pkcs15emu_sc_hsm_free_cvc(&cvc);
  293|    430|	LOG_TEST_RET(p15card->card->ctx, r, "Could not encode GAKP cdata");
  ------------------
  |  |  174|    430|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    430|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    430|	int _ret = (r); \
  |  |  |  |  168|    430|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 430]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|    430|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 430]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  294|       |
  295|    430|	cvcpo = cvcbin;
  296|    430|	sc_asn1_read_tag((const u8 **)&cvcpo, cvclen, &cla, &tag, &taglen);
  297|    430|	sc_asn1_read_tag((const u8 **)&cvcpo, cvclen, &cla, &tag, &taglen);
  298|       |
  299|    430|	if (taglen > sizeof(gakp)) {
  ------------------
  |  Branch (299:6): [True: 0, False: 430]
  ------------------
  300|      0|		r = SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  301|      0|		goto out;
  302|      0|	}
  303|       |
  304|    430|	memcpy(gakp, cvcpo, taglen);
  305|    430|	cvcpo = gakp + taglen;
  306|       |
  307|    430|	if (key_info->aux_data && key_info->aux_data->type == SC_AUX_DATA_TYPE_PROP_KEY_GEN_PARAM) {
  ------------------
  |  |   37|      0|#define SC_AUX_DATA_TYPE_PROP_KEY_GEN_PARAM 0x02
  ------------------
  |  Branch (307:6): [True: 0, False: 430]
  |  Branch (307:28): [True: 0, False: 0]
  ------------------
  308|      0|		keygen_data = (sc_hsm_keygen_data_t *)key_info->aux_data->data.proprietary_key_gen_params;
  309|       |
  310|      0|		if (keygen_data->key_use_counter) {
  ------------------
  |  Branch (310:7): [True: 0, False: 0]
  ------------------
  311|      0|			if (taglen + 6 > sizeof(gakp)) {
  ------------------
  |  Branch (311:8): [True: 0, False: 0]
  ------------------
  312|      0|				r = SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  313|      0|				goto out;
  314|      0|			}
  315|      0|			*cvcpo++ = 0x90;
  316|      0|			*cvcpo++ = 0x04;
  317|       |
  318|      0|			*cvcpo++ = (u8)(keygen_data->key_use_counter >> 24);
  319|      0|			*cvcpo++ = (u8)(keygen_data->key_use_counter >> 16);
  320|      0|			*cvcpo++ = (u8)(keygen_data->key_use_counter >> 8);
  321|      0|			*cvcpo++ = (u8)keygen_data->key_use_counter;
  322|      0|			taglen += 6;
  323|      0|		}
  324|       |
  325|      0|		if (keygen_data->key_algorithms) {
  ------------------
  |  Branch (325:7): [True: 0, False: 0]
  ------------------
  326|      0|			if (taglen + 2 + keygen_data->key_algorithms_len > sizeof(gakp)) {
  ------------------
  |  Branch (326:8): [True: 0, False: 0]
  ------------------
  327|      0|				r = SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  328|      0|				goto out;
  329|      0|			}
  330|      0|			*cvcpo++ = 0x91;
  331|      0|			*cvcpo++ = (u8)keygen_data->key_algorithms_len;
  332|      0|			memcpy(cvcpo, keygen_data->key_algorithms, keygen_data->key_algorithms_len);
  333|      0|			cvcpo += keygen_data->key_algorithms_len;
  334|      0|			taglen += 2 + keygen_data->key_algorithms_len;
  335|      0|		}
  336|       |
  337|      0|		if (keygen_data->key_domain) {
  ------------------
  |  Branch (337:7): [True: 0, False: 0]
  ------------------
  338|      0|			if (taglen + 3 > sizeof(gakp)) {
  ------------------
  |  Branch (338:8): [True: 0, False: 0]
  ------------------
  339|      0|				r = SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  340|      0|				goto out;
  341|      0|			}
  342|      0|			*cvcpo++ = 0x92;
  343|      0|			*cvcpo++ = 0x01;
  344|      0|			*cvcpo++ = (u8)(keygen_data->key_domain - 1);
  345|      0|			taglen += 3;
  346|      0|		}
  347|      0|	}
  348|       |
  349|    430|	sc_hsm_keyinfo.key_id = key_info->key_reference;
  350|    430|	sc_hsm_keyinfo.auth_key_id = 0;
  351|    430|	sc_hsm_keyinfo.gakprequest = gakp;
  352|    430|	sc_hsm_keyinfo.gakprequest_len = taglen;
  353|    430|	sc_hsm_keyinfo.gakpresponse = NULL;
  354|    430|	sc_hsm_keyinfo.gakpresponse_len = 0;
  355|       |
  356|    430|	r = sc_card_ctl(card, SC_CARDCTL_SC_HSM_GENERATE_KEY, &sc_hsm_keyinfo);
  357|    430|	if (r < 0)
  ------------------
  |  Branch (357:6): [True: 409, False: 21]
  ------------------
  358|    409|		goto out;
  359|       |
  360|       |
  361|     21|	cvcpo = sc_hsm_keyinfo.gakpresponse;
  362|     21|	cvclen = sc_hsm_keyinfo.gakpresponse_len;
  363|       |
  364|     21|	r = sc_pkcs15emu_sc_hsm_decode_cvc(p15card, (const u8 **)&cvcpo, &cvclen, &cvc);
  365|     21|	if (r < 0) {
  ------------------
  |  Branch (365:6): [True: 21, False: 0]
  ------------------
  366|     21|		sc_log(p15card->card->ctx, "Could not decode GAKP rdata");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  367|     21|		r = SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|     21|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  368|     21|		goto out;
  369|     21|	}
  370|       |
  371|      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 */
  ------------------
  372|      0|	if (r < 0) {
  ------------------
  |  Branch (372:6): [True: 0, False: 0]
  ------------------
  373|      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__
  |  |  ------------------
  ------------------
  374|      0|		goto out;
  375|      0|	}
  376|       |
  377|      0|	if (pubkey != NULL) {
  ------------------
  |  Branch (377:6): [True: 0, False: 0]
  ------------------
  378|      0|		sc_pkcs15_erase_pubkey(pubkey);
  379|      0|		memset(pubkey, 0, sizeof *pubkey);
  380|      0|		r = sc_pkcs15emu_sc_hsm_get_public_key(p15card->card->ctx, &cvc, pubkey);
  381|      0|	}
  382|       |
  383|    430|	out:
  384|       |
  385|    430|	sc_pkcs15emu_sc_hsm_free_cvc(&cvc);
  386|       |
  387|    430|	if (cvcbin) {
  ------------------
  |  Branch (387:6): [True: 430, False: 0]
  ------------------
  388|    430|		free(cvcbin);
  389|    430|	}
  390|    430|	if (sc_hsm_keyinfo.gakpresponse) {
  ------------------
  |  Branch (390:6): [True: 21, False: 409]
  ------------------
  391|     21|		free(sc_hsm_keyinfo.gakpresponse);
  392|     21|	}
  393|    430|	LOG_FUNC_RETURN(p15card->card->ctx, r);
  ------------------
  |  |  164|    430|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    430|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    430|	int _ret = r; \
  |  |  |  |  155|    430|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 430, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    430|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    430|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 430, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    430|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    430|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    430|	return _ret; \
  |  |  |  |  163|    430|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  394|    430|}
pkcs15-sc-hsm.c:sc_hsm_determine_free_id:
  132|    668|{
  133|    668|	struct sc_card *card = p15card->card;
  134|    668|	u8 filelist[MAX_EXT_APDU_LENGTH];
  135|    668|	int filelistlength, i, j;
  136|       |
  137|    668|	LOG_FUNC_CALLED(p15card->card->ctx);
  ------------------
  |  |  151|    668|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    668|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    668|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    668|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 668]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  138|       |
  139|    668|	filelistlength = sc_list_files(card, filelist, sizeof(filelist));
  140|    668|	LOG_TEST_RET(card->ctx, filelistlength, "Could not enumerate file and key identifier");
  ------------------
  |  |  174|    668|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    668|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    668|	int _ret = (r); \
  |  |  |  |  168|    668|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 4, False: 664]
  |  |  |  |  ------------------
  |  |  |  |  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|    668|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 664]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  141|       |
  142|  8.10k|	for (j = 0; j < 256; j++) {
  ------------------
  |  Branch (142:14): [True: 8.07k, False: 29]
  ------------------
  143|   221k|		for (i = 0; i + 1 < filelistlength; i += 2) {
  ------------------
  |  Branch (143:15): [True: 213k, False: 8.01k]
  ------------------
  144|   213k|			if ((filelist[i] == range) && (filelist[i + 1] == j)) {
  ------------------
  |  Branch (144:8): [True: 25.7k, False: 187k]
  |  Branch (144:34): [True: 59, False: 25.6k]
  ------------------
  145|     59|				break;
  146|     59|			}
  147|   213k|		}
  148|  8.07k|		if (i >= filelistlength) {
  ------------------
  |  Branch (148:7): [True: 635, False: 7.43k]
  ------------------
  149|    635|			LOG_FUNC_RETURN(p15card->card->ctx, j);
  ------------------
  |  |  164|    635|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    635|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    635|	int _ret = r; \
  |  |  |  |  155|    635|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 625, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  156|    625|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 625]
  |  |  |  |  ------------------
  |  |  |  |  157|    625|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    625|	} 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|    635|	return _ret; \
  |  |  |  |  163|    635|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  150|    635|		}
  151|  8.07k|	}
  152|     29|	LOG_FUNC_RETURN(p15card->card->ctx, SC_ERROR_NOT_ENOUGH_MEMORY);
  ------------------
  |  |  164|     29|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     29|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     29|	int _ret = r; \
  |  |  |  |  155|     29|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 29, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     29|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     29|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 29, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     29|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     29|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     29|	return _ret; \
  |  |  |  |  163|     29|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  153|     29|}
pkcs15-sc-hsm.c:sc_hsm_encode_gakp_rsa:
  157|    216|static int sc_hsm_encode_gakp_rsa(struct sc_pkcs15_card *p15card, sc_cvc_t *cvc, size_t keysize) {
  158|    216|	struct sc_object_id rsa15withSHA256 = { { 0,4,0,127,0,7,2,2,2,1,2,-1 } };
  159|       |
  160|    216|	LOG_FUNC_CALLED(p15card->card->ctx);
  ------------------
  |  |  151|    216|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    216|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    216|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    216|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 216]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  161|       |
  162|    216|	cvc->coefficientAorExponentlen = sizeof(pubexp);
  163|    216|	cvc->coefficientAorExponent = malloc(sizeof(pubexp));
  164|    216|	if (!cvc->coefficientAorExponent) {
  ------------------
  |  Branch (164:6): [True: 0, False: 216]
  ------------------
  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|    216|	memcpy(cvc->coefficientAorExponent, pubexp, sizeof(pubexp));
  168|       |
  169|    216|	cvc->pukoid = rsa15withSHA256;
  170|    216|	cvc->modulusSize = (int)keysize;
  171|       |
  172|    216|	LOG_FUNC_RETURN(p15card->card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    216|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    216|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    216|	int _ret = r; \
  |  |  |  |  155|    216|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 216, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    216|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 216]
  |  |  |  |  ------------------
  |  |  |  |  157|    216|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    216|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    216|	return _ret; \
  |  |  |  |  163|    216|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  173|    216|}
pkcs15-sc-hsm.c:sc_hsm_encode_gakp_ec:
  177|    214|static int sc_hsm_encode_gakp_ec(struct sc_pkcs15_card *p15card, sc_cvc_t *cvc, struct sc_pkcs15_prkey_info *key_info) {
  178|    214|	struct sc_object_id ecdsaWithSHA256 = { { 0,4,0,127,0,7,2,2,2,2,3,-1 } };
  179|    214|	struct sc_ec_parameters *ecparams = (struct sc_ec_parameters *)key_info->params.data;
  180|    214|	struct ec_curve *curve = NULL;
  181|    214|	u8 *curveoid;
  182|    214|	int curveoidlen,r;
  183|       |
  184|    214|	LOG_FUNC_CALLED(p15card->card->ctx);
  ------------------
  |  |  151|    214|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    214|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    214|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    214|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 214]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  185|       |
  186|    214|	curveoid = ecparams->der.value;
  187|    214|	if ((ecparams->der.len < 3) || (*curveoid++ != 0x06)) {
  ------------------
  |  Branch (187:6): [True: 0, False: 214]
  |  Branch (187:33): [True: 0, False: 214]
  ------------------
  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|    214|	curveoidlen = *curveoid++;
  193|       |
  194|    214|	r = sc_pkcs15emu_sc_hsm_get_curve(&curve, curveoid, curveoidlen);
  195|    214|	LOG_TEST_RET(p15card->card->ctx, r, "Unsupported named curve");
  ------------------
  |  |  174|    214|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    214|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    214|	int _ret = (r); \
  |  |  |  |  168|    214|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 214]
  |  |  |  |  ------------------
  |  |  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      0|		return _ret; \
  |  |  |  |  172|      0|	} \
  |  |  |  |  173|    214|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 214]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  196|       |
  197|    214|	cvc->primeOrModuluslen = curve->prime.len;
  198|    214|	cvc->primeOrModulus = malloc(cvc->primeOrModuluslen);
  199|    214|	if (!cvc->primeOrModulus) {
  ------------------
  |  Branch (199:6): [True: 0, False: 214]
  ------------------
  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|    214|	memcpy(cvc->primeOrModulus, curve->prime.value, cvc->primeOrModuluslen);
  203|       |
  204|    214|	cvc->coefficientAorExponentlen = curve->coefficientA.len;
  205|    214|	cvc->coefficientAorExponent = malloc(cvc->coefficientAorExponentlen);
  206|    214|	if (!cvc->coefficientAorExponent) {
  ------------------
  |  Branch (206:6): [True: 0, False: 214]
  ------------------
  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|    214|	memcpy(cvc->coefficientAorExponent, curve->coefficientA.value, cvc->coefficientAorExponentlen);
  210|       |
  211|    214|	cvc->coefficientBlen = curve->coefficientB.len;
  212|    214|	cvc->coefficientB = malloc(cvc->coefficientBlen);
  213|    214|	if (!cvc->coefficientB) {
  ------------------
  |  Branch (213:6): [True: 0, False: 214]
  ------------------
  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|    214|	memcpy(cvc->coefficientB, curve->coefficientB.value, cvc->coefficientBlen);
  217|       |
  218|    214|	cvc->basePointGlen = curve->basePointG.len;
  219|    214|	cvc->basePointG = malloc(cvc->basePointGlen);
  220|    214|	if (!cvc->basePointG) {
  ------------------
  |  Branch (220:6): [True: 0, False: 214]
  ------------------
  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|    214|	memcpy(cvc->basePointG, curve->basePointG.value, cvc->basePointGlen);
  224|       |
  225|    214|	cvc->orderlen = curve->order.len;
  226|    214|	cvc->order = malloc(cvc->orderlen);
  227|    214|	if (!cvc->order) {
  ------------------
  |  Branch (227:6): [True: 0, False: 214]
  ------------------
  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|    214|	memcpy(cvc->order, curve->order.value, cvc->orderlen);
  231|       |
  232|    214|	cvc->cofactorlen = curve->coFactor.len;
  233|    214|	cvc->cofactor = malloc(cvc->cofactorlen);
  234|    214|	if (!cvc->cofactor) {
  ------------------
  |  Branch (234:6): [True: 0, False: 214]
  ------------------
  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|    214|	memcpy(cvc->cofactor, curve->coFactor.value, cvc->cofactorlen);
  238|       |
  239|    214|	cvc->pukoid = ecdsaWithSHA256;
  240|       |
  241|    214|	LOG_FUNC_RETURN(p15card->card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  242|    214|}
pkcs15-sc-hsm.c:sc_hsm_update_ef:
   74|    223|{
   75|    223|	sc_card_t *card = p15card->card;
   76|    223|	sc_file_t *file = NULL;
   77|    223|	sc_path_t path;
   78|    223|	u8 fid[2];
   79|    223|	int r;
   80|       |
   81|    223|	fid[0] = prefix;
   82|    223|	fid[1] = id;
   83|       |
   84|    223|	sc_path_set(&path, SC_PATH_TYPE_FILE_ID, fid, 2, 0, -1);
  ------------------
  |  |  117|    223|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
   85|       |
   86|    223|	r = sc_select_file(card, &path, NULL);
   87|       |
   88|    223|	if ((r == SC_SUCCESS) && erase) {
  ------------------
  |  |   28|    223|#define SC_SUCCESS				0
  ------------------
  |  Branch (88:6): [True: 9, False: 214]
  |  Branch (88:27): [True: 7, False: 2]
  ------------------
   89|      7|		r = sc_delete_file(card, &path);
   90|      7|		LOG_TEST_RET(card->ctx, r, "Could not delete 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: 3, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  169|      3|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      3|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      3|		return _ret; \
  |  |  |  |  172|      3|	} \
  |  |  |  |  173|      7|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   91|      4|		r = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|      4|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
   92|      4|	}
   93|       |
   94|    220|	if (r == SC_ERROR_FILE_NOT_FOUND) {
  ------------------
  |  |   51|    220|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (94:6): [True: 4, False: 216]
  ------------------
   95|      4|		file = sc_file_new();
   96|      4|		file->id = (path.value[0] << 8) | path.value[1];
   97|      4|		file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|      4|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
   98|      4|		file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|      4|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
   99|      4|		file->size = (size_t) 0;
  100|      4|		file->status = SC_FILE_STATUS_ACTIVATED;
  ------------------
  |  |  236|      4|#define SC_FILE_STATUS_ACTIVATED	0x00 /* ISO7816-4: Operational state (activated)   (5, 7) */
  ------------------
  101|      4|		r = sc_create_file(card, file);
  102|      4|		sc_file_free(file);
  103|      4|		LOG_TEST_RET(card->ctx, r, "Could not create 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  104|      4|	}
  105|       |
  106|    220|	r = sc_update_binary(card, 0, buf, buflen, 0);
  107|    220|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    220|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    220|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    220|	int _ret = r; \
  |  |  |  |  155|    220|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 220]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    220|	} else { \
  |  |  |  |  159|    220|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    220|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    220|	} \
  |  |  |  |  162|    220|	return _ret; \
  |  |  |  |  163|    220|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  108|    220|}
pkcs15-sc-hsm.c:sc_hsm_emu_update_any_df:
  622|     50|{
  623|     50|	struct sc_context *ctx = p15card->card->ctx;
  624|     50|	int rv = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|     50|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  625|       |
  626|     50|	SC_FUNC_CALLED(ctx, 1);
  ------------------
  |  |  148|     50|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     50|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     50|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 50]
  |  |  ------------------
  ------------------
  627|     50|	switch(op)   {
  ------------------
  |  Branch (627:9): [True: 50, False: 0]
  ------------------
  628|      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 (628:2): [True: 0, False: 50]
  ------------------
  629|      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__
  |  |  ------------------
  ------------------
  630|      0|		switch(object->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|      0|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  |  Branch (630:10): [True: 0, False: 0]
  ------------------
  631|      0|		case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|      0|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (631:3): [True: 0, False: 0]
  ------------------
  632|      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 */
  ------------------
  633|      0|			break;
  634|      0|		case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|      0|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (634:3): [True: 0, False: 0]
  ------------------
  635|      0|			rv = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  636|      0|			break;
  637|      0|		case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (637:3): [True: 0, False: 0]
  ------------------
  638|      0|			rv = sc_hsm_emu_delete_cd(profile, p15card, object);
  639|      0|			break;
  640|      0|		case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|      0|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (640:3): [True: 0, False: 0]
  ------------------
  641|      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 */
  ------------------
  642|      0|			break;
  643|      0|		}
  644|      0|		break;
  645|      0|	case SC_AC_OP_UPDATE:
  ------------------
  |  |  189|      0|#define SC_AC_OP_UPDATE			23
  ------------------
  |  Branch (645:2): [True: 0, False: 50]
  ------------------
  646|     50|	case SC_AC_OP_CREATE:
  ------------------
  |  |  169|     50|#define SC_AC_OP_CREATE			3
  ------------------
  |  Branch (646:2): [True: 50, False: 0]
  ------------------
  647|     50|		sc_log(ctx, "Update DF; create object('%s',type:%X)", object->label, object->type);
  ------------------
  |  |   71|     50|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  648|     50|		switch(object->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|     50|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  |  Branch (648:10): [True: 48, False: 2]
  ------------------
  649|      0|		case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|      0|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (649:3): [True: 0, False: 50]
  ------------------
  650|      0|			rv = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  651|      0|			break;
  652|      0|		case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|      0|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (652:3): [True: 0, False: 50]
  ------------------
  653|      0|			rv = sc_hsm_emu_update_prkd(profile, p15card, object);
  654|      0|			break;
  655|      0|		case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (655:3): [True: 0, False: 50]
  ------------------
  656|      0|			rv = sc_hsm_emu_update_cd(profile, p15card, object);
  657|      0|			break;
  658|     48|		case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|     48|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (658:3): [True: 48, False: 2]
  ------------------
  659|     48|			rv = sc_hsm_emu_update_dcod(profile, p15card, object);
  660|     48|			break;
  661|     50|		}
  662|     50|		break;
  663|     50|	}
  664|     50|	SC_FUNC_RETURN(ctx, 1, rv);
  ------------------
  |  |  153|     50|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|     50|	int _ret = r; \
  |  |  155|     50|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 32, False: 18]
  |  |  ------------------
  |  |  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|     18|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|     18|			"returning with: %d\n", _ret); \
  |  |  161|     18|	} \
  |  |  162|     50|	return _ret; \
  |  |  163|     50|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  665|     50|}
pkcs15-sc-hsm.c:sc_hsm_emu_update_dcod:
  564|     48|{
  565|     48|	struct sc_pkcs15_data_info *data_info = (struct sc_pkcs15_data_info *) object->data;
  566|     48|	u8 *buf;
  567|     48|	size_t buflen;
  568|     48|	int r;
  569|       |
  570|     48|	r = sc_pkcs15_encode_dodf_entry(p15card->card->ctx, object, &buf, &buflen);
  571|     48|	LOG_TEST_RET(p15card->card->ctx, r, "Error encoding DCOD entry");
  ------------------
  |  |  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: 30, False: 18]
  |  |  |  |  ------------------
  |  |  |  |  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|     48|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 18]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  572|       |
  573|     18|	r = sc_hsm_update_ef(p15card, DCOD_PREFIX, data_info->path.value[data_info->path.len - 1], 0, buf, buflen);
  ------------------
  |  |   31|     18|#define DCOD_PREFIX		0xC9		/* Hi byte in file identifier for PKCS#15 DCOD objects */
  ------------------
  574|     18|	free(buf);
  575|     18|	return r;
  576|     48|}
pkcs15-sc-hsm.c:sc_hsm_emu_store_data:
  483|    224|{
  484|    224|	struct sc_context *ctx = p15card->card->ctx;
  485|    224|	int r;
  486|       |
  487|    224|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    224|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    224|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    224|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    224|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 224]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  488|       |
  489|    224|	switch (object->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|    224|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  490|      0|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|      0|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (490:2): [True: 0, False: 224]
  ------------------
  491|      0|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|      0|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (491:2): [True: 0, False: 224]
  ------------------
  492|      0|		r = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  493|      0|		break;
  494|      0|	case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (494:2): [True: 0, False: 224]
  ------------------
  495|      0|		r = sc_hsm_emu_store_cert(p15card, profile, object, data);
  496|      0|		break;
  497|    224|	case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|    224|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (497:2): [True: 224, False: 0]
  ------------------
  498|    224|		r = sc_hsm_emu_store_binary(p15card, profile, object, data);
  499|    224|		break;
  500|      0|	default:
  ------------------
  |  Branch (500:2): [True: 0, False: 224]
  ------------------
  501|      0|		r = SC_ERROR_NOT_IMPLEMENTED;
  ------------------
  |  |   97|      0|#define SC_ERROR_NOT_IMPLEMENTED		-1416
  ------------------
  502|      0|		break;
  503|    224|	}
  504|       |
  505|    224|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  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: 22, False: 202]
  |  |  |  |  ------------------
  |  |  |  |  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|    202|	} else { \
  |  |  |  |  159|    202|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    202|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    202|	} \
  |  |  |  |  162|    224|	return _ret; \
  |  |  |  |  163|    224|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  506|    224|}
pkcs15-sc-hsm.c:sc_hsm_emu_store_binary:
  454|    224|{
  455|    224|	struct sc_pkcs15_data_info *data_info = (struct sc_pkcs15_data_info *) object->data;
  456|    224|	sc_path_t path;
  457|    224|	u8 id[2];
  458|    224|	int r;
  459|       |
  460|    224|	r = sc_hsm_determine_free_id(p15card, DCOD_PREFIX);
  ------------------
  |  |   31|    224|#define DCOD_PREFIX		0xC9		/* Hi byte in file identifier for PKCS#15 DCOD objects */
  ------------------
  461|    224|	LOG_TEST_RET(p15card->card->ctx, r, "Out of identifier to store data description");
  ------------------
  |  |  174|    224|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    224|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    224|	int _ret = (r); \
  |  |  |  |  168|    224|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 19, False: 205]
  |  |  |  |  ------------------
  |  |  |  |  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|    224|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 205]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  462|       |
  463|    205|	if (object->flags & SC_PKCS15_CO_FLAG_PRIVATE) {
  ------------------
  |  |   50|    205|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  |  Branch (463:6): [True: 0, False: 205]
  ------------------
  464|      0|		id[0] = PROT_DATA_PREFIX;
  ------------------
  |  |   34|      0|#define PROT_DATA_PREFIX	0xCD		/* Hi byte in file identifier for PIN protected data objects */
  ------------------
  465|    205|	} else {
  466|    205|		id[0] = DATA_PREFIX;
  ------------------
  |  |   36|    205|#define DATA_PREFIX		0xCF		/* Hi byte in file identifier for readable data objects */
  ------------------
  467|    205|	}
  468|    205|	id[1] = r;
  469|       |
  470|    205|	sc_path_set(&path, SC_PATH_TYPE_FILE_ID, id, 2, 0, -1);
  ------------------
  |  |  117|    205|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  471|    205|	data_info->path = path;
  472|       |
  473|    205|	r = sc_hsm_update_ef(p15card, id[0], id[1], 1, data->value, data->len);
  474|    205|	return r;
  475|    224|}

sc_pkcs15init_get_setcos_ops:
  633|    527|{
  634|    527|	return &sc_pkcs15init_setcos_operations;
  635|    527|}
pkcs15-setcos.c:setcos_erase_card:
   67|    150|{
   68|    150|	sc_path_t path;
   69|    150|	int r;
   70|       |
   71|       |	/* Just delete the entire MF */
   72|       |
   73|       |	/* Select parent DF and verify PINs/key as necessary */
   74|    150|	r = sc_pkcs15init_authenticate(profile, p15card, profile->mf_info->file, SC_AC_OP_DELETE);
  ------------------
  |  |  168|    150|#define SC_AC_OP_DELETE			2
  ------------------
   75|    150|	if (r < 0)
  ------------------
  |  Branch (75:6): [True: 96, False: 54]
  ------------------
   76|     96|		return r == SC_ERROR_FILE_NOT_FOUND ? 0 : r;
  ------------------
  |  |   51|     96|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (76:10): [True: 1, False: 95]
  ------------------
   77|       |
   78|       |	/* Empty path -> we have to to delete the current DF (= the MF) */
   79|     54|	memset(&path, 0, sizeof(sc_path_t));
   80|     54|	r = sc_delete_file(p15card->card, &path) ;
   81|     54|	if (r)
  ------------------
  |  Branch (81:6): [True: 49, False: 5]
  ------------------
   82|     49|		return r;
   83|       |
   84|      5|	sc_free_apps(p15card->card);
   85|      5|	return 0;
   86|     54|}
pkcs15-setcos.c:setcos_init_card:
   94|    128|{
   95|    128|	struct sc_context *ctx = p15card->card->ctx;
   96|    128|	sc_file_t *mf = profile->mf_info->file;
   97|    128|	sc_file_t *pinfile;
   98|    128|	int r;
   99|       |
  100|    128|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  101|       |
  102|       |	/* Create the MF if it doesn't exist yet */
  103|    128|	r = sc_select_file(p15card->card, &mf->path, NULL);
  104|    128|	if (r == SC_ERROR_FILE_NOT_FOUND) {
  ------------------
  |  |   51|    128|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (104:6): [True: 122, False: 6]
  ------------------
  105|    122|		sc_log(ctx,  "MF doesn't exist, creating now");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  106|       |
  107|       |		/* Fix up the file's ACLs */
  108|    122|		r = sc_pkcs15init_fixup_file(profile, p15card, mf);
  109|    122|		LOG_TEST_RET(ctx, r, "MF fixup failed");
  ------------------
  |  |  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: 24, False: 98]
  |  |  |  |  ------------------
  |  |  |  |  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|    122|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 98]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  110|       |
  111|     98|		mf->status = SC_FILE_STATUS_CREATION;
  ------------------
  |  |  240|     98|#define SC_FILE_STATUS_CREATION		0x02 /* ISO7816-4: Creation state, (1) */
  ------------------
  112|     98|		r = sc_create_file(p15card->card, mf);
  113|     98|		LOG_TEST_RET(ctx, r, "MF creation 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: 91, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  169|     91|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     91|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     91|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     91|		return _ret; \
  |  |  |  |  172|     91|	} \
  |  |  |  |  173|     98|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  114|     98|	}
  115|     13|	LOG_TEST_RET(ctx, r, "Cannot select MF");
  ------------------
  |  |  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: 5, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  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|     13|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  116|       |
  117|       |	/* Create the global pin file if it doesn't exist yet */
  118|      8|	r = sc_profile_get_file(profile, "pinfile", &pinfile);
  119|      8|	LOG_TEST_RET(ctx, r, "Cannot get 'pinfile' from profile");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  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|    324|{
  173|    324|	sc_pkcs15_auth_info_t auth_info_prof = {0};
  174|       |
  175|    324|	auth_info_prof.attrs.pin.reference = 1; /* Default SO PIN ref. */
  176|    324|	auth_info_prof.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|    324|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  177|    324|	sc_profile_get_pin_info(profile, SC_PKCS15INIT_SO_PIN, &auth_info_prof);
  ------------------
  |  |  169|    324|#define SC_PKCS15INIT_SO_PIN		0
  ------------------
  178|       |
  179|       |	/* For the SO pin, we take the first available pin reference = 1 */
  180|    324|	if (auth_info != NULL && auth_info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN)
  ------------------
  |  |   61|    324|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (180:6): [True: 324, False: 0]
  |  Branch (180:27): [True: 19, False: 305]
  ------------------
  181|     19|		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|    305|	else if (auth_info != NULL && auth_info->attrs.pin.reference <= 0) {
  ------------------
  |  Branch (185:11): [True: 305, False: 0]
  |  Branch (185:32): [True: 173, False: 132]
  ------------------
  186|    173|		if (auth_info_prof.attrs.pin.reference != 1)
  ------------------
  |  Branch (186:7): [True: 166, False: 7]
  ------------------
  187|    166|			return SC_ERROR_INVALID_PIN_REFERENCE;
  ------------------
  |  |  111|    166|#define SC_ERROR_INVALID_PIN_REFERENCE		-1509
  ------------------
  188|      7|		auth_info->attrs.pin.reference = auth_info_prof.attrs.pin.reference + 1;
  189|      7|	}
  190|       |
  191|    158|	return SC_SUCCESS;
  ------------------
  |  |   28|    158|#define SC_SUCCESS				0
  ------------------
  192|    324|}
pkcs15-setcos.c:setcos_create_pin:
  203|     13|{
  204|     13|	struct sc_context *ctx = p15card->card->ctx;
  205|     13|	sc_pkcs15_auth_info_t *auth_info = (sc_pkcs15_auth_info_t *) pin_obj->data;
  206|     13|	sc_file_t *pinfile = NULL, *tmp_pinfile = NULL;
  207|     13|	int r, ignore_ac = 0;
  208|       |
  209|     13|	SC_FUNC_CALLED(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]
  |  |  ------------------
  ------------------
  210|       |
  211|     13|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|     13|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (211:6): [True: 0, False: 13]
  ------------------
  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|     13|	r = sc_profile_get_file(profile, "pinfile", &tmp_pinfile);
  216|     13|	LOG_TEST_RET(ctx, r, "No 'pinfile' template in profile");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  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|    541|{
  332|    541|	struct sc_context *ctx = p15card->card->ctx;
  333|    541|	struct sc_pkcs15_prkey_info *key_info = (struct sc_pkcs15_prkey_info *)object->data;
  334|    541|	struct sc_file *file = NULL;
  335|    541|	size_t keybits = key_info->modulus_length;
  336|    541|	int r;
  337|       |
  338|    541|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    541|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    541|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    541|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 541]
  |  |  ------------------
  ------------------
  339|    541|	if (object->type != SC_PKCS15_TYPE_PRKEY_RSA)
  ------------------
  |  |  419|    541|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (339:6): [True: 441, False: 100]
  ------------------
  340|    541|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Create key failed: RSA only supported");
  ------------------
  |  |  174|    441|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    441|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    441|	int _ret = (r); \
  |  |  |  |  168|    441|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 441, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    441|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    441|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    441|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    441|		return _ret; \
  |  |  |  |  172|    441|	} \
  |  |  |  |  173|    441|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  341|       |
  342|       |	/* Parameter check */
  343|    100|	if ((keybits < 512) || (keybits > 1024) || (keybits & 0x7))
  ------------------
  |  Branch (343:6): [True: 0, False: 100]
  |  Branch (343:25): [True: 0, False: 100]
  |  Branch (343:45): [True: 0, False: 100]
  ------------------
  344|    100|		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|    100|	sc_log(ctx,  "create private key ID:%s\n",  sc_pkcs15_print_id(&key_info->id));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  347|       |
  348|       |	/* Get the private key file */
  349|    100|	r = setcos_new_file(profile, p15card->card, SC_PKCS15_TYPE_PRKEY_RSA, key_info->key_reference, &file);
  ------------------
  |  |  419|    100|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  350|    100|	LOG_TEST_RET(ctx, r, "Cannot get new private key file");
  ------------------
  |  |  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: 40, False: 60]
  |  |  |  |  ------------------
  |  |  |  |  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|    100|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 60]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  351|       |
  352|       |	/* Take enough room for a 1024 bit key */
  353|     60|	if (file->size < 512)
  ------------------
  |  Branch (353:6): [True: 60, False: 0]
  ------------------
  354|     60|		file->size = 512;
  355|       |
  356|       |	/* Replace the path of instantiated key template by the path from the object data. */
  357|     60|	memcpy(&file->path, &key_info->path, sizeof(file->path));
  358|     60|	if (file->path.len < 2) {
  ------------------
  |  Branch (358:6): [True: 14, False: 46]
  ------------------
  359|     14|		sc_file_free(file);
  360|     14|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid path");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  361|     14|	}
  362|     46|	file->id = file->path.value[file->path.len - 2] * 0x100
  363|     46|			+ file->path.value[file->path.len - 1];
  364|       |
  365|     46|	key_info->key_reference = file->path.value[file->path.len - 1] & 0xFF;
  366|       |
  367|     46|	sc_log(ctx,  "Path of private key file to create %s\n", sc_print_path(&file->path));
  ------------------
  |  |   71|     46|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  368|       |
  369|     46|	r = sc_select_file(p15card->card, &file->path, NULL);
  370|     46|	if (!r) {
  ------------------
  |  Branch (370:6): [True: 31, False: 15]
  ------------------
  371|     31|		r = sc_pkcs15init_delete_by_path(profile, p15card, &file->path);
  372|     31|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|     31|#define SC_SUCCESS				0
  ------------------
  |  Branch (372:7): [True: 4, False: 27]
  ------------------
  373|      4|			sc_file_free(file);
  374|     31|		LOG_TEST_RET(ctx, r, "Failed to delete private key file");
  ------------------
  |  |  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: 4, False: 27]
  |  |  |  |  ------------------
  |  |  |  |  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|     31|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 27]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  375|     31|	} else if (r != SC_ERROR_FILE_NOT_FOUND) {
  ------------------
  |  |   51|     15|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (375:13): [True: 4, False: 11]
  ------------------
  376|      4|		sc_file_free(file);
  377|      4|		file = NULL;
  378|      4|		LOG_TEST_RET(ctx, r, "Select private key 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  379|      4|	}
  380|       |
  381|       |	/* Now create the key file */
  382|     38|	r = sc_pkcs15init_create_file(profile, p15card, file);
  383|     38|	sc_file_free(file);
  384|     38|	LOG_TEST_RET(ctx, r, "Cannot create private key file");
  ------------------
  |  |  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: 15, False: 23]
  |  |  |  |  ------------------
  |  |  |  |  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|     38|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 23]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  385|       |
  386|     23|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|     23|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     23|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     23|	int _ret = r; \
  |  |  |  |  155|     23|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 23, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     23|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 23]
  |  |  |  |  ------------------
  |  |  |  |  157|     23|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     23|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     23|	return _ret; \
  |  |  |  |  163|     23|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  387|     23|}
pkcs15-setcos.c:setcos_new_file:
  260|    100|{
  261|    100|	sc_file_t *file = NULL;
  262|    100|	sc_path_t *p;
  263|    100|	char name[64];
  264|    100|	const char *tag;
  265|    100|	int r;
  266|       |
  267|    100|	if (type == SC_PKCS15_TYPE_PRKEY_RSA)
  ------------------
  |  |  419|    100|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (267:6): [True: 100, False: 0]
  ------------------
  268|    100|		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|    100|	snprintf(name, sizeof(name), "template-%s", tag);
  282|    100|	if (sc_profile_get_file(profile, name, &file) < 0) {
  ------------------
  |  Branch (282:6): [True: 39, False: 61]
  ------------------
  283|     39|		sc_log(card->ctx,  "Profile doesn't define %s", name);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  284|     39|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|     39|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  285|     39|	}
  286|       |
  287|       |	/* Auto-increment FID for next object */
  288|     61|	file->id += num;
  289|     61|	p = &file->path;
  290|     61|	*p = profile->df_info->file->path;
  291|     61|	if (p->len + 2 > SC_MAX_PATH_SIZE) {
  ------------------
  |  |   47|     61|#define SC_MAX_PATH_SIZE		16
  ------------------
  |  Branch (291:6): [True: 1, False: 60]
  ------------------
  292|      1|		sc_file_free(file);
  293|      1|		return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      1|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  294|      1|	}
  295|     60|	p->value[p->len++] = (u8) (file->id / 256);
  296|     60|	p->value[p->len++] = (u8) (file->id % 256);
  297|       |
  298|       |	/* Increment FID until there's no file with such path */
  299|     60|	r = sc_select_file(card, p, NULL);
  300|    470|	while(r == 0) {
  ------------------
  |  Branch (300:8): [True: 410, False: 60]
  ------------------
  301|    410|		file->id++;
  302|    410|		p->value[p->len - 2] = (u8) (file->id / 256);
  303|    410|		p->value[p->len - 1] = (u8) (file->id % 256);
  304|    410|		r = sc_select_file(card, p, NULL);
  305|    410|	}
  306|       |
  307|     60|	*out = file;
  308|     60|	return 0;
  309|     61|}
pkcs15-setcos.c:setcos_generate_key:
  447|     23|{
  448|     23|	struct sc_context *ctx = p15card->card->ctx;
  449|     23|	struct sc_cardctl_setcos_gen_store_key_info args;
  450|     23|	struct sc_cardctl_setcos_data_obj data_obj;
  451|     23|	struct sc_pkcs15_prkey_info *key_info = (struct sc_pkcs15_prkey_info *)object->data;
  452|     23|	int r;
  453|     23|	size_t keybits = key_info->modulus_length;
  454|     23|	unsigned char raw_pubkey[256];
  455|     23|	struct sc_file *file = NULL;
  456|       |
  457|     23|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  458|     23|	if (object->type != SC_PKCS15_TYPE_PRKEY_RSA)
  ------------------
  |  |  419|     23|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (458:6): [True: 0, False: 23]
  ------------------
  459|     23|		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|     23|	if ( (keybits < 512) || (keybits > 1024) || (keybits & 0x7))
  ------------------
  |  Branch (462:7): [True: 0, False: 23]
  |  Branch (462:26): [True: 0, False: 23]
  |  Branch (462:46): [True: 0, False: 23]
  ------------------
  463|     23|		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|     23|	r = sc_select_file(p15card->card, &key_info->path, &file);
  466|     23|	LOG_TEST_RET(ctx, r, "Cannot store key: select key file failed");
  ------------------
  |  |  174|     23|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     23|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     23|	int _ret = (r); \
  |  |  |  |  168|     23|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 21]
  |  |  |  |  ------------------
  |  |  |  |  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|     23|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 21]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  467|       |
  468|       |	/* Authenticate */
  469|     21|	r = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_UPDATE);
  ------------------
  |  |  189|     21|#define SC_AC_OP_UPDATE			23
  ------------------
  470|     21|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|     21|#define SC_SUCCESS				0
  ------------------
  |  Branch (470:6): [True: 1, False: 20]
  ------------------
  471|      1|		sc_file_free(file);
  472|      1|		LOG_TEST_RET(ctx, r, "No authorisation to store private 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  473|      1|	}
  474|       |
  475|       |	/* Fill in data structure */
  476|     20|	memset(&args, 0, sizeof(args));
  477|     20|	args.mod_len = keybits;
  478|     20|	args.op_type = OP_TYPE_GENERATE;
  ------------------
  |  |  530|     20|#define OP_TYPE_GENERATE	0
  ------------------
  479|     20|	args.pubexp_len = SETCOS_DEFAULT_PUBKEY_LEN * 8;
  ------------------
  |  |   37|     20|#define SETCOS_DEFAULT_PUBKEY_LEN       sizeof(SETCOS_DEFAULT_PUBKEY)
  ------------------
  480|     20|	args.pubexp = SETCOS_DEFAULT_PUBKEY;
  481|       |
  482|       |	/* Generate/store rsa key  */
  483|     20|	r = sc_card_ctl(p15card->card, SC_CARDCTL_SETCOS_GENERATE_STORE_KEY, &args);
  484|     20|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|     20|#define SC_SUCCESS				0
  ------------------
  |  Branch (484:6): [True: 2, False: 18]
  ------------------
  485|      2|		sc_file_free(file);
  486|      2|		LOG_TEST_RET(ctx, r, "Card control 'GENERATE_STORE_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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  487|      2|	}
  488|       |
  489|       |	/* Key pair generation -> collect public key info */
  490|     18|	if (pubkey != NULL) {
  ------------------
  |  Branch (490:6): [True: 18, False: 0]
  ------------------
  491|     18|		pubkey->algorithm		= SC_ALGORITHM_RSA;
  ------------------
  |  |   69|     18|#define SC_ALGORITHM_RSA		0
  ------------------
  492|     18|		pubkey->u.rsa.modulus.len	= BYTES4BITS(keybits);
  ------------------
  |  |  146|     18|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  493|     18|		pubkey->u.rsa.modulus.data	= malloc(pubkey->u.rsa.modulus.len);
  494|     18|		if (pubkey->u.rsa.modulus.data == NULL)
  ------------------
  |  Branch (494:7): [True: 0, False: 18]
  ------------------
  495|     18|			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|     18|		pubkey->u.rsa.exponent.len	= SETCOS_DEFAULT_PUBKEY_LEN;
  ------------------
  |  |   37|     18|#define SETCOS_DEFAULT_PUBKEY_LEN       sizeof(SETCOS_DEFAULT_PUBKEY)
  ------------------
  497|     18|		pubkey->u.rsa.exponent.data	= malloc(SETCOS_DEFAULT_PUBKEY_LEN);
  ------------------
  |  |   37|     18|#define SETCOS_DEFAULT_PUBKEY_LEN       sizeof(SETCOS_DEFAULT_PUBKEY)
  ------------------
  498|     18|		if (pubkey->u.rsa.exponent.data == NULL)
  ------------------
  |  Branch (498:7): [True: 0, False: 18]
  ------------------
  499|     18|			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|     18|		memcpy(pubkey->u.rsa.exponent.data, SETCOS_DEFAULT_PUBKEY, SETCOS_DEFAULT_PUBKEY_LEN);
  ------------------
  |  |   37|     18|#define SETCOS_DEFAULT_PUBKEY_LEN       sizeof(SETCOS_DEFAULT_PUBKEY)
  ------------------
  501|       |
  502|       |		/* Get public key modulus */
  503|     18|		r = sc_select_file(p15card->card, &file->path, NULL);
  504|     18|		sc_file_free(file);
  505|     18|		LOG_TEST_RET(ctx, r, "Cannot get key modulus: select key file 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: 1, False: 17]
  |  |  |  |  ------------------
  |  |  |  |  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|     18|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 17]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  506|       |
  507|     17|		data_obj.P1 = 0x01;
  508|     17|		data_obj.P2 = 0x01;
  509|     17|		data_obj.Data = raw_pubkey;
  510|     17|		data_obj.DataLen = sizeof(raw_pubkey);
  511|       |
  512|     17|		r = sc_card_ctl(p15card->card, SC_CARDCTL_SETCOS_GETDATA, &data_obj);
  513|     17|		LOG_TEST_RET(ctx, r, "Cannot get key modulus: 'SETCOS_GETDATA' 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: 4, False: 13]
  |  |  |  |  ------------------
  |  |  |  |  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|     17|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 13]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  514|       |
  515|     13|		if (data_obj.DataLen < 3 || data_obj.DataLen < pubkey->u.rsa.modulus.len)
  ------------------
  |  Branch (515:7): [True: 1, False: 12]
  |  Branch (515:31): [True: 2, False: 10]
  ------------------
  516|     13|			LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Cannot get key modulus: wrong length of raw key");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  517|       |
  518|     10|		keybits = ((raw_pubkey[0] * 256) + raw_pubkey[1]);  /* modulus bit length */
  519|     10|		if (keybits != key_info->modulus_length)  {
  ------------------
  |  Branch (519:7): [True: 9, False: 1]
  ------------------
  520|      9|			sc_log(ctx, "key-size from card[%zu] does not match[%zu]",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  521|      9|					keybits, key_info->modulus_length);
  522|      9|			LOG_TEST_RET(ctx, SC_ERROR_PKCS15INIT, "Failed to generate key");
  ------------------
  |  |  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: 9, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|      9|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  523|      9|		}
  524|      1|		memcpy(pubkey->u.rsa.modulus.data, &raw_pubkey[2], pubkey->u.rsa.modulus.len);
  525|      1|	} else {
  526|      0|		sc_file_free(file);
  527|      0|	}
  528|       |
  529|      1|	return r;
  530|     18|}

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

sc_profile_new:
  291|  13.2k|{
  292|  13.2k|	struct sc_pkcs15_card *p15card;
  293|  13.2k|	struct sc_profile *pro;
  294|       |
  295|  13.2k|	pro = calloc(1, sizeof(*pro));
  296|  13.2k|	if (pro == NULL)
  ------------------
  |  Branch (296:6): [True: 0, False: 13.2k]
  ------------------
  297|      0|		return NULL;
  298|  13.2k|	pro->p15_spec = p15card = sc_pkcs15_card_new();
  299|       |
  300|  13.2k|	pro->pkcs15.do_last_update = 1;
  301|       |
  302|  13.2k|	if (p15card) {
  ------------------
  |  Branch (302:6): [True: 13.2k, False: 0]
  ------------------
  303|  13.2k|		p15card->tokeninfo->label = strdup("OpenSC Card");
  304|  13.2k|		p15card->tokeninfo->manufacturer_id = strdup("OpenSC Project");
  305|  13.2k|		p15card->tokeninfo->serial_number = strdup("0000");
  306|  13.2k|		p15card->tokeninfo->flags = SC_PKCS15_TOKEN_EID_COMPLIANT;
  ------------------
  |  |  598|  13.2k|#define SC_PKCS15_TOKEN_EID_COMPLIANT			0x08
  ------------------
  307|  13.2k|		p15card->tokeninfo->version = 0;
  308|       |
  309|       |		/* Set up EF(TokenInfo) and EF(ODF) */
  310|  13.2k|		p15card->file_tokeninfo = init_file(SC_FILE_TYPE_WORKING_EF);
  ------------------
  |  |  216|  13.2k|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  311|  13.2k|		p15card->file_odf = init_file(SC_FILE_TYPE_WORKING_EF);
  ------------------
  |  |  216|  13.2k|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  312|  13.2k|		p15card->file_unusedspace = init_file(SC_FILE_TYPE_WORKING_EF);
  ------------------
  |  |  216|  13.2k|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  313|  13.2k|	}
  314|       |
  315|       |	/* Assume card does RSA natively */
  316|  13.2k|	pro->rsa_access_flags = DEF_PRKEY_RSA_ACCESS;
  ------------------
  |  |   53|  13.2k|#define DEF_PRKEY_RSA_ACCESS	0x1D
  ------------------
  317|  13.2k|	pro->pin_encoding = SC_PKCS15_PIN_TYPE_ASCII_NUMERIC;
  ------------------
  |  |   89|  13.2k|#define SC_PKCS15_PIN_TYPE_ASCII_NUMERIC		1
  ------------------
  318|  13.2k|	pro->pin_minlen = 4;
  319|  13.2k|	pro->pin_maxlen = 8;
  320|  13.2k|	pro->id_style = SC_PKCS15INIT_ID_STYLE_NATIVE;
  ------------------
  |  |  165|  13.2k|#define SC_PKCS15INIT_ID_STYLE_NATIVE		0
  ------------------
  321|       |
  322|  13.2k|	return pro;
  323|  13.2k|}
sc_profile_finish:
  391|  10.0k|{
  392|  10.0k|	struct sc_context *ctx = profile->card->ctx;
  393|  10.0k|	struct file_info *fi;
  394|  10.0k|	struct pin_info	*pi;
  395|  10.0k|	char		reason[64];
  396|       |
  397|  10.0k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  10.0k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  10.0k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  10.0k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  10.0k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 10.0k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  398|  10.0k|	profile->mf_info = sc_profile_find_file(profile, NULL, "MF");
  399|  10.0k|	if (!profile->mf_info)
  ------------------
  |  Branch (399:6): [True: 3.37k, False: 6.71k]
  ------------------
  400|  10.0k|		LOG_TEST_RET(ctx, SC_ERROR_INCONSISTENT_PROFILE, "Profile doesn't define a MF");
  ------------------
  |  |  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: 3.37k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|  3.37k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  3.37k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  3.37k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  3.37k|		return _ret; \
  |  |  |  |  172|  3.37k|	} \
  |  |  |  |  173|  3.37k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  401|       |
  402|  6.71k|	if (app_info && app_info->aid.len)   {
  ------------------
  |  Branch (402:6): [True: 0, False: 6.71k]
  |  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|  6.71k|	profile->df_info = sc_profile_find_file(profile, NULL, "PKCS15-AppDF");
  421|  6.71k|	if (!profile->df_info)
  ------------------
  |  Branch (421:6): [True: 82, False: 6.63k]
  ------------------
  422|  6.71k|		LOG_TEST_RET(ctx, SC_ERROR_INCONSISTENT_PROFILE, "Profile doesn't define a PKCS15-AppDF");
  ------------------
  |  |  174|     82|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     82|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     82|	int _ret = (r); \
  |  |  |  |  168|     82|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 82, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     82|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     82|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     82|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     82|		return _ret; \
  |  |  |  |  172|     82|	} \
  |  |  |  |  173|     82|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  423|       |
  424|  6.63k|	profile->p15_spec->file_app = profile->df_info->file;
  425|  6.63k|	profile->df_info->dont_free = 1;
  426|       |
  427|  10.4k|	for (pi = profile->pin_list; pi; pi = pi->next) {
  ------------------
  |  Branch (427:31): [True: 3.85k, False: 6.63k]
  ------------------
  428|  3.85k|		const char	*name;
  429|       |
  430|  3.85k|		set_pin_defaults(profile, pi);
  431|  3.85k|		if (!(name = pi->file_name))
  ------------------
  |  Branch (431:7): [True: 3.85k, False: 1]
  ------------------
  432|  3.85k|			continue;
  433|      1|		if (!(fi = sc_profile_find_file(profile, NULL, name))) {
  ------------------
  |  Branch (433:7): [True: 1, False: 0]
  ------------------
  434|      1|			snprintf(reason, sizeof(reason), "unknown PIN file \"%s\"\n", name);
  435|      1|			goto whine;
  436|      1|		}
  437|       |
  438|      0|		pi->file = fi;
  439|      0|	}
  440|  6.63k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  6.63k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  6.63k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  6.63k|	int _ret = r; \
  |  |  |  |  155|  6.63k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 6.63k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  6.63k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 6.63k]
  |  |  |  |  ------------------
  |  |  |  |  157|  6.63k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  6.63k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|  6.63k|	return _ret; \
  |  |  |  |  163|  6.63k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  441|       |
  442|      1|whine:
  443|      1|	sc_log(ctx, "%s", reason);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  444|      1|	LOG_FUNC_RETURN(ctx, SC_ERROR_INCONSISTENT_PROFILE);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  445|      1|}
sc_profile_free:
  449|  14.8k|{
  450|  14.8k|	struct auth_info *ai;
  451|  14.8k|	struct pin_info *pi;
  452|  14.8k|	sc_macro_t	*mi;
  453|  14.8k|	sc_template_t	*ti;
  454|       |
  455|  14.8k|	if (profile->name)
  ------------------
  |  Branch (455:6): [True: 12.1k, False: 2.71k]
  ------------------
  456|  12.1k|		free(profile->name);
  457|  14.8k|	if (profile->driver)
  ------------------
  |  Branch (457:6): [True: 9, False: 14.8k]
  ------------------
  458|      9|		free(profile->driver);
  459|       |
  460|  14.8k|	free_file_list(&profile->ef_list);
  461|       |
  462|  14.8k|	while ((ai = profile->auth_list) != NULL) {
  ------------------
  |  Branch (462:9): [True: 2, False: 14.8k]
  ------------------
  463|      2|		profile->auth_list = ai->next;
  464|      2|		free(ai);
  465|      2|	}
  466|       |
  467|  16.5k|	while ((ti = profile->template_list) != NULL) {
  ------------------
  |  Branch (467:9): [True: 1.62k, False: 14.8k]
  ------------------
  468|  1.62k|		profile->template_list = ti->next;
  469|  1.62k|		if (ti->data)
  ------------------
  |  Branch (469:7): [True: 1.62k, False: 0]
  ------------------
  470|  1.62k|			sc_profile_free(ti->data);
  471|  1.62k|		if (ti->name)
  ------------------
  |  Branch (471:7): [True: 1.62k, False: 0]
  ------------------
  472|  1.62k|			free(ti->name);
  473|  1.62k|		free(ti);
  474|  1.62k|	}
  475|       |
  476|  17.6k|	while ((mi = profile->macro_list) != NULL) {
  ------------------
  |  Branch (476:9): [True: 2.76k, False: 14.8k]
  ------------------
  477|  2.76k|		profile->macro_list = mi->next;
  478|  2.76k|		if (mi->name)
  ------------------
  |  Branch (478:7): [True: 2.76k, False: 0]
  ------------------
  479|  2.76k|			free(mi->name);
  480|  2.76k|		free(mi);
  481|  2.76k|	}
  482|       |
  483|  33.1k|	while ((pi = profile->pin_list) != NULL) {
  ------------------
  |  Branch (483:9): [True: 18.2k, False: 14.8k]
  ------------------
  484|  18.2k|		profile->pin_list = pi->next;
  485|  18.2k|		if (pi->file_name)
  ------------------
  |  Branch (485:7): [True: 21, False: 18.2k]
  ------------------
  486|     21|			free(pi->file_name);
  487|  18.2k|		free(pi);
  488|  18.2k|	}
  489|       |
  490|  14.9k|	for (int i = 0; profile->options[i]; i++) {
  ------------------
  |  Branch (490:18): [True: 127, False: 14.8k]
  ------------------
  491|    127|		free(profile->options[i]);
  492|    127|	}
  493|       |
  494|  14.8k|	if (profile->p15_spec)
  ------------------
  |  Branch (494:6): [True: 13.2k, False: 1.62k]
  ------------------
  495|  13.2k|		sc_pkcs15_card_free(profile->p15_spec);
  496|       |
  497|  14.8k|	if (profile->dll)
  ------------------
  |  Branch (497:6): [True: 0, False: 14.8k]
  ------------------
  498|      0|		sc_dlclose(profile->dll);
  499|       |
  500|  14.8k|	free(profile);
  501|  14.8k|}
sc_profile_get_pin_info:
  506|  27.3k|{
  507|  27.3k|	struct pin_info	*pi;
  508|       |
  509|  27.3k|	pi = new_pin(profile, id);
  510|  27.3k|	if (pi == NULL)
  ------------------
  |  Branch (510:6): [True: 0, False: 27.3k]
  ------------------
  511|      0|		return;
  512|       |
  513|  27.3k|	pi->pin.max_tries = pi->pin.tries_left;
  514|  27.3k|	*info = pi->pin;
  515|  27.3k|}
sc_profile_get_pin_retries:
  519|     53|{
  520|     53|	struct pin_info	*pi;
  521|       |
  522|     53|	pi = new_pin(profile, id);
  523|     53|	if (pi == NULL)
  ------------------
  |  Branch (523:6): [True: 0, False: 53]
  ------------------
  524|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  525|     53|	return pi->pin.tries_left;
  526|     53|}
sc_profile_get_pin_id:
  531|     43|{
  532|     43|	struct pin_info	*pi;
  533|       |
  534|    164|	for (pi = profile->pin_list; pi; pi = pi->next) {
  ------------------
  |  Branch (534:31): [True: 152, False: 12]
  ------------------
  535|    152|		if (pi->pin.auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|    152|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (535:7): [True: 0, False: 152]
  ------------------
  536|      0|			continue;
  537|    152|		if (pi->pin.attrs.pin.reference == (int)reference) {
  ------------------
  |  Branch (537:7): [True: 31, False: 121]
  ------------------
  538|     31|			*id = pi->id;
  539|     31|			return 0;
  540|     31|		}
  541|       |
  542|    152|	}
  543|     12|	return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|     12|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  544|     43|}
sc_profile_get_file_in:
  549|     19|{
  550|     19|	struct file_info *fi;
  551|       |
  552|     19|	if ((fi = sc_profile_find_file(profile, path, name)) == NULL)
  ------------------
  |  Branch (552:6): [True: 15, False: 4]
  ------------------
  553|     15|		return SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|     15|#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|  7.43k|{
  564|  7.43k|	struct file_info *fi;
  565|       |
  566|  7.43k|	if ((fi = sc_profile_find_file(profile, NULL, name)) == NULL)
  ------------------
  |  Branch (566:6): [True: 3.96k, False: 3.46k]
  ------------------
  567|  3.96k|		return SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|  3.96k|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  568|  3.46k|	sc_file_dup(ret, fi->file);
  569|  3.46k|	if (*ret == NULL)
  ------------------
  |  Branch (569:6): [True: 0, False: 3.46k]
  ------------------
  570|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  571|  3.46k|	return 0;
  572|  3.46k|}
sc_profile_get_file_instance:
  577|  23.3k|{
  578|  23.3k|	struct sc_context *ctx = profile->card->ctx;
  579|  23.3k|	struct file_info *fi;
  580|  23.3k|	struct sc_file *file;
  581|  23.3k|	int r;
  582|       |
  583|  23.3k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  23.3k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  23.3k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  23.3k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  23.3k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 23.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  584|  23.3k|	sc_log(ctx, "try to get '%s' file instance", name);
  ------------------
  |  |   71|  23.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__
  |  |  ------------------
  ------------------
  585|       |
  586|  23.3k|	if ((fi = sc_profile_find_file(profile, NULL, name)) == NULL)
  ------------------
  |  Branch (586:6): [True: 17.2k, False: 6.11k]
  ------------------
  587|  23.3k|		LOG_FUNC_RETURN(ctx, SC_ERROR_FILE_NOT_FOUND);
  ------------------
  |  |  164|  17.2k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  17.2k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  17.2k|	int _ret = r; \
  |  |  |  |  155|  17.2k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 17.2k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  17.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|  17.2k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 17.2k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  17.2k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  17.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|  17.2k|	return _ret; \
  |  |  |  |  163|  17.2k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  588|  6.11k|	sc_file_dup(&file, fi->file);
  589|  6.11k|	sc_log(ctx, "ident '%s'; parent '%s'", fi->ident, fi->parent ? fi->parent->ident : "(null)");
  ------------------
  |  |   71|  12.2k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  |  Branch (71:122): [True: 5.56k, False: 547]
  |  |  ------------------
  ------------------
  590|  6.11k|	if (file == NULL)
  ------------------
  |  Branch (590:6): [True: 0, False: 6.11k]
  ------------------
  591|  6.11k|		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|  6.11k|	sc_log(ctx, "file (type:%X, path:'%s')", file->type, sc_print_path(&file->path));
  ------------------
  |  |   71|  6.11k|#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|  6.11k|	file->id += index;
  595|  6.11k|        if(file->type == SC_FILE_TYPE_BSO) {
  ------------------
  |  |  217|  6.11k|#define SC_FILE_TYPE_BSO		0x10
  ------------------
  |  Branch (595:12): [True: 14, False: 6.10k]
  ------------------
  596|     14|		r = sc_profile_add_file(profile, name, file);
  597|     14|		if (r < 0)
  ------------------
  |  Branch (597:7): [True: 0, False: 14]
  ------------------
  598|      0|			sc_file_free(file);
  599|     14|		LOG_TEST_RET(ctx, r, "Profile error: cannot add BSO file");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  600|     14|	}
  601|  6.10k|	else if (file->path.len)   {
  ------------------
  |  Branch (601:11): [True: 544, False: 5.55k]
  ------------------
  602|    544|		file->path.value[file->path.len - 2] = (file->id >> 8) & 0xFF;
  603|    544|		file->path.value[file->path.len - 1] = file->id & 0xFF;
  604|       |
  605|    544|		r = sc_profile_add_file(profile, name, file);
  606|    544|		if (r < 0)
  ------------------
  |  Branch (606:7): [True: 38, False: 506]
  ------------------
  607|     38|			sc_file_free(file);
  608|    544|		LOG_TEST_RET(ctx, r, "Profile error: cannot add file");
  ------------------
  |  |  174|    544|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    544|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    544|	int _ret = (r); \
  |  |  |  |  168|    544|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 38, False: 506]
  |  |  |  |  ------------------
  |  |  |  |  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|    544|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 506]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  609|    544|	}
  610|       |
  611|  6.07k|	if (ret)
  ------------------
  |  Branch (611:6): [True: 6.07k, False: 0]
  ------------------
  612|  6.07k|		*ret = file;
  613|      0|	else
  614|      0|		sc_file_free(file);
  615|       |
  616|  6.07k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  6.07k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  6.07k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  6.07k|	int _ret = r; \
  |  |  |  |  155|  6.07k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 6.07k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  6.07k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 6.07k]
  |  |  |  |  ------------------
  |  |  |  |  157|  6.07k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  6.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|  6.07k|	return _ret; \
  |  |  |  |  163|  6.07k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  617|  6.07k|}
sc_profile_get_file_by_path:
  634|  5.09k|{
  635|  5.09k|	struct sc_context *ctx = profile->card->ctx;
  636|  5.09k|	struct file_info *fi;
  637|       |
  638|  5.09k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  5.09k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  5.09k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  5.09k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  5.09k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 5.09k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  639|  5.09k|	if ((fi = sc_profile_find_file_by_path(profile, path)) == NULL)
  ------------------
  |  Branch (639:6): [True: 2.01k, False: 3.07k]
  ------------------
  640|  5.09k|		LOG_FUNC_RETURN(ctx, SC_ERROR_FILE_NOT_FOUND);
  ------------------
  |  |  164|  2.01k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.01k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.01k|	int _ret = r; \
  |  |  |  |  155|  2.01k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.01k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.01k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  2.01k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.01k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.01k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.01k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|  2.01k|	return _ret; \
  |  |  |  |  163|  2.01k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  641|  3.07k|	sc_file_dup(ret, fi->file);
  642|  3.07k|	LOG_FUNC_RETURN(ctx, *ret ? SC_SUCCESS : SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  164|  3.07k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.07k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  6.15k|	int _ret = r; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (154:13): [True: 3.07k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  155|  3.07k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.07k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.07k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 3.07k]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.07k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.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|  3.07k|	return _ret; \
  |  |  |  |  163|  3.07k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  643|  3.07k|}
sc_profile_add_file:
  647|    571|{
  648|    571|	struct sc_context *ctx = profile->card->ctx;
  649|    571|	sc_path_t	path = file->path;
  650|    571|	struct file_info	*parent;
  651|       |
  652|    571|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    571|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    571|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    571|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    571|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 571]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  653|    571|	if (!path.len)   {
  ------------------
  |  Branch (653:6): [True: 14, False: 557]
  ------------------
  654|     14|		parent = profile->df_info;
  655|    557|	} else {
  656|    557|		path.len -= 2;
  657|    557|		parent = sc_profile_find_file_by_path(profile, &path);
  658|    557|	}
  659|    571|	if (!parent)
  ------------------
  |  Branch (659:6): [True: 51, False: 520]
  ------------------
  660|    571|		LOG_FUNC_RETURN(ctx, SC_ERROR_FILE_NOT_FOUND);
  ------------------
  |  |  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|     51|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 51, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  661|    520|	sc_log(ctx, "Parent path:%s", sc_print_path(&parent->file->path));
  ------------------
  |  |   71|    520|#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|    520|	sc_file_dup(&file, file);
  664|    520|	if (file == NULL)
  ------------------
  |  Branch (664:6): [True: 0, False: 520]
  ------------------
  665|    520|		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|    520|	add_file(profile, name, file, parent);
  668|    520|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    520|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    520|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    520|	int _ret = r; \
  |  |  |  |  155|    520|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 520, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    520|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 520]
  |  |  |  |  ------------------
  |  |  |  |  157|    520|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    520|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    520|	return _ret; \
  |  |  |  |  163|    520|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  669|    520|}
sc_profile_instantiate_template:
  679|  25.2k|{
  680|  25.2k|	struct sc_context *ctx = profile->card->ctx;
  681|  25.2k|	struct sc_profile	*tmpl;
  682|  25.2k|	struct sc_template	*info;
  683|  25.2k|	unsigned int	idx;
  684|  25.2k|	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|  26.1k|	for (info = profile->template_list; info; info = info->next)
  ------------------
  |  Branch (690:38): [True: 2.53k, False: 23.5k]
  ------------------
  691|  2.53k|		if (!strcmp(info->name, template_name))
  ------------------
  |  Branch (691:7): [True: 1.65k, False: 877]
  ------------------
  692|  1.65k|			break;
  693|  25.2k|	if (info == NULL)   {
  ------------------
  |  Branch (693:6): [True: 23.5k, False: 1.65k]
  ------------------
  694|  23.5k|		sc_log(ctx, "Template %s not found", template_name);
  ------------------
  |  |   71|  23.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__
  |  |  ------------------
  ------------------
  695|  23.5k|		return SC_ERROR_TEMPLATE_NOT_FOUND;
  ------------------
  |  |  110|  23.5k|#define SC_ERROR_TEMPLATE_NOT_FOUND		-1508
  ------------------
  696|  23.5k|	}
  697|       |
  698|  1.65k|	tmpl = info->data;
  699|  1.65k|	idx = id->value[id->len-1];
  700|   108k|	for (fi = profile->ef_list; fi; fi = fi->next) {
  ------------------
  |  Branch (700:30): [True: 106k, False: 1.32k]
  ------------------
  701|   106k|		if (fi->base_template == tmpl
  ------------------
  |  Branch (701:7): [True: 101k, False: 5.20k]
  ------------------
  702|   101k|		 && fi->inst_index == idx
  ------------------
  |  Branch (702:7): [True: 2.77k, False: 98.7k]
  ------------------
  703|  2.77k|		 && sc_compare_path(&fi->inst_path, base_path)
  ------------------
  |  Branch (703:7): [True: 2.75k, False: 16]
  ------------------
  704|  2.75k|		 && !strcmp(fi->ident, file_name)) {
  ------------------
  |  Branch (704:7): [True: 335, False: 2.42k]
  ------------------
  705|    335|			sc_file_dup(ret, fi->file);
  706|    335|			if (*ret == NULL)
  ------------------
  |  Branch (706:8): [True: 0, False: 335]
  ------------------
  707|      0|				return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  708|    335|			return 0;
  709|    335|		}
  710|   106k|	}
  711|       |
  712|  1.32k|	sc_log(ctx, "Instantiating template %s at %s", template_name, sc_print_path(base_path));
  ------------------
  |  |   71|  1.32k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  713|       |
  714|  1.32k|	base_file = sc_profile_find_file_by_path(profile, base_path);
  715|  1.32k|	if (base_file == NULL) {
  ------------------
  |  Branch (715:6): [True: 32, False: 1.29k]
  ------------------
  716|     32|		sc_log(ctx, "Directory %s not defined in profile", sc_print_path(base_path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  717|     32|		return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|     32|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  718|     32|	}
  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|  1.29k|	if (base_file->instance == NULL)
  ------------------
  |  Branch (723:6): [True: 0, False: 1.29k]
  ------------------
  724|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  725|  3.01k|	for (fi = tmpl->ef_list; fi; fi = fi->next) {
  ------------------
  |  Branch (725:27): [True: 1.72k, False: 1.29k]
  ------------------
  726|  1.72k|		struct file_info	*parent, *instance;
  727|  1.72k|		unsigned int	skew = 0;
  728|       |
  729|  1.72k|		fi->instance = NULL;
  730|  1.72k|		if ((parent = fi->parent) == NULL) {
  ------------------
  |  Branch (730:7): [True: 1.28k, False: 440]
  ------------------
  731|  1.28k|			parent = base_file;
  732|  1.28k|			skew = idx;
  733|  1.28k|		}
  734|  1.72k|		parent = parent->instance;
  735|       |
  736|  1.72k|		instance = sc_profile_instantiate_file(profile, fi, parent, skew);
  737|  1.72k|		if (instance == NULL)
  ------------------
  |  Branch (737:7): [True: 0, False: 1.72k]
  ------------------
  738|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  739|  1.72k|		instance->base_template = tmpl;
  740|  1.72k|		instance->inst_index = idx;
  741|  1.72k|		instance->inst_path = *base_path;
  742|       |
  743|  1.72k|		if (!strcmp(instance->ident, file_name))
  ------------------
  |  Branch (743:7): [True: 515, False: 1.20k]
  ------------------
  744|    515|			match = instance;
  745|  1.72k|	}
  746|       |
  747|  1.29k|	if (match == NULL) {
  ------------------
  |  Branch (747:6): [True: 776, False: 515]
  ------------------
  748|    776|		sc_log(ctx, "No file named \"%s\" in template \"%s\"",
  ------------------
  |  |   71|    776|#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|    776|				file_name, template_name);
  750|    776|		return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|    776|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  751|    776|	}
  752|    515|	sc_file_dup(ret, match->file);
  753|    515|	if (*ret == NULL)
  ------------------
  |  Branch (753:6): [True: 0, False: 515]
  ------------------
  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|    515|	return 0;
  759|    515|}
sc_profile_get_pin_id_by_reference:
  806|  1.99k|{
  807|  1.99k|	struct pin_info *pinfo;
  808|       |
  809|  4.61k|	for (pinfo = profile->pin_list; pinfo; pinfo = pinfo->next)  {
  ------------------
  |  Branch (809:34): [True: 3.95k, False: 657]
  ------------------
  810|  3.95k|		if (auth_method == SC_AC_SYMBOLIC)   {
  ------------------
  |  |  155|  3.95k|#define SC_AC_SYMBOLIC			0x00000010 /* internal use only */
  ------------------
  |  Branch (810:7): [True: 2.51k, False: 1.44k]
  ------------------
  811|  2.51k|			if (pinfo->id != reference)
  ------------------
  |  Branch (811:8): [True: 1.20k, False: 1.31k]
  ------------------
  812|  1.20k|				continue;
  813|  2.51k|		}
  814|  1.44k|		else   {
  815|  1.44k|			if (pinfo->pin.auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|  1.44k|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (815:8): [True: 0, False: 1.44k]
  ------------------
  816|      0|				continue;
  817|  1.44k|			if (pinfo->pin.auth_method != auth_method)
  ------------------
  |  Branch (817:8): [True: 518, False: 922]
  ------------------
  818|    518|				continue;
  819|    922|			if (pinfo->pin.attrs.pin.reference != reference)
  ------------------
  |  Branch (819:8): [True: 898, False: 24]
  ------------------
  820|    898|				continue;
  821|    922|		}
  822|       |
  823|  1.33k|		if (auth_info)
  ------------------
  |  Branch (823:7): [True: 1.33k, False: 0]
  ------------------
  824|  1.33k|			*auth_info = pinfo->pin;
  825|  1.33k|		return pinfo->id;
  826|  3.95k|	}
  827|       |
  828|    657|	return -1;
  829|  1.99k|}
sc_profile_get_parent:
 2340|     67|{
 2341|     67|	struct file_info *fi = NULL;
 2342|       |
 2343|     67|	if ((fi = sc_profile_find_file(profile, NULL, name)) == NULL)
  ------------------
  |  Branch (2343:6): [True: 0, False: 67]
  ------------------
 2344|      0|		return SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
 2345|       |
 2346|     67|	if (!fi->parent)
  ------------------
  |  Branch (2346:6): [True: 1, False: 66]
  ------------------
 2347|      1|		return SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|      1|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
 2348|       |
 2349|     66|	sc_file_dup(ret, fi->parent->file);
 2350|     66|	if (*ret == NULL)
  ------------------
  |  Branch (2350:6): [True: 0, False: 66]
  ------------------
 2351|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2352|     66|	return 0;
 2353|     66|}
fuzz_pkcs15init.c:init_file:
  271|  64.2k|{
  272|  64.2k|	struct sc_file	*file;
  273|  64.2k|	unsigned int	op;
  274|       |
  275|  64.2k|	file = sc_file_new();
  276|  2.05M|	for (op = 0; op < SC_MAX_AC_OPS; op++) {
  ------------------
  |  |  198|  2.05M|#define SC_MAX_AC_OPS			31
  ------------------
  |  Branch (276:15): [True: 1.99M, False: 64.2k]
  ------------------
  277|  1.99M|		sc_file_add_acl_entry(file, op, SC_AC_NONE, 0);
  ------------------
  |  |  150|  1.99M|#define SC_AC_NONE			0x00000000
  ------------------
  278|  1.99M|	}
  279|  64.2k|	file->type = type;
  280|  64.2k|	file->status = SC_FILE_STATUS_ACTIVATED;
  ------------------
  |  |  236|  64.2k|#define SC_FILE_STATUS_ACTIVATED	0x00 /* ISO7816-4: Operational state (activated)   (5, 7) */
  ------------------
  281|  64.2k|	if (file->type != SC_FILE_TYPE_DF && file->type != SC_FILE_TYPE_BSO)
  ------------------
  |  |  214|   128k|#define SC_FILE_TYPE_DF			0x04
  ------------------
              	if (file->type != SC_FILE_TYPE_DF && file->type != SC_FILE_TYPE_BSO)
  ------------------
  |  |  217|  47.8k|#define SC_FILE_TYPE_BSO		0x10
  ------------------
  |  Branch (281:6): [True: 47.8k, False: 16.3k]
  |  Branch (281:39): [True: 46.0k, False: 1.74k]
  ------------------
  282|  46.0k|		file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|  46.0k|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  283|  64.2k|	return file;
  284|  64.2k|}
fuzz_pkcs15init.c:sc_profile_instantiate_file:
  764|  1.72k|{
  765|  1.72k|	struct sc_context *ctx = profile->card->ctx;
  766|  1.72k|	struct file_info *fi;
  767|       |
  768|  1.72k|	fi = calloc(1, sizeof(*fi));
  769|  1.72k|	if (fi == NULL)
  ------------------
  |  Branch (769:6): [True: 0, False: 1.72k]
  ------------------
  770|      0|		return NULL;
  771|  1.72k|	fi->instance = fi;
  772|  1.72k|	fi->parent = parent;
  773|  1.72k|	fi->ident = strdup(ft->ident);
  774|  1.72k|	if (fi->ident == NULL) {
  ------------------
  |  Branch (774:6): [True: 0, False: 1.72k]
  ------------------
  775|      0|		free(fi);
  776|      0|		return NULL;
  777|      0|	}
  778|  1.72k|	sc_file_dup(&fi->file, ft->file);
  779|  1.72k|	if (fi->file == NULL) {
  ------------------
  |  Branch (779:6): [True: 0, False: 1.72k]
  ------------------
  780|      0|		free(fi->ident);
  781|      0|		free(fi);
  782|      0|		return NULL;
  783|      0|	}
  784|  1.72k|	fi->file->path = parent->file->path;
  785|  1.72k|	fi->file->id += skew;
  786|       |
  787|  1.72k|	if (fi->file->type == SC_FILE_TYPE_INTERNAL_EF
  ------------------
  |  |  215|  3.44k|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (787:6): [True: 54, False: 1.66k]
  ------------------
  788|  1.66k|			|| fi->file->type == SC_FILE_TYPE_WORKING_EF
  ------------------
  |  |  216|  3.39k|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (788:7): [True: 344, False: 1.32k]
  ------------------
  789|  1.32k|			|| (fi->file->type == SC_FILE_TYPE_DF && fi->file->id))
  ------------------
  |  |  214|  2.64k|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (789:8): [True: 85, False: 1.23k]
  |  Branch (789:45): [True: 80, False: 5]
  ------------------
  790|    478|		sc_append_file_id(&fi->file->path, fi->file->id);
  791|       |
  792|  1.72k|	append_file(profile, fi);
  793|       |
  794|  1.72k|	ft->instance = fi;
  795|       |
  796|  1.72k|	sc_log(ctx, "Instantiated %s at %s", ft->ident, sc_print_path(&fi->file->path));
  ------------------
  |  |   71|  1.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__
  |  |  ------------------
  ------------------
  797|  1.72k|	sc_log(ctx, "  parent=%s@%s", parent->ident, sc_print_path(&parent->file->path));
  ------------------
  |  |   71|  1.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__
  |  |  ------------------
  ------------------
  798|       |
  799|  1.72k|	return fi;
  800|  1.72k|}
fuzz_pkcs15init.c:append_file:
 1176|  27.1k|{
 1177|  27.1k|	struct file_info	**list, *fi;
 1178|       |
 1179|  27.1k|	list = &profile->ef_list;
 1180|   154k|	while ((fi = *list) != NULL)
  ------------------
  |  Branch (1180:9): [True: 127k, False: 27.1k]
  ------------------
 1181|   127k|		list = &fi->next;
 1182|  27.1k|	*list = nfile;
 1183|  27.1k|}
fuzz_pkcs15init.c:add_file:
 1192|  25.3k|{
 1193|  25.3k|	struct file_info	*info;
 1194|       |
 1195|  25.3k|	info = calloc(1, sizeof(*info));
 1196|  25.3k|	if (info == NULL)
  ------------------
  |  Branch (1196:6): [True: 0, False: 25.3k]
  ------------------
 1197|      0|		return NULL;
 1198|  25.3k|	info->instance = info;
 1199|  25.3k|	info->ident = strdup(name);
 1200|       |
 1201|  25.3k|	info->parent = parent;
 1202|  25.3k|	info->file = file;
 1203|       |
 1204|  25.3k|	append_file(profile, info);
 1205|  25.3k|	return info;
 1206|  25.3k|}
fuzz_pkcs15init.c:free_file_list:
 1213|  14.8k|{
 1214|  14.8k|	struct file_info	*fi;
 1215|       |
 1216|  41.9k|	while ((fi = *list) != NULL) {
  ------------------
  |  Branch (1216:9): [True: 27.1k, False: 14.8k]
  ------------------
 1217|  27.1k|		*list = fi->next;
 1218|       |
 1219|  27.1k|		if (fi->dont_free == 0)
  ------------------
  |  Branch (1219:7): [True: 20.0k, False: 7.03k]
  ------------------
 1220|  20.0k|			sc_file_free(fi->file);
 1221|  27.1k|		free(fi->profile_extension);
 1222|  27.1k|		free(fi->ident);
 1223|  27.1k|		free(fi);
 1224|  27.1k|	}
 1225|  14.8k|}
fuzz_pkcs15init.c:new_pin:
 1654|  35.0k|{
 1655|  35.0k|	struct pin_info	*pi, **tail;
 1656|       |
 1657|  60.5k|	for (tail = &profile->pin_list; (pi = *tail); tail = &pi->next) {
  ------------------
  |  Branch (1657:34): [True: 42.2k, False: 18.2k]
  ------------------
 1658|  42.2k|		if (pi->id == id)
  ------------------
  |  Branch (1658:7): [True: 16.7k, False: 25.5k]
  ------------------
 1659|  16.7k|			return pi;
 1660|  42.2k|	}
 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|  18.2k|	pi = calloc(1, sizeof(*pi));
 1669|  18.2k|	if (pi == NULL)
  ------------------
  |  Branch (1669:6): [True: 0, False: 18.2k]
  ------------------
 1670|      0|		return NULL;
 1671|  18.2k|	pi->id = id;
 1672|  18.2k|	pi->pin.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|  18.2k|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
 1673|  18.2k|	pi->pin.auth_method = SC_AC_CHV;
  ------------------
  |  |  151|  18.2k|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1674|  18.2k|	pi->pin.attrs.pin.type = (unsigned int)-1;
 1675|  18.2k|	pi->pin.attrs.pin.flags = 0x32;
 1676|  18.2k|	pi->pin.attrs.pin.max_length = 0;
 1677|  18.2k|	pi->pin.attrs.pin.min_length = 0;
 1678|  18.2k|	pi->pin.attrs.pin.stored_length = 0;
 1679|  18.2k|	pi->pin.attrs.pin.pad_char = 0xA5;
 1680|  18.2k|	pi->pin.attrs.pin.reference = -1;
 1681|  18.2k|	pi->pin.tries_left = 3;
 1682|       |
 1683|  18.2k|	*tail = pi;
 1684|  18.2k|	return pi;
 1685|  18.2k|}
fuzz_pkcs15init.c:set_pin_defaults:
 1688|  3.85k|{
 1689|  3.85k|	struct sc_pkcs15_auth_info *info = &pi->pin;
 1690|  3.85k|	struct sc_pkcs15_pin_attributes *pin_attrs = &info->attrs.pin;
 1691|       |
 1692|  3.85k|	info->auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|  3.85k|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
 1693|       |
 1694|  3.85k|	if (pin_attrs->type == (unsigned int) -1)
  ------------------
  |  Branch (1694:6): [True: 3.83k, False: 18]
  ------------------
 1695|  3.83k|		pin_attrs->type = profile->pin_encoding;
 1696|  3.85k|	if (pin_attrs->max_length == 0)
  ------------------
  |  Branch (1696:6): [True: 3.52k, False: 330]
  ------------------
 1697|  3.52k|		pin_attrs->max_length = profile->pin_maxlen;
 1698|  3.85k|	if (pin_attrs->min_length == 0)
  ------------------
  |  Branch (1698:6): [True: 3.44k, False: 409]
  ------------------
 1699|  3.44k|		pin_attrs->min_length = profile->pin_minlen;
 1700|  3.85k|	if (pin_attrs->stored_length == 0) {
  ------------------
  |  Branch (1700:6): [True: 3.83k, False: 15]
  ------------------
 1701|  3.83k|		pin_attrs->stored_length = profile->pin_maxlen;
 1702|       |		/* BCD encoded PIN takes half the space */
 1703|  3.83k|		if (pin_attrs->type == SC_PKCS15_PIN_TYPE_BCD)
  ------------------
  |  |   88|  3.83k|#define SC_PKCS15_PIN_TYPE_BCD				0
  ------------------
  |  Branch (1703:7): [True: 18, False: 3.82k]
  ------------------
 1704|     18|			pin_attrs->stored_length = (pin_attrs->stored_length + 1) / 2;
 1705|  3.83k|	}
 1706|  3.85k|	if (pin_attrs->pad_char == 0xA5)
  ------------------
  |  Branch (1706:6): [True: 3.85k, False: 0]
  ------------------
 1707|  3.85k|		pin_attrs->pad_char = profile->pin_pad_char;
 1708|  3.85k|}
fuzz_pkcs15init.c:process_conf:
 2249|  11.8k|{
 2250|  11.8k|	struct state	state;
 2251|       |
 2252|  11.8k|	memset(&state, 0, sizeof(state));
 2253|  11.8k|	state.filename = conf->filename;
 2254|  11.8k|	state.profile = profile;
 2255|  11.8k|	return process_block(&state, &root_ops, "root", conf->root);
 2256|  11.8k|}
fuzz_pkcs15init.c:process_block:
 2195|  63.7k|{
 2196|  63.7k|	scconf_item	*item;
 2197|  63.7k|	struct command	*cp;
 2198|  63.7k|	struct block	*bp;
 2199|  63.7k|	const char	*cmd, *ident;
 2200|  63.7k|	int		res = 0;
 2201|       |
 2202|   208k|	for (item = blk->items; res == 0 && item; item = item->next) {
  ------------------
  |  Branch (2202:26): [True: 205k, False: 3.70k]
  |  Branch (2202:38): [True: 145k, False: 59.5k]
  ------------------
 2203|   145k|		cmd = item->key;
 2204|   145k|		if (item->type == SCCONF_ITEM_TYPE_COMMENT)
  ------------------
  |  |   42|   145k|#define SCCONF_ITEM_TYPE_COMMENT	0	/* key = NULL, comment */
  ------------------
  |  Branch (2204:7): [True: 49.0k, False: 96.7k]
  ------------------
 2205|  49.0k|			continue;
 2206|  96.7k|		if (!cmd) {
  ------------------
  |  Branch (2206:7): [True: 22, False: 96.7k]
  ------------------
 2207|     22|			parse_error(cur, "Command can not be processed.");
 2208|     22|			return SC_ERROR_SYNTAX_ERROR;
  ------------------
  |  |  103|     22|#define SC_ERROR_SYNTAX_ERROR			-1501
  ------------------
 2209|     22|		}
 2210|  96.7k|		if (item->type == SCCONF_ITEM_TYPE_BLOCK) {
  ------------------
  |  |   43|  96.7k|#define SCCONF_ITEM_TYPE_BLOCK		1	/* key = key, block */
  ------------------
  |  Branch (2210:7): [True: 54.9k, False: 41.7k]
  ------------------
 2211|  54.9k|			scconf_list *nlist;
 2212|       |
 2213|  54.9k|			ident = NULL;
 2214|  54.9k|			if ((nlist = item->value.block->name) != NULL) {
  ------------------
  |  Branch (2214:8): [True: 54.9k, False: 0]
  ------------------
 2215|  54.9k|				if (nlist->next) {
  ------------------
  |  Branch (2215:9): [True: 3, False: 54.9k]
  ------------------
 2216|      3|					parse_error(cur, "Too many name components in block name.");
 2217|      3|					return SC_ERROR_SYNTAX_ERROR;
  ------------------
  |  |  103|      3|#define SC_ERROR_SYNTAX_ERROR			-1501
  ------------------
 2218|      3|				}
 2219|  54.9k|				ident = nlist->data;
 2220|  54.9k|			}
 2221|       |#ifdef DEBUG_PROFILE
 2222|       |			printf("Processing %s %s\n", cmd, ident? ident : "");
 2223|       |#endif
 2224|  54.9k|			if ((bp = find_block_handler(info->blk_info, cmd))) {
  ------------------
  |  Branch (2224:8): [True: 54.7k, False: 238]
  ------------------
 2225|  54.7k|				res = bp->handler(cur, bp, ident, item->value.block);
 2226|  54.7k|				continue;
 2227|  54.7k|			}
 2228|  54.9k|		}
 2229|  41.7k|		else if (item->type == SCCONF_ITEM_TYPE_VALUE) {
  ------------------
  |  |   44|  41.7k|#define SCCONF_ITEM_TYPE_VALUE		2	/* key = key, list */
  ------------------
  |  Branch (2229:12): [True: 41.7k, False: 0]
  ------------------
 2230|       |#ifdef DEBUG_PROFILE
 2231|       |			printf("Processing %s\n", cmd);
 2232|       |#endif
 2233|  41.7k|			if ((cp = find_cmd_handler(info->cmd_info, cmd))) {
  ------------------
  |  Branch (2233:8): [True: 41.4k, False: 306]
  ------------------
 2234|  41.4k|				res = process_command(cur, cp, item->value.list);
 2235|  41.4k|				continue;
 2236|  41.4k|			}
 2237|  41.7k|		}
 2238|    544|		parse_error(cur, "Command \"%s\" not understood in this context.", cmd);
 2239|    544|		return SC_ERROR_SYNTAX_ERROR;
  ------------------
  |  |  103|    544|#define SC_ERROR_SYNTAX_ERROR			-1501
  ------------------
 2240|  96.7k|	}
 2241|       |
 2242|  63.2k|	if (res > 0)
  ------------------
  |  Branch (2242:6): [True: 1.00k, False: 62.2k]
  ------------------
 2243|  1.00k|		res = SC_ERROR_SYNTAX_ERROR;
  ------------------
  |  |  103|  1.00k|#define SC_ERROR_SYNTAX_ERROR			-1501
  ------------------
 2244|  63.2k|	return res;
 2245|  63.7k|}
fuzz_pkcs15init.c:parse_error:
 2699|  1.96k|{
 2700|  1.96k|	char	buffer[1024], *sp;
 2701|  1.96k|	va_list	ap;
 2702|       |
 2703|  1.96k|	va_start(ap, fmt);
 2704|  1.96k|	vsnprintf(buffer, sizeof(buffer), fmt, ap);
 2705|  1.96k|	va_end(ap);
 2706|       |
 2707|  1.96k|	if ((sp = strchr(buffer, '\n')) != NULL)
  ------------------
  |  Branch (2707:6): [True: 1.27k, False: 689]
  ------------------
 2708|  1.27k|		*sp = '\0';
 2709|       |
 2710|  1.96k|	if (cur->profile->card && cur->profile->card->ctx)
  ------------------
  |  Branch (2710:6): [True: 1.91k, False: 44]
  |  Branch (2710:28): [True: 1.91k, False: 0]
  ------------------
 2711|  1.91k|		sc_log(cur->profile->card->ctx, "%s: %s", cur->filename, buffer);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2712|     44|	else
 2713|     44|		fprintf(stdout, "%s: %s\n", cur->filename, buffer);
 2714|  1.96k|}
fuzz_pkcs15init.c:find_block_handler:
 2170|  54.9k|{
 2171|  54.9k|	if (bp == NULL)
  ------------------
  |  Branch (2171:6): [True: 10, False: 54.9k]
  ------------------
 2172|     10|		return NULL;
 2173|   113k|	for (; bp->name; bp++) {
  ------------------
  |  Branch (2173:9): [True: 113k, False: 228]
  ------------------
 2174|   113k|		if (!strcasecmp(bp->name, name))
  ------------------
  |  Branch (2174:7): [True: 54.7k, False: 58.3k]
  ------------------
 2175|  54.7k|			return bp;
 2176|   113k|	}
 2177|    228|	return NULL;
 2178|  54.9k|}
fuzz_pkcs15init.c:find_cmd_handler:
 2182|  41.7k|{
 2183|  41.7k|	if (cp == NULL)
  ------------------
  |  Branch (2183:6): [True: 151, False: 41.6k]
  ------------------
 2184|    151|		return NULL;
 2185|   196k|	for (; cp->name; cp++) {
  ------------------
  |  Branch (2185:9): [True: 196k, False: 155]
  ------------------
 2186|   196k|		if (!strcasecmp(cp->name, name))
  ------------------
  |  Branch (2186:7): [True: 41.4k, False: 154k]
  ------------------
 2187|  41.4k|			return cp;
 2188|   196k|	}
 2189|    155|	return NULL;
 2190|  41.6k|}
fuzz_pkcs15init.c:process_command:
 2150|  41.4k|{
 2151|  41.4k|	const char	*cmd = cmd_info->name;
 2152|  41.4k|	char		*argv[32];
 2153|  41.4k|	int		argc, max = 32;
 2154|       |
 2155|  41.4k|	if (cmd_info->max_args >= 0 && max > cmd_info->max_args)
  ------------------
  |  Branch (2155:6): [True: 34.4k, False: 7.02k]
  |  Branch (2155:33): [True: 34.4k, False: 0]
  ------------------
 2156|  34.4k|		max = cmd_info->max_args;
 2157|       |
 2158|  41.4k|	if ((argc = build_argv(cur, cmd, list, argv, max)) < 0)
  ------------------
  |  Branch (2158:6): [True: 54, False: 41.4k]
  ------------------
 2159|     54|		return argc;
 2160|       |
 2161|  41.4k|	if (argc < cmd_info->min_args) {
  ------------------
  |  Branch (2161:6): [True: 3, False: 41.3k]
  ------------------
 2162|      3|		parse_error(cur, "%s: not enough arguments\n", cmd);
 2163|      3|		return 1;
 2164|      3|	}
 2165|  41.3k|	return cmd_info->func(cur, argc, argv);
 2166|  41.4k|}
fuzz_pkcs15init.c:build_argv:
 2082|  42.7k|{
 2083|  42.7k|	unsigned int	argc;
 2084|  42.7k|	const char	*str;
 2085|  42.7k|	sc_macro_t	*macro;
 2086|  42.7k|	int		r;
 2087|       |
 2088|  96.0k|	for (argc = 0; list; list = list->next) {
  ------------------
  |  Branch (2088:17): [True: 53.3k, False: 42.6k]
  ------------------
 2089|  53.3k|		if (argc >= max) {
  ------------------
  |  Branch (2089:7): [True: 6, False: 53.3k]
  ------------------
 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|  53.3k|		str = list->data;
 2095|  53.3k|		if (str[0] != '$') {
  ------------------
  |  Branch (2095:7): [True: 52.0k, False: 1.31k]
  ------------------
 2096|       |			/* When str contains macro inside, macro reference loop needs to be checked */
 2097|  52.0k|			const char *macro_name = NULL;
 2098|  52.0k|			if ((macro_name = strchr(str, '$'))) {
  ------------------
  |  Branch (2098:8): [True: 6.38k, False: 45.6k]
  ------------------
 2099|       |				/* Macro does not have to start at the first position */
 2100|  6.38k|				char word[WORD_SIZE];
 2101|  6.38k|				if (get_inner_word(macro_name + 1, word) != 0) {
  ------------------
  |  Branch (2101:9): [True: 5, False: 6.38k]
  ------------------
 2102|      5|					return SC_ERROR_SYNTAX_ERROR;
  ------------------
  |  |  103|      5|#define SC_ERROR_SYNTAX_ERROR			-1501
  ------------------
 2103|      5|				}
 2104|  6.38k|				if ((macro = find_macro(cur->profile, word))
  ------------------
  |  Branch (2104:9): [True: 90, False: 6.29k]
  ------------------
 2105|     90|				    && check_macro_reference_loop(macro->name, macro, cur->profile, 0)) {
  ------------------
  |  Branch (2105:12): [True: 2, False: 88]
  ------------------
 2106|      2|					return SC_ERROR_SYNTAX_ERROR;
  ------------------
  |  |  103|      2|#define SC_ERROR_SYNTAX_ERROR			-1501
  ------------------
 2107|      2|				}
 2108|  6.38k|			}
 2109|       |
 2110|  52.0k|			argv[argc++] = list->data;
 2111|  52.0k|			continue;
 2112|  52.0k|		}
 2113|       |
 2114|       |		/* Expand macro reference */
 2115|  1.31k|		if (!(macro = find_macro(cur->profile, str + 1))) {
  ------------------
  |  Branch (2115:7): [True: 17, False: 1.29k]
  ------------------
 2116|     17|			parse_error(cur, "%s: unknown macro \"%s\"",
 2117|     17|					cmdname, str);
 2118|     17|			return SC_ERROR_SYNTAX_ERROR;
  ------------------
  |  |  103|     17|#define SC_ERROR_SYNTAX_ERROR			-1501
  ------------------
 2119|     17|		}
 2120|       |
 2121|  1.29k|		if (list == macro->value) {
  ------------------
  |  Branch (2121:7): [True: 0, False: 1.29k]
  ------------------
 2122|      0|			return SC_ERROR_SYNTAX_ERROR;
  ------------------
  |  |  103|      0|#define SC_ERROR_SYNTAX_ERROR			-1501
  ------------------
 2123|      0|		}
 2124|  1.29k|		if (check_macro_reference_loop(macro->name, macro, cur->profile, 0)) {
  ------------------
  |  Branch (2124:7): [True: 25, False: 1.27k]
  ------------------
 2125|     25|			return SC_ERROR_SYNTAX_ERROR;
  ------------------
  |  |  103|     25|#define SC_ERROR_SYNTAX_ERROR			-1501
  ------------------
 2126|     25|		}
 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|  1.27k|		r = build_argv(cur, cmdname, macro->value,
 2138|  1.27k|				argv + argc, max - argc);
 2139|  1.27k|		if (r < 0)
  ------------------
  |  Branch (2139:7): [True: 23, False: 1.25k]
  ------------------
 2140|     23|			return r;
 2141|       |
 2142|  1.25k|		argc += r;
 2143|  1.25k|	}
 2144|       |
 2145|  42.6k|	return argc;
 2146|  42.7k|}
fuzz_pkcs15init.c:get_inner_word:
 2024|  7.84k|{
 2025|  7.84k|	const char *inner = NULL;
 2026|  7.84k|	size_t len = 0;
 2027|       |
 2028|  7.84k|	inner = str;
 2029|       |
 2030|  40.0k|	while (is_macro_character(*inner)) {
  ------------------
  |  Branch (2030:9): [True: 32.1k, False: 7.84k]
  ------------------
 2031|  32.1k|		inner++;
 2032|  32.1k|		len++;
 2033|  32.1k|	}
 2034|  7.84k|	if (len >= WORD_SIZE)
  ------------------
  |  |   58|  7.84k|#define WORD_SIZE	64
  ------------------
  |  Branch (2034:6): [True: 9, False: 7.83k]
  ------------------
 2035|      9|		return 1;
 2036|  7.83k|	memcpy(word, str, len);
 2037|  7.83k|	word[len] = '\0';
 2038|  7.83k|	return 0;
 2039|  7.84k|}
fuzz_pkcs15init.c:is_macro_character:
 2016|   142k|{
 2017|   142k|	if (isalnum(c) || c == '-' || c == '_')
  ------------------
  |  Branch (2017:6): [True: 115k, False: 27.0k]
  |  Branch (2017:20): [True: 9.69k, False: 17.4k]
  |  Branch (2017:32): [True: 221, False: 17.1k]
  ------------------
 2018|   125k|		return 1;
 2019|  17.1k|	return 0;
 2020|   142k|}
fuzz_pkcs15init.c:find_macro:
 1898|  18.4k|{
 1899|  18.4k|	sc_macro_t	*mac;
 1900|       |
 1901|   167k|	for (mac = profile->macro_list; mac; mac = mac->next) {
  ------------------
  |  Branch (1901:34): [True: 158k, False: 9.56k]
  ------------------
 1902|   158k|		if (!strcmp(mac->name, name))
  ------------------
  |  Branch (1902:7): [True: 8.85k, False: 149k]
  ------------------
 1903|  8.85k|			return mac;
 1904|   158k|	}
 1905|  9.56k|	return NULL;
 1906|  18.4k|}
fuzz_pkcs15init.c:check_macro_reference_loop:
 2047|  2.34k|{
 2048|  2.34k|	scconf_list *value;
 2049|  2.34k|	const char *name = NULL;
 2050|  2.34k|	sc_macro_t	*m;
 2051|  2.34k|	char word[WORD_SIZE];
 2052|       |
 2053|  2.34k|	if (!start_name || !macro || !profile || depth == 16)
  ------------------
  |  Branch (2053:6): [True: 0, False: 2.34k]
  |  Branch (2053:21): [True: 0, False: 2.34k]
  |  Branch (2053:31): [True: 0, False: 2.34k]
  |  Branch (2053:43): [True: 16, False: 2.33k]
  ------------------
 2054|     16|		return 1;
 2055|       |
 2056|       |	/* For some reason, the macro value is a list where we need to check for references */
 2057|  5.57k|	for (value = macro->value; value != NULL; value = value->next) {
  ------------------
  |  Branch (2057:29): [True: 3.52k, False: 2.05k]
  ------------------
 2058|       |		/* Find name in macro value */
 2059|  3.52k|		char *macro_value = value->data;
 2060|  3.52k|		if (!(name = strchr(macro_value, '$')))
  ------------------
  |  Branch (2060:7): [True: 2.06k, False: 1.45k]
  ------------------
 2061|  2.06k|			continue;
 2062|       |		/* Extract the macro name from the string */
 2063|  1.45k|		if (get_inner_word(name + 1, word))
  ------------------
  |  Branch (2063:7): [True: 4, False: 1.45k]
  ------------------
 2064|      4|			return 1;
 2065|       |		/* Find whether name corresponds to some other macro */
 2066|  1.45k|		if (!(m = find_macro(profile, word)))
  ------------------
  |  Branch (2066:7): [True: 486, False: 965]
  ------------------
 2067|    486|			continue;
 2068|       |		/* Check for loop */
 2069|    965|		if (!strcmp(m->name, start_name))
  ------------------
  |  Branch (2069:7): [True: 7, False: 958]
  ------------------
 2070|      7|			return 1;
 2071|       |		/* Reference loop was found to the original macro name */
 2072|    958|		if (check_macro_reference_loop(start_name, m, profile, depth + 1) == 1) {
  ------------------
  |  Branch (2072:7): [True: 265, False: 693]
  ------------------
 2073|    265|			return 1;
 2074|    265|		}
 2075|    958|	}
 2076|  2.05k|	return 0;
 2077|  2.33k|}
fuzz_pkcs15init.c:process_df:
 1022|  18.6k|{
 1023|  18.6k|	struct state	state;
 1024|       |
 1025|  18.6k|	init_state(cur, &state);
 1026|  18.6k|	if (name == NULL) {
  ------------------
  |  Branch (1026:6): [True: 0, False: 18.6k]
  ------------------
 1027|      0|		parse_error(cur, "No name given for DF object.");
 1028|      0|		return 1;
 1029|      0|	}
 1030|  18.6k|	if (!(state.file = new_file(cur, name, SC_FILE_TYPE_DF)))
  ------------------
  |  |  214|  18.6k|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (1030:6): [True: 237, False: 18.3k]
  ------------------
 1031|    237|		return 1;
 1032|  18.3k|	return process_block(&state, info, name, blk);
 1033|  18.6k|}
fuzz_pkcs15init.c:init_state:
  836|  38.7k|{
  837|  38.7k|	memset(new_state, 0, sizeof(*new_state));
  838|  38.7k|	new_state->filename = cur_state->filename;
  839|  38.7k|	new_state->profile = cur_state->profile;
  840|  38.7k|	new_state->frame = cur_state;
  841|  38.7k|}
fuzz_pkcs15init.c:new_file:
 1233|  29.4k|{
 1234|  29.4k|	sc_profile_t	*profile = cur->profile;
 1235|  29.4k|	struct file_info	*info;
 1236|  29.4k|	sc_file_t	*file;
 1237|  29.4k|	unsigned int	df_type = 0, dont_free = 0;
 1238|  29.4k|	int	free_file = 0;
 1239|       |
 1240|  29.4k|	if ((info = sc_profile_find_file(profile, NULL, name)) != NULL)
  ------------------
  |  Branch (1240:6): [True: 4.35k, False: 25.1k]
  ------------------
 1241|  4.35k|		return info;
 1242|       |
 1243|       |	/* Special cases for those EFs handled separately
 1244|       |	 * by the PKCS15 logic */
 1245|  25.1k|	if (strncasecmp(name, "PKCS15-", 7)) {
  ------------------
  |  Branch (1245:6): [True: 15.7k, False: 9.37k]
  ------------------
 1246|  15.7k|		file = init_file(type);
 1247|  15.7k|		free_file = 1;
 1248|  15.7k|	} else if (!strcasecmp(name+7, "TokenInfo")) {
  ------------------
  |  Branch (1248:13): [True: 86, False: 9.29k]
  ------------------
 1249|     86|		if (!profile->p15_spec) {
  ------------------
  |  Branch (1249:7): [True: 1, False: 85]
  ------------------
 1250|      1|			parse_error(cur, "no pkcs15 spec in profile");
 1251|      1|			return NULL;
 1252|      1|		}
 1253|     85|		file = profile->p15_spec->file_tokeninfo;
 1254|     85|		dont_free = 1;
 1255|  9.29k|	} else if (!strcasecmp(name+7, "ODF")) {
  ------------------
  |  Branch (1255:13): [True: 250, False: 9.04k]
  ------------------
 1256|    250|		if (!profile->p15_spec) {
  ------------------
  |  Branch (1256:7): [True: 1, False: 249]
  ------------------
 1257|      1|			parse_error(cur, "no pkcs15 spec in profile");
 1258|      1|			return NULL;
 1259|      1|		}
 1260|    249|		file = profile->p15_spec->file_odf;
 1261|    249|		dont_free = 1;
 1262|  9.04k|	} else if (!strcasecmp(name+7, "UnusedSpace")) {
  ------------------
  |  Branch (1262:13): [True: 72, False: 8.96k]
  ------------------
 1263|     72|		if (!profile->p15_spec) {
  ------------------
  |  Branch (1263:7): [True: 1, False: 71]
  ------------------
 1264|      1|			parse_error(cur, "no pkcs15 spec in profile");
 1265|      1|			return NULL;
 1266|      1|		}
 1267|     71|		file = profile->p15_spec->file_unusedspace;
 1268|     71|		dont_free = 1;
 1269|  8.96k|	} else if (!strcasecmp(name+7, "AppDF")) {
  ------------------
  |  Branch (1269:13): [True: 7.35k, False: 1.61k]
  ------------------
 1270|  7.35k|		file = init_file(SC_FILE_TYPE_DF);
  ------------------
  |  |  214|  7.35k|#define SC_FILE_TYPE_DF			0x04
  ------------------
 1271|  7.35k|		free_file = 1;
 1272|  7.35k|	} else {
 1273|  1.61k|		if (map_str2int(cur, name+7, &df_type, pkcs15DfNames)
  ------------------
  |  Branch (1273:7): [True: 217, False: 1.39k]
  ------------------
 1274|  1.39k|				|| df_type >= SC_PKCS15_DF_TYPE_COUNT)
  ------------------
  |  |  497|  1.39k|#define SC_PKCS15_DF_TYPE_COUNT		9
  ------------------
  |  Branch (1274:8): [True: 18, False: 1.38k]
  ------------------
 1275|    235|			return NULL;
 1276|       |
 1277|  1.38k|		file = init_file(SC_FILE_TYPE_WORKING_EF);
  ------------------
  |  |  216|  1.38k|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
 1278|  1.38k|		profile->df[df_type] = file;
 1279|  1.38k|		free_file = 1;
 1280|  1.38k|	}
 1281|  24.8k|	if (!file)
  ------------------
  |  Branch (1281:6): [True: 0, False: 24.8k]
  ------------------
 1282|      0|		return NULL;
 1283|  24.8k|	if (file->type != type) {
  ------------------
  |  Branch (1283:6): [True: 9, False: 24.8k]
  ------------------
 1284|      9|		parse_error(cur, "inconsistent file type (should be %s)",
 1285|      9|			file->type == SC_FILE_TYPE_DF
  ------------------
  |  |  214|      9|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (1285:4): [True: 1, False: 8]
  ------------------
 1286|      9|				? "DF" : file->type == SC_FILE_TYPE_BSO
  ------------------
  |  |  217|      8|#define SC_FILE_TYPE_BSO		0x10
  ------------------
  |  Branch (1286:14): [True: 0, False: 8]
  ------------------
 1287|      8|					? "BS0" : "EF");
 1288|      9|		if (free_file)
  ------------------
  |  Branch (1288:7): [True: 6, False: 3]
  ------------------
 1289|      6|			sc_file_free(file);
 1290|      9|		return NULL;
 1291|      9|	}
 1292|       |
 1293|  24.8k|	info = add_file(profile, name, file, cur->file);
 1294|  24.8k|	if (info == NULL) {
  ------------------
  |  Branch (1294:6): [True: 0, False: 24.8k]
  ------------------
 1295|      0|		parse_error(cur, "memory allocation failed");
 1296|      0|		return NULL;
 1297|      0|	}
 1298|  24.8k|	info->dont_free = dont_free;
 1299|  24.8k|	return info;
 1300|  24.8k|}
fuzz_pkcs15init.c:map_str2int:
 2430|  38.7k|{
 2431|  38.7k|	unsigned int	n;
 2432|  38.7k|	const char	*what;
 2433|       |
 2434|  38.7k|	if (isdigit((unsigned char) *value))
  ------------------
  |  Branch (2434:6): [True: 4.31k, False: 34.3k]
  ------------------
 2435|  4.31k|		return get_uint(cur, value, vp);
 2436|   169k|	for (n = 0; map[n].name; n++) {
  ------------------
  |  Branch (2436:14): [True: 169k, False: 408]
  ------------------
 2437|   169k|		if (!strcasecmp(value, map[n].name)) {
  ------------------
  |  Branch (2437:7): [True: 33.9k, False: 135k]
  ------------------
 2438|  33.9k|			*vp = map[n].val;
 2439|  33.9k|			return 0;
 2440|  33.9k|		}
 2441|   169k|	}
 2442|       |
 2443|       |	/* Try to print a meaningful error message */
 2444|    408|	what = "argument";
 2445|  2.16k|	for (n = 0; mapNames[n].name; n++) {
  ------------------
  |  Branch (2445:14): [True: 2.16k, False: 3]
  ------------------
 2446|  2.16k|		if (mapNames[n].addr == map) {
  ------------------
  |  Branch (2446:7): [True: 405, False: 1.75k]
  ------------------
 2447|    405|			what = mapNames[n].name;
 2448|    405|			break;
 2449|    405|		}
 2450|  2.16k|	}
 2451|       |
 2452|    408|	parse_error(cur, "invalid %s \"%s\"\n", what, value);
 2453|    408|	return SC_ERROR_SYNTAX_ERROR;
  ------------------
  |  |  103|    408|#define SC_ERROR_SYNTAX_ERROR			-1501
  ------------------
 2454|  34.3k|}
fuzz_pkcs15init.c:get_uint:
 2386|  16.2k|{
 2387|  16.2k|	char	*ep;
 2388|  16.2k|	unsigned long tmp;
 2389|       |
 2390|  16.2k|	if (strstr(value, "0x") == value)
  ------------------
  |  Branch (2390:6): [True: 828, False: 15.4k]
  ------------------
 2391|    828|		tmp = strtoul(value + 2, &ep, 16);
 2392|  15.4k|	else if (strstr(value, "x") == value)
  ------------------
  |  Branch (2392:11): [True: 460, False: 14.9k]
  ------------------
 2393|    460|		tmp = strtoul(value + 1, &ep, 16);
 2394|  14.9k|	else
 2395|  14.9k|		tmp = strtoul(value, &ep, 0);
 2396|  16.2k|	if (*ep != '\0') {
  ------------------
  |  Branch (2396:6): [True: 263, False: 15.9k]
  ------------------
 2397|    263|		parse_error(cur, "invalid integer argument \"%s\"\n", value);
 2398|    263|		return 1;
 2399|    263|	}
 2400|  15.9k|	if (tmp > INT_MAX) {
  ------------------
  |  Branch (2400:6): [True: 71, False: 15.9k]
  ------------------
 2401|     71|		parse_error(cur, "the number \"%s\" is too large\n", value);
 2402|     71|		return 1;
 2403|     71|	}
 2404|  15.9k|	*vp = (int)tmp;
 2405|  15.9k|	return 0;
 2406|  15.9k|}
fuzz_pkcs15init.c:do_file_type:
 1304|  2.69k|{
 1305|  2.69k|	unsigned int	type;
 1306|       |
 1307|  2.69k|	if (!cur->file) {
  ------------------
  |  Branch (1307:6): [True: 1, False: 2.69k]
  ------------------
 1308|      1|		parse_error(cur, "Invalid state\n");
 1309|      1|		return 1;
 1310|      1|	}
 1311|       |
 1312|  2.69k|	if (map_str2int(cur, argv[0], &type, fileTypeNames))
  ------------------
  |  Branch (1312:6): [True: 3, False: 2.68k]
  ------------------
 1313|      3|		return 1;
 1314|  2.68k|	cur->file->file->type = type;
 1315|  2.68k|	return 0;
 1316|  2.69k|}
fuzz_pkcs15init.c:do_file_path:
 1320|  3.68k|{
 1321|  3.68k|	struct sc_file	*file = NULL;
 1322|  3.68k|	struct sc_path	*path = NULL;
 1323|       |
 1324|  3.68k|	if (!cur->file) {
  ------------------
  |  Branch (1324:6): [True: 1, False: 3.68k]
  ------------------
 1325|      1|		parse_error(cur, "Invalid state\n");
 1326|      1|		return 1;
 1327|      1|	}
 1328|  3.68k|	file = cur->file->file;
 1329|  3.68k|	path = &file->path;
 1330|       |
 1331|       |	/* sc_format_path doesn't return an error indication
 1332|       |	 * when it's unable to parse the path */
 1333|  3.68k|	sc_format_path(argv[0], path);
 1334|  3.68k|	if (!path->len || (path->len & 1)) {
  ------------------
  |  Branch (1334:6): [True: 27, False: 3.65k]
  |  Branch (1334:20): [True: 14, False: 3.64k]
  ------------------
 1335|     41|		parse_error(cur, "Invalid path length\n");
 1336|     41|		return 1;
 1337|     41|	}
 1338|  3.64k|	file->id = (path->value[path->len-2] << 8) | path->value[path->len-1];
 1339|  3.64k|	return 0;
 1340|  3.68k|}
fuzz_pkcs15init.c:do_fileid:
 1344|  7.78k|{
 1345|  7.78k|	struct file_info *fi;
 1346|  7.78k|	struct sc_file	*df, *file = NULL;
 1347|  7.78k|	struct sc_path	temp, *path = NULL;
 1348|       |
 1349|  7.78k|	if (!cur->file) {
  ------------------
  |  Branch (1349:6): [True: 1, False: 7.78k]
  ------------------
 1350|      1|		parse_error(cur, "Invalid state\n");
 1351|      1|		return 1;
 1352|      1|	}
 1353|  7.78k|	file = cur->file->file;
 1354|  7.78k|	path = &file->path;
 1355|       |
 1356|       |	/* sc_format_path doesn't return an error indication
 1357|       |	 * when it's unable to parse the path */
 1358|  7.78k|	sc_format_path(argv[0], &temp);
 1359|  7.78k|	if (temp.len != 2) {
  ------------------
  |  Branch (1359:6): [True: 19, False: 7.76k]
  ------------------
 1360|     19|		parse_error(cur, "Invalid file ID length\n");
 1361|     19|		return 1;
 1362|     19|	}
 1363|       |
 1364|       |	/* Get the DF, if any */
 1365|  7.76k|	if ((fi = cur->file->parent) && (df = fi->file)) {
  ------------------
  |  Branch (1365:6): [True: 5.76k, False: 1.99k]
  |  Branch (1365:34): [True: 5.76k, False: 0]
  ------------------
 1366|  5.76k|		if (!df->path.len && !df->path.aid.len) {
  ------------------
  |  Branch (1366:7): [True: 117, False: 5.64k]
  |  Branch (1366:24): [True: 2, False: 115]
  ------------------
 1367|      2|			parse_error(cur, "No path/fileid set for parent DF\n");
 1368|      2|			return 1;
 1369|      2|		}
 1370|  5.76k|		if (df->path.len + 2 > sizeof(df->path.value)) {
  ------------------
  |  Branch (1370:7): [True: 1, False: 5.76k]
  ------------------
 1371|      1|			parse_error(cur, "File path too long\n");
 1372|      1|			return 1;
 1373|      1|		}
 1374|  5.76k|		*path = df->path;
 1375|  5.76k|	}
 1376|  7.75k|	if (path->len + 2 > sizeof(path->value)) {
  ------------------
  |  Branch (1376:6): [True: 4, False: 7.75k]
  ------------------
 1377|      4|		parse_error(cur, "File path too long\n");
 1378|      4|		return 1;
 1379|      4|	}
 1380|  7.75k|	memcpy(path->value + path->len, temp.value, 2);
 1381|  7.75k|	path->len += 2;
 1382|       |
 1383|  7.75k|	file->id = (temp.value[0] << 8) | temp.value[1];
 1384|  7.75k|	return 0;
 1385|  7.75k|}
fuzz_pkcs15init.c:do_structure:
 1389|  1.67k|{
 1390|  1.67k|	unsigned int	ef_structure;
 1391|       |
 1392|  1.67k|	if (!cur->file) {
  ------------------
  |  Branch (1392:6): [True: 1, False: 1.67k]
  ------------------
 1393|      1|		parse_error(cur, "Invalid state\n");
 1394|      1|		return 1;
 1395|      1|	}
 1396|       |
 1397|  1.67k|	if (map_str2int(cur, argv[0], &ef_structure, fileStructureNames))
  ------------------
  |  Branch (1397:6): [True: 2, False: 1.66k]
  ------------------
 1398|      2|		return 1;
 1399|  1.66k|	cur->file->file->ef_structure = ef_structure;
 1400|  1.66k|	return 0;
 1401|  1.67k|}
fuzz_pkcs15init.c:do_size:
 1405|  2.15k|{
 1406|  2.15k|	unsigned int	size;
 1407|       |
 1408|  2.15k|	if (!cur->file) {
  ------------------
  |  Branch (1408:6): [True: 1, False: 2.15k]
  ------------------
 1409|      1|		parse_error(cur, "Invalid state\n");
 1410|      1|		return 1;
 1411|      1|	}
 1412|       |
 1413|  2.15k|	if (get_uint_eval(cur, argc, argv, &size))
  ------------------
  |  Branch (1413:6): [True: 229, False: 1.92k]
  ------------------
 1414|    229|		return 1;
 1415|  1.92k|	cur->file->file->size = size;
 1416|  1.92k|	return 0;
 1417|  2.15k|}
fuzz_pkcs15init.c:get_uint_eval:
 2677|  2.16k|{
 2678|  2.16k|	struct num_exp_ctx	ctx;
 2679|       |
 2680|  2.16k|	memset(&ctx, 0, sizeof(ctx));
 2681|  2.16k|	ctx.state = cur;
 2682|  2.16k|	ctx.argc  = argc;
 2683|  2.16k|	ctx.argv  = argv;
 2684|       |
 2685|  2.16k|	if (setjmp(ctx.error)) {
  ------------------
  |  Branch (2685:6): [True: 232, False: 1.93k]
  ------------------
 2686|    232|		parse_error(cur, "invalid numeric expression\n");
 2687|    232|		return SC_ERROR_SYNTAX_ERROR;
  ------------------
  |  |  103|    232|#define SC_ERROR_SYNTAX_ERROR			-1501
  ------------------
 2688|    232|	}
 2689|       |
 2690|  1.93k|	expr_eval(&ctx, vp, 0, 0);
 2691|  1.93k|	if (ctx.str[0] || ctx.argc)
  ------------------
  |  Branch (2691:6): [True: 18.4E, False: 1.93k]
  |  Branch (2691:20): [True: 2, False: 1.93k]
  ------------------
 2692|     28|		expr_fail(&ctx);
 2693|       |
 2694|  1.93k|	return 0;
 2695|  2.16k|}
fuzz_pkcs15init.c:expr_eval:
 2616|  5.67k|{
 2617|  5.67k|	unsigned int	left, right, new_pri;
 2618|  5.67k|	char		*tok, op;
 2619|       |
 2620|  5.67k|	expr_term(ctx, &left, opening_brackets);
 2621|       |
 2622|  8.01k|	while (1) {
  ------------------
  |  Branch (2622:9): [True: 7.40k, Folded]
  ------------------
 2623|  7.40k|		tok = __expr_get(ctx, 1);
 2624|  7.40k|		if (tok == NULL)
  ------------------
  |  Branch (2624:7): [True: 2.25k, False: 5.15k]
  ------------------
 2625|  2.25k|			break;
 2626|       |
 2627|  5.15k|		op = tok[0];
 2628|       |
 2629|  5.15k|		new_pri = 0;
 2630|  5.15k|		switch (op) {
 2631|    631|		case '*':
  ------------------
  |  Branch (2631:3): [True: 631, False: 4.52k]
  ------------------
 2632|  1.35k|		case '/':
  ------------------
  |  Branch (2632:3): [True: 719, False: 4.43k]
  ------------------
 2633|  1.35k|			new_pri++;
 2634|       |			/* fall through */
 2635|  2.29k|		case '+':
  ------------------
  |  Branch (2635:3): [True: 942, False: 4.21k]
  ------------------
 2636|  3.25k|		case '-':
  ------------------
  |  Branch (2636:3): [True: 963, False: 4.19k]
  ------------------
 2637|  3.25k|			new_pri++;
 2638|       |			/* fall through */
 2639|  3.91k|		case '&':
  ------------------
  |  Branch (2639:3): [True: 664, False: 4.49k]
  ------------------
 2640|  3.91k|			new_pri++;
 2641|       |			/* fall through */
 2642|  4.55k|		case '|':
  ------------------
  |  Branch (2642:3): [True: 634, False: 4.52k]
  ------------------
 2643|  4.55k|			new_pri++;
 2644|       |			/* fall through */
 2645|  5.12k|		case ')':
  ------------------
  |  Branch (2645:3): [True: 568, False: 4.58k]
  ------------------
 2646|  5.12k|			break;
 2647|     14|		default:
  ------------------
  |  Branch (2647:3): [True: 14, False: 5.14k]
  ------------------
 2648|     14|			expr_fail(ctx);
 2649|  5.15k|		}
 2650|       |
 2651|  5.12k|		if (new_pri < pri) {
  ------------------
  |  Branch (2651:7): [True: 2.56k, False: 2.55k]
  ------------------
 2652|  2.56k|			expr_unget(ctx, tok);
 2653|  2.56k|			break;
 2654|  2.56k|		}
 2655|  2.55k|		pri = new_pri;
 2656|       |
 2657|  2.55k|		expr_eval(ctx, &right, new_pri + 1, opening_brackets);
 2658|  2.55k|		switch (op) {
 2659|    344|		case '*': left *= right; break;
  ------------------
  |  Branch (2659:3): [True: 344, False: 2.21k]
  ------------------
 2660|    365|		case '/':
  ------------------
  |  Branch (2660:3): [True: 365, False: 2.18k]
  ------------------
 2661|    365|			if (right == 0)
  ------------------
  |  Branch (2661:8): [True: 5, False: 360]
  ------------------
 2662|      5|				expr_fail(ctx);
 2663|    365|			left /= right; break;
 2664|    491|		case '+': left += right; break;
  ------------------
  |  Branch (2664:3): [True: 491, False: 2.06k]
  ------------------
 2665|    484|		case '-': left -= right; break;
  ------------------
  |  Branch (2665:3): [True: 484, False: 2.07k]
  ------------------
 2666|    350|		case '&': left &= right; break;
  ------------------
  |  Branch (2666:3): [True: 350, False: 2.20k]
  ------------------
 2667|    308|		case '|': left |= right; break;
  ------------------
  |  Branch (2667:3): [True: 308, False: 2.24k]
  ------------------
 2668|      2|		default: expr_fail(ctx);
  ------------------
  |  Branch (2668:3): [True: 2, False: 2.55k]
  ------------------
 2669|  2.55k|		}
 2670|  2.55k|	}
 2671|       |
 2672|  5.42k|	*vp = left;
 2673|  5.42k|}
fuzz_pkcs15init.c:expr_term:
 2574|  5.67k|{
 2575|  5.67k|	char	*tok;
 2576|       |
 2577|  5.67k|	tok = expr_get(ctx);
 2578|  5.67k|	if (*tok == '(') {
  ------------------
  |  Branch (2578:6): [True: 955, False: 4.72k]
  ------------------
 2579|    955|		if (opening_brackets + 1 > MAX_BRACKETS) {
  ------------------
  |  | 2571|    955|#define MAX_BRACKETS 32
  ------------------
  |  Branch (2579:7): [True: 2, False: 953]
  ------------------
 2580|      2|			parse_error(ctx->state, "Too many \"%s\" in expression", tok);
 2581|      2|			expr_fail(ctx);
 2582|      2|		}
 2583|    955|		expr_eval(ctx, vp, 1, opening_brackets + 1);
 2584|    955|		expr_expect(ctx, ')');
 2585|    955|	}
 2586|  4.72k|	else if (isdigit((unsigned char)*tok)) {
  ------------------
  |  Branch (2586:11): [True: 4.61k, False: 111]
  ------------------
 2587|  4.61k|		char	*ep;
 2588|  4.61k|		unsigned long tmp;
 2589|       |
 2590|  4.61k|		tmp = strtoul(tok, &ep, 0);
 2591|  4.61k|		if (*ep)
  ------------------
  |  Branch (2591:7): [True: 2, False: 4.60k]
  ------------------
 2592|      2|			expr_fail(ctx);
 2593|  4.61k|		if (tmp > UINT_MAX)
  ------------------
  |  Branch (2593:7): [True: 53, False: 4.55k]
  ------------------
 2594|     53|			expr_fail(ctx);
 2595|  4.61k|		*vp = (unsigned int)tmp;
 2596|  4.61k|	}
 2597|    111|	else if (*tok == '$') {
  ------------------
  |  Branch (2597:11): [True: 27, False: 84]
  ------------------
 2598|     27|		sc_macro_t	*mac;
 2599|     27|		char		*argv[32];
 2600|     27|		int		argc;
 2601|       |
 2602|     27|		if (!(mac = find_macro(ctx->state->profile, tok + 1)))
  ------------------
  |  Branch (2602:7): [True: 8, False: 19]
  ------------------
 2603|      8|			expr_fail(ctx);
 2604|     27|		argc = build_argv(ctx->state, "<expr>", mac->value, argv, 32);
 2605|     27|		if (argc < 0 || get_uint_eval(ctx->state, argc, argv, vp) < 0)
  ------------------
  |  Branch (2605:7): [True: 9, False: 18]
  |  Branch (2605:19): [True: 3, False: 15]
  ------------------
 2606|      4|			expr_fail(ctx);
 2607|     27|	}
 2608|     84|	else {
 2609|     84|		parse_error(ctx->state, "Unexpected token \"%s\" in expression", tok);
 2610|     84|		expr_fail(ctx);
 2611|     84|	}
 2612|  5.67k|}
fuzz_pkcs15init.c:expr_get:
 2549|  6.18k|{
 2550|  6.18k|	return __expr_get(ctx, 0);
 2551|  6.18k|}
fuzz_pkcs15init.c:expr_expect:
 2563|    508|{
 2564|    508|	char	*tok;
 2565|       |
 2566|    508|	tok = expr_get(ctx);
 2567|    508|	if (tok[0] != (char)c || tok[1])
  ------------------
  |  Branch (2567:6): [True: 9, False: 499]
  |  Branch (2567:27): [True: 0, False: 499]
  ------------------
 2568|      3|		expr_fail(ctx);
 2569|    508|}
fuzz_pkcs15init.c:__expr_get:
 2501|  13.5k|{
 2502|  13.5k|	char	*s;
 2503|       |
 2504|  13.5k|	if ((s = ctx->unget) != NULL) {
  ------------------
  |  Branch (2504:6): [True: 2.53k, False: 11.0k]
  ------------------
 2505|  2.53k|		ctx->unget = NULL;
 2506|  2.53k|		return s;
 2507|  2.53k|	}
 2508|       |
 2509|  11.0k|	ctx->j = 0;
 2510|  11.0k|	s = ctx->str;
 2511|  11.1k|	do {
 2512|  11.1k|		if (s == NULL || *s == '\0') {
  ------------------
  |  Branch (2512:7): [True: 2.16k, False: 8.97k]
  |  Branch (2512:20): [True: 2.38k, False: 6.59k]
  ------------------
 2513|  4.55k|			if (ctx->argc == 0) {
  ------------------
  |  Branch (2513:8): [True: 2.31k, False: 2.24k]
  ------------------
 2514|  2.31k|				if (eof_okay)
  ------------------
  |  Branch (2514:9): [True: 2.25k, False: 62]
  ------------------
 2515|  2.25k|					return NULL;
 2516|     62|				expr_fail(ctx);
 2517|     62|			}
 2518|  2.30k|			ctx->str = s = *(ctx->argv++);
 2519|  2.30k|			ctx->argc--;
 2520|  2.30k|		}
 2521|       |
 2522|  8.89k|		while (isspace((unsigned char)*s))
  ------------------
  |  Branch (2522:10): [True: 629, False: 8.89k]
  ------------------
 2523|    629|			s++;
 2524|  8.89k|	} while (*s == '\0');
  ------------------
  |  Branch (2524:11): [True: 91, False: 8.80k]
  ------------------
 2525|       |
 2526|  8.80k|	if (isdigit((unsigned char)*s)) {
  ------------------
  |  Branch (2526:6): [True: 4.61k, False: 4.19k]
  ------------------
 2527|  4.61k|		while (isdigit((unsigned char)*s))
  ------------------
  |  Branch (2527:10): [True: 10.9k, False: 4.61k]
  ------------------
 2528|  10.9k|			expr_put(ctx, *s++);
 2529|  4.61k|	}
 2530|  4.19k|	else if (*s == '$') {
  ------------------
  |  Branch (2530:11): [True: 38, False: 4.15k]
  ------------------
 2531|     38|		expr_put(ctx, *s++);
 2532|    359|		while (is_macro_character(*s))
  ------------------
  |  Branch (2532:10): [True: 321, False: 38]
  ------------------
 2533|    321|			expr_put(ctx, *s++);
 2534|     38|	}
 2535|  4.15k|	else if (strchr("*/+-()|&", *s)) {
  ------------------
  |  Branch (2535:11): [True: 4.05k, False: 103]
  ------------------
 2536|  4.05k|		expr_put(ctx, *s++);
 2537|  4.05k|	}
 2538|    103|	else {
 2539|    103|		expr_fail(ctx);
 2540|    103|	}
 2541|  8.80k|	ctx->str = s;
 2542|       |
 2543|  8.80k|	expr_put(ctx, '\0');
 2544|  8.80k|	return ctx->word;
 2545|  11.0k|}
fuzz_pkcs15init.c:expr_put:
 2493|  24.0k|{
 2494|  24.0k|	if (ctx->j >= (int)sizeof(ctx->word))
  ------------------
  |  Branch (2494:6): [True: 1, False: 24.0k]
  ------------------
 2495|      1|		expr_fail(ctx);
 2496|  24.0k|	ctx->word[ctx->j++] = (char)c;
 2497|  24.0k|}
fuzz_pkcs15init.c:expr_unget:
 2555|  2.56k|{
 2556|  2.56k|	if (ctx->unget)
  ------------------
  |  Branch (2556:6): [True: 0, False: 2.56k]
  ------------------
 2557|      0|		expr_fail(ctx);
 2558|  2.56k|	ctx->unget = s;
 2559|  2.56k|}
fuzz_pkcs15init.c:expr_fail:
 2487|    232|{
 2488|    232|	longjmp(ctx->error, 1);
 2489|    232|}
fuzz_pkcs15init.c:do_reclength:
 1421|     20|{
 1422|     20|	unsigned int	reclength;
 1423|       |
 1424|     20|	if (!cur->file) {
  ------------------
  |  Branch (1424:6): [True: 1, False: 19]
  ------------------
 1425|      1|		parse_error(cur, "Invalid state\n");
 1426|      1|		return 1;
 1427|      1|	}
 1428|       |
 1429|     19|	if (get_uint(cur, argv[0], &reclength))
  ------------------
  |  Branch (1429:6): [True: 1, False: 18]
  ------------------
 1430|      1|		return 1;
 1431|     18|	cur->file->file->record_length = reclength;
 1432|     18|	return 0;
 1433|     19|}
fuzz_pkcs15init.c:do_aid:
 1482|    311|{
 1483|    311|	struct sc_file	*file = NULL;
 1484|    311|	const char	*name = argv[0];
 1485|    311|	size_t len;
 1486|    311|	int		res = 0;
 1487|       |
 1488|    311|	if (!cur->file) {
  ------------------
  |  Branch (1488:6): [True: 1, False: 310]
  ------------------
 1489|      1|		parse_error(cur, "Invalid state\n");
 1490|      1|		return 1;
 1491|      1|	}
 1492|    310|	file = cur->file->file;
 1493|       |
 1494|    310|	if (*name == '=') {
  ------------------
  |  Branch (1494:6): [True: 31, False: 279]
  ------------------
 1495|     31|		len = strlen(++name);
 1496|     31|		if (len > sizeof(file->name)) {
  ------------------
  |  Branch (1496:7): [True: 1, False: 30]
  ------------------
 1497|      1|			parse_error(cur, "AID \"%s\" too long\n", name);
 1498|      1|			return 1;
 1499|      1|		}
 1500|     30|		memcpy(file->name, name, len);
 1501|     30|		file->namelen = len;
 1502|     30|	}
 1503|    279|	else {
 1504|    279|		file->namelen = sizeof(file->name);
 1505|    279|		res = sc_hex_to_bin(name, file->name, &file->namelen);
 1506|    279|	}
 1507|    309|	return res;
 1508|    310|}
fuzz_pkcs15init.c:do_acl:
 1579|  3.66k|{
 1580|  3.66k|	struct sc_file	*file = NULL;
 1581|  3.66k|	char		oper[64], *what = NULL;
 1582|  3.66k|	memset(oper, 0, sizeof(oper));
 1583|       |
 1584|  3.66k|	if (!cur->file)
  ------------------
  |  Branch (1584:6): [True: 1, False: 3.65k]
  ------------------
 1585|      1|		goto bad;
 1586|  3.65k|	file = cur->file->file;
 1587|       |
 1588|  16.4k|	while (argc--) {
  ------------------
  |  Branch (1588:9): [True: 12.9k, False: 3.54k]
  ------------------
 1589|  12.9k|		unsigned int	op, method, id;
 1590|       |
 1591|  12.9k|		if (strlen(*argv) >= sizeof(oper))
  ------------------
  |  Branch (1591:7): [True: 4, False: 12.9k]
  ------------------
 1592|      4|			goto bad;
 1593|  12.9k|		strlcpy(oper, *argv++, sizeof(oper));
  ------------------
  |  |   43|  12.9k|#define strlcpy _strlcpy
  ------------------
 1594|       |
 1595|  12.9k|		if ((what = strchr(oper, '=')) == NULL)
  ------------------
  |  Branch (1595:7): [True: 28, False: 12.8k]
  ------------------
 1596|     28|			goto bad;
 1597|  12.8k|		*what++ = '\0';
 1598|       |
 1599|  12.8k|		if (*what == '$') {
  ------------------
  |  Branch (1599:7): [True: 5.94k, False: 6.95k]
  ------------------
 1600|  5.94k|			method = SC_AC_SYMBOLIC;
  ------------------
  |  |  155|  5.94k|#define SC_AC_SYMBOLIC			0x00000010 /* internal use only */
  ------------------
 1601|  5.94k|			if (map_str2int(cur, what+1, &id, pinIdNames))
  ------------------
  |  Branch (1601:8): [True: 5, False: 5.93k]
  ------------------
 1602|      5|				return 1;
 1603|  5.94k|		}
 1604|  6.95k|		else if (get_authid(cur, what, &method, &id))
  ------------------
  |  Branch (1604:12): [True: 54, False: 6.89k]
  ------------------
 1605|     54|			goto bad;
 1606|       |
 1607|       |
 1608|  12.8k|		if (!strcmp(oper, "*")) {
  ------------------
  |  Branch (1608:7): [True: 2.42k, False: 10.4k]
  ------------------
 1609|  77.6k|			for (op = 0; op < SC_MAX_AC_OPS; op++) {
  ------------------
  |  |  198|  77.6k|#define SC_MAX_AC_OPS			31
  ------------------
  |  Branch (1609:17): [True: 75.2k, False: 2.42k]
  ------------------
 1610|  75.2k|				sc_file_clear_acl_entries(file, op);
 1611|  75.2k|				sc_file_add_acl_entry(file, op, method, id);
 1612|  75.2k|			}
 1613|  10.4k|		} else {
 1614|  10.4k|			const sc_acl_entry_t *acl;
 1615|       |
 1616|  10.4k|			if (map_str2int(cur, oper, &op, fileOpNames))
  ------------------
  |  Branch (1616:8): [True: 7, False: 10.4k]
  ------------------
 1617|      7|				goto bad;
 1618|  10.4k|			if (!(acl = sc_file_get_acl_entry(file, op)))
  ------------------
  |  Branch (1618:8): [True: 17, False: 10.3k]
  ------------------
 1619|     17|				goto bad;
 1620|  10.3k|			if (acl->method == SC_AC_NEVER
  ------------------
  |  |  163|  20.7k|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (1620:8): [True: 2.96k, False: 7.42k]
  ------------------
 1621|  7.42k|			 || acl->method == SC_AC_NONE
  ------------------
  |  |  150|  17.8k|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (1621:8): [True: 4.44k, False: 2.97k]
  ------------------
 1622|  2.97k|			 || acl->method == SC_AC_UNKNOWN)
  ------------------
  |  |  162|  2.97k|#define SC_AC_UNKNOWN			0xFFFFFFFE
  ------------------
  |  Branch (1622:8): [True: 0, False: 2.97k]
  ------------------
 1623|  7.40k|				sc_file_clear_acl_entries(file, op);
 1624|       |
 1625|  10.3k|			sc_file_add_acl_entry(file, op, method, id);
 1626|  10.3k|		}
 1627|  12.8k|	}
 1628|  3.54k|	return 0;
 1629|       |
 1630|    111|bad:	parse_error(cur,
 1631|    111|		"Invalid ACL \"%s%s%s\"\n",
 1632|    111|		oper, what? "=" : "", what? what : "");
  ------------------
  |  Branch (1632:9): [True: 78, False: 33]
  |  Branch (1632:25): [True: 78, False: 33]
  ------------------
 1633|    111|	return 1;
 1634|  3.65k|}
fuzz_pkcs15init.c:get_authid:
 2361|  6.96k|{
 2362|  6.96k|	char	temp[16];
 2363|  6.96k|	size_t	n;
 2364|       |
 2365|  6.96k|	if (isdigit((unsigned char) *value)) {
  ------------------
  |  Branch (2365:6): [True: 2.11k, False: 4.85k]
  ------------------
 2366|  2.11k|		*num = 0;
 2367|  2.11k|		return get_uint(cur, value, type);
 2368|  2.11k|	}
 2369|       |
 2370|  4.85k|	if (strlen(value) >= sizeof(temp))
  ------------------
  |  Branch (2370:6): [True: 5, False: 4.84k]
  ------------------
 2371|      5|		return 1;
 2372|       |
 2373|  4.84k|	n = strcspn(value, "0123456789x");
 2374|  4.84k|	strlcpy(temp, value, (sizeof(temp) > n) ? n + 1 : sizeof(temp));
  ------------------
  |  |   43|  4.84k|#define strlcpy _strlcpy
  ------------------
  |  Branch (2374:23): [True: 4.84k, False: 0]
  ------------------
 2375|       |
 2376|  4.84k|	if (map_str2int(cur, temp, type, aclNames))
  ------------------
  |  Branch (2376:6): [True: 46, False: 4.80k]
  ------------------
 2377|     46|		return 1;
 2378|  4.80k|	if (value[n])
  ------------------
  |  Branch (2378:6): [True: 1.57k, False: 3.23k]
  ------------------
 2379|  1.57k|		return get_uint(cur, value + n, num);
 2380|  3.23k|	*num = 0;
 2381|  3.23k|	return 0;
 2382|  4.80k|}
fuzz_pkcs15init.c:do_profile_extension:
 1561|     26|{
 1562|     26|	if (!cur->file) {
  ------------------
  |  Branch (1562:6): [True: 2, False: 24]
  ------------------
 1563|      2|		parse_error(cur, "Invalid state\n");
 1564|      2|		return 1;
 1565|      2|	}
 1566|     24|	return setstr(&cur->file->profile_extension, argv[0]);
 1567|     26|}
fuzz_pkcs15init.c:setstr:
 2458|  2.00k|{
 2459|  2.00k|	if (*strp)
  ------------------
  |  Branch (2459:6): [True: 1.98k, False: 16]
  ------------------
 2460|  1.98k|		free(*strp);
 2461|  2.00k|	*strp = strdup(value);
 2462|  2.00k|	return 0;
 2463|  2.00k|}
fuzz_pkcs15init.c:do_exclusive_aid:
 1512|  1.30k|{
 1513|  1.30k|	struct sc_file	*file = NULL;
 1514|  1.30k|	const char	*name = argv[0];
 1515|  1.30k|	size_t len;
 1516|  1.30k|	int		res = 0;
 1517|       |
 1518|  1.30k|	if (!cur->file) {
  ------------------
  |  Branch (1518:6): [True: 1, False: 1.30k]
  ------------------
 1519|      1|		parse_error(cur, "Invalid state\n");
 1520|      1|		return 1;
 1521|      1|	}
 1522|  1.30k|	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|  1.30k|	sc_format_path(name, &file->path);
 1529|  1.30k|	if (file->path.len > SC_MAX_AID_SIZE)   {
  ------------------
  |  |   43|  1.30k|#define SC_MAX_AID_SIZE			16
  ------------------
  |  Branch (1529:6): [True: 0, False: 1.30k]
  ------------------
 1530|      0|		parse_error(cur, "Path length is too big\n");
 1531|      0|		return 1;
 1532|      0|	}
 1533|       |
 1534|  1.30k|	memcpy(file->path.aid.value, file->path.value, file->path.len);
 1535|  1.30k|	file->path.aid.len = file->path.len;
 1536|       |
 1537|  1.30k|	file->path.len = 0;
 1538|  1.30k|	file->path.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|  1.30k|#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|  1.30k|	if (*name == '=') {
  ------------------
  |  Branch (1543:6): [True: 12, False: 1.29k]
  ------------------
 1544|     12|		len = strlen(++name);
 1545|     12|		if (len > sizeof(file->name)) {
  ------------------
  |  Branch (1545:7): [True: 1, False: 11]
  ------------------
 1546|      1|			parse_error(cur, "AID \"%s\" too long\n", name);
 1547|      1|			return 1;
 1548|      1|		}
 1549|     11|		memcpy(file->name, name, len);
 1550|     11|		file->namelen = len;
 1551|     11|	}
 1552|  1.29k|	else {
 1553|  1.29k|		file->namelen = sizeof(file->name);
 1554|  1.29k|		res = sc_hex_to_bin(name, file->name, &file->namelen);
 1555|  1.29k|	}
 1556|  1.30k|	return res;
 1557|  1.30k|}
fuzz_pkcs15init.c:do_content:
 1437|    470|{
 1438|    470|	struct sc_file *file = NULL;
 1439|    470|	size_t len = (strlen(argv[0]) + 1) / 2;
 1440|    470|	int rv = 0;
 1441|       |
 1442|    470|	if (!cur->file) {
  ------------------
  |  Branch (1442:6): [True: 1, False: 469]
  ------------------
 1443|      1|		parse_error(cur, "Invalid state\n");
 1444|      1|		return 1;
 1445|      1|	}
 1446|    469|	file = cur->file->file;
 1447|       |
 1448|    469|	free(file->encoded_content);
 1449|       |
 1450|    469|	file->encoded_content = malloc(len);
 1451|    469|	if (!file->encoded_content)
  ------------------
  |  Branch (1451:6): [True: 0, False: 469]
  ------------------
 1452|      0|		return 1;
 1453|    469|	rv = sc_hex_to_bin(argv[0], file->encoded_content, &len);
 1454|    469|	file->encoded_content_len = len;
 1455|    469|	return rv;
 1456|    469|}
fuzz_pkcs15init.c:do_prop_attr:
 1460|     42|{
 1461|     42|	struct sc_file *file = NULL;
 1462|     42|	size_t len = (strlen(argv[0]) + 1) / 2;
 1463|     42|	int rv = 0;
 1464|       |
 1465|     42|	if (!cur->file) {
  ------------------
  |  Branch (1465:6): [True: 1, False: 41]
  ------------------
 1466|      1|		parse_error(cur, "Invalid state\n");
 1467|      1|		return 1;
 1468|      1|	}
 1469|     41|	file = cur->file->file;
 1470|       |
 1471|     41|	free(file->prop_attr);
 1472|     41|	file->prop_attr = malloc(len);
 1473|     41|	if (!file->prop_attr)
  ------------------
  |  Branch (1473:6): [True: 0, False: 41]
  ------------------
 1474|      0|		return 1;
 1475|     41|	rv = sc_hex_to_bin(argv[0], file->prop_attr, &len);
 1476|     41|	file->prop_attr_len = len;
 1477|     41|	return rv;
 1478|     41|}
fuzz_pkcs15init.c:process_ef:
 1038|  8.36k|{
 1039|  8.36k|	struct state	state;
 1040|       |
 1041|  8.36k|	init_state(cur, &state);
 1042|  8.36k|	if (name == NULL) {
  ------------------
  |  Branch (1042:6): [True: 0, False: 8.36k]
  ------------------
 1043|      0|		parse_error(cur, "No name given for EF object.");
 1044|      0|		return 1;
 1045|      0|	}
 1046|  8.36k|	if (!(state.file = new_file(cur, name, SC_FILE_TYPE_WORKING_EF)))
  ------------------
  |  |  216|  8.36k|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (1046:6): [True: 9, False: 8.35k]
  ------------------
 1047|      9|		return 1;
 1048|  8.35k|	return process_block(&state, info, name, blk);
 1049|  8.36k|}
fuzz_pkcs15init.c:process_bso:
 1055|  2.47k|{
 1056|  2.47k|	struct state	state;
 1057|       |
 1058|  2.47k|	init_state(cur, &state);
 1059|  2.47k|	if (name == NULL) {
  ------------------
  |  Branch (1059:6): [True: 0, False: 2.47k]
  ------------------
 1060|      0|		parse_error(cur, "No name given for BSO object.");
 1061|      0|		return 1;
 1062|      0|	}
 1063|  2.47k|	if (!(state.file = new_file(cur, name, SC_FILE_TYPE_BSO)))
  ------------------
  |  |  217|  2.47k|#define SC_FILE_TYPE_BSO		0x10
  ------------------
  |  Branch (1063:6): [True: 1, False: 2.47k]
  ------------------
 1064|      1|		return 1;
 1065|  2.47k|	return process_block(&state, info, name, blk);
 1066|  2.47k|}
fuzz_pkcs15init.c:process_tmpl:
 1125|  1.62k|{
 1126|  1.62k|	struct state	state;
 1127|  1.62k|	sc_template_t	*tinfo;
 1128|  1.62k|	sc_profile_t	*templ;
 1129|  1.62k|	int r;
 1130|       |
 1131|       |#ifdef DEBUG_PROFILE
 1132|       |	printf("Process template:%s; block:%s\n", name, info->name);
 1133|       |#endif
 1134|  1.62k|	if (name == NULL) {
  ------------------
  |  Branch (1134:6): [True: 0, False: 1.62k]
  ------------------
 1135|      0|		parse_error(cur, "No name given for template.");
 1136|      0|		return 1;
 1137|      0|	}
 1138|       |
 1139|  1.62k|	templ = calloc(1, sizeof(*templ));
 1140|  1.62k|	if (templ == NULL) {
  ------------------
  |  Branch (1140:6): [True: 0, False: 1.62k]
  ------------------
 1141|      0|		parse_error(cur, "memory allocation failed");
 1142|      0|		return 1;
 1143|      0|	}
 1144|       |
 1145|  1.62k|	tinfo = calloc(1, sizeof(*tinfo));
 1146|  1.62k|	if (tinfo == NULL) {
  ------------------
  |  Branch (1146:6): [True: 0, False: 1.62k]
  ------------------
 1147|      0|		parse_error(cur, "memory allocation failed");
 1148|      0|		free(templ);
 1149|      0|		return 1;
 1150|      0|	}
 1151|  1.62k|	tinfo->name = strdup(name);
 1152|  1.62k|	tinfo->data = templ;
 1153|       |
 1154|  1.62k|	tinfo->next = cur->profile->template_list;
 1155|  1.62k|	cur->profile->template_list = tinfo;
 1156|       |
 1157|  1.62k|	init_state(cur, &state);
 1158|  1.62k|	state.profile = tinfo->data;
 1159|  1.62k|	state.file = NULL;
 1160|       |
 1161|  1.62k|	r = process_block(&state, info, name, blk);
 1162|  1.62k|	if (!r)
  ------------------
  |  Branch (1162:6): [True: 1.51k, False: 113]
  ------------------
 1163|  1.51k|		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.62k|	return r;
 1169|  1.62k|}
fuzz_pkcs15init.c:template_sanity_check:
 1074|  1.51k|{
 1075|  1.51k|	struct file_info *fi, *ffi;
 1076|       |
 1077|  6.17k|	for (fi = templ->ef_list; fi; fi = fi->next) {
  ------------------
  |  Branch (1077:28): [True: 4.70k, False: 1.46k]
  ------------------
 1078|  4.70k|		struct sc_path fi_path =  fi->file->path;
 1079|  4.70k|		int fi_id;
 1080|       |
 1081|  4.70k|		if (fi->file->type == SC_FILE_TYPE_BSO)
  ------------------
  |  |  217|  4.70k|#define SC_FILE_TYPE_BSO		0x10
  ------------------
  |  Branch (1081:7): [True: 1.59k, False: 3.11k]
  ------------------
 1082|  1.59k|			continue;
 1083|       |
 1084|  3.11k|		if (fi_path.len < 2) {
  ------------------
  |  Branch (1084:7): [True: 24, False: 3.09k]
  ------------------
 1085|     24|			parse_error(cur, "Template insane: file-path length should not be less than 2 bytes");
 1086|     24|			return 1;
 1087|     24|		}
 1088|       |
 1089|  3.09k|		fi_id = fi_path.value[fi_path.len - 2] * 0x100
 1090|  3.09k|				+ fi_path.value[fi_path.len - 1];
 1091|       |
 1092|  15.4k|		for (ffi = templ->ef_list; ffi; ffi = ffi->next) {
  ------------------
  |  Branch (1092:30): [True: 12.3k, False: 3.06k]
  ------------------
 1093|  12.3k|			struct sc_path ffi_path =  ffi->file->path;
 1094|  12.3k|			int dlt, ffi_id;
 1095|       |
 1096|  12.3k|			if (ffi->file->type == SC_FILE_TYPE_BSO)
  ------------------
  |  |  217|  12.3k|#define SC_FILE_TYPE_BSO		0x10
  ------------------
  |  Branch (1096:8): [True: 66, False: 12.2k]
  ------------------
 1097|     66|				continue;
 1098|       |
 1099|  12.2k|			if (ffi_path.len < 2) {
  ------------------
  |  Branch (1099:8): [True: 11, False: 12.2k]
  ------------------
 1100|     11|				parse_error(cur, "Template insane: file-path length should not be less than 2 bytes");
 1101|     11|				return 1;
 1102|     11|			}
 1103|       |
 1104|  12.2k|			ffi_id = ffi_path.value[ffi_path.len - 2] * 0x100
 1105|  12.2k|					+ ffi_path.value[ffi_path.len - 1];
 1106|       |
 1107|  12.2k|			dlt = fi_id > ffi_id ? fi_id - ffi_id : ffi_id - fi_id;
  ------------------
  |  Branch (1107:10): [True: 4.58k, False: 7.68k]
  ------------------
 1108|  12.2k|			if (strcmp(ffi->ident, fi->ident))   {
  ------------------
  |  Branch (1108:8): [True: 9.17k, False: 3.09k]
  ------------------
 1109|  9.17k|				if (dlt >= TEMPLATE_FILEID_MIN_DIFF)
  ------------------
  |  |   56|  9.17k|#define TEMPLATE_FILEID_MIN_DIFF	0x20
  ------------------
  |  Branch (1109:9): [True: 9.16k, False: 16]
  ------------------
 1110|  9.16k|					continue;
 1111|       |
 1112|     16|				parse_error(cur, "Template insane: file-ids should be substantially different");
 1113|     16|				return 1;
 1114|  9.17k|			}
 1115|  12.2k|		}
 1116|  3.09k|	}
 1117|       |
 1118|  1.46k|	return SC_SUCCESS;
  ------------------
  |  |   28|  1.46k|#define SC_SUCCESS				0
  ------------------
 1119|  1.51k|}
fuzz_pkcs15init.c:do_card_driver:
  845|     38|{
  846|     38|	free(cur->profile->driver);
  847|     38|	cur->profile->driver = strdup(argv[0]);
  848|     38|	return 0;
  849|     38|}
fuzz_pkcs15init.c:do_maxpinlength:
  853|    179|{
  854|    179|	return get_uint(cur, argv[0], &cur->profile->pin_maxlen);
  855|    179|}
fuzz_pkcs15init.c:do_minpinlength:
  859|    535|{
  860|    535|	return get_uint(cur, argv[0], &cur->profile->pin_minlen);
  861|    535|}
fuzz_pkcs15init.c:do_default_pin_type:
  865|  1.06k|{
  866|  1.06k|	return map_str2int(cur, argv[0],
  867|  1.06k|		       	&cur->profile->pin_encoding, pinTypeNames);
  868|  1.06k|}
fuzz_pkcs15init.c:do_pin_pad_char:
  872|  1.09k|{
  873|  1.09k|	return get_uint(cur, argv[0], &cur->profile->pin_pad_char);
  874|  1.09k|}
fuzz_pkcs15init.c:do_pin_domains:
  878|    266|{
  879|    266|	return get_bool(cur, argv[0], &cur->profile->pin_domains);
  880|    266|}
fuzz_pkcs15init.c:get_bool:
 2410|  2.87k|{
 2411|  2.87k|	if (!strcasecmp(value, "on")
  ------------------
  |  Branch (2411:6): [True: 546, False: 2.33k]
  ------------------
 2412|  2.33k|	 || !strcasecmp(value, "yes")
  ------------------
  |  Branch (2412:6): [True: 203, False: 2.12k]
  ------------------
 2413|  2.12k|	 || !strcasecmp(value, "true")) {
  ------------------
  |  Branch (2413:6): [True: 457, False: 1.67k]
  ------------------
 2414|  1.20k|		*vp = 1;
 2415|  1.20k|	} else
 2416|  1.67k|	if (!strcasecmp(value, "off")
  ------------------
  |  Branch (2416:6): [True: 16, False: 1.65k]
  ------------------
 2417|  1.65k|	 || !strcasecmp(value, "no")
  ------------------
  |  Branch (2417:6): [True: 1.45k, False: 202]
  ------------------
 2418|  1.54k|	 || !strcasecmp(value, "false")) {
  ------------------
  |  Branch (2418:6): [True: 75, False: 127]
  ------------------
 2419|  1.54k|		*vp = 0;
 2420|  1.54k|	} else {
 2421|    127|		parse_error(cur, "invalid boolean argument \"%s\"\n", value);
 2422|    127|		return 1;
 2423|    127|	}
 2424|  2.74k|	return 0;
 2425|  2.87k|}
fuzz_pkcs15init.c:do_card_label:
  884|  1.41k|{
  885|  1.41k|	struct sc_pkcs15_card	*p15card = cur->profile->p15_spec;
  886|       |
  887|  1.41k|	return setstr(&p15card->tokeninfo->label, argv[0]);
  888|  1.41k|}
fuzz_pkcs15init.c:do_card_manufacturer:
  892|    568|{
  893|    568|	struct sc_pkcs15_card	*p15card = cur->profile->p15_spec;
  894|       |
  895|    568|	return setstr(&p15card->tokeninfo->manufacturer_id, argv[0]);
  896|    568|}
fuzz_pkcs15init.c:process_key:
  954|     12|{
  955|     12|	unsigned int	type, id;
  956|     12|	struct state	state;
  957|       |
  958|     12|	if (get_authid(cur, name, &type, &id))
  ------------------
  |  Branch (958:6): [True: 10, False: 2]
  ------------------
  959|     10|		return 1;
  960|       |
  961|      2|	init_state(cur, &state);
  962|      2|	state.key = new_key(cur->profile, type, id);
  963|      2|	return process_block(&state, info, name, blk);
  964|     12|}
fuzz_pkcs15init.c:new_key:
  968|      2|{
  969|      2|	struct auth_info *ai, **aip;
  970|       |
  971|      2|	for (aip = &profile->auth_list; (ai = *aip); aip = &ai->next) {
  ------------------
  |  Branch (971:34): [True: 0, False: 2]
  ------------------
  972|      0|		if (ai->type == type && ai->ref == ref)
  ------------------
  |  Branch (972:7): [True: 0, False: 0]
  |  Branch (972:27): [True: 0, False: 0]
  ------------------
  973|      0|			return ai;
  974|      0|	}
  975|       |
  976|      2|	ai = calloc(1, sizeof(*ai));
  977|      2|	if (ai == NULL)
  ------------------
  |  Branch (977:6): [True: 0, False: 2]
  ------------------
  978|      0|		return NULL;
  979|      2|	ai->type = type;
  980|      2|	ai->ref = ref;
  981|      2|	*aip = ai;
  982|      2|	return ai;
  983|      2|}
fuzz_pkcs15init.c:process_pin:
 1639|  7.74k|{
 1640|  7.74k|	struct state	state;
 1641|  7.74k|	unsigned int	id;
 1642|       |
 1643|  7.74k|	if (map_str2int(cur, name, &id, pinIdNames))
  ------------------
  |  Branch (1643:6): [True: 95, False: 7.65k]
  ------------------
 1644|     95|		return 1;
 1645|       |
 1646|  7.65k|	init_state(cur, &state);
 1647|  7.65k|	state.pin = new_pin(cur->profile, (int)id);
 1648|       |
 1649|  7.65k|	return process_block(&state, info, name, blk);
 1650|  7.74k|}
fuzz_pkcs15init.c:do_pin_file:
 1712|    334|{
 1713|    334|	free(cur->pin->file_name);
 1714|    334|	cur->pin->file_name = strdup(argv[0]);
 1715|    334|	return 0;
 1716|    334|}
fuzz_pkcs15init.c:do_pin_offset:
 1720|     82|{
 1721|     82|	return get_uint(cur, argv[0], &cur->pin->file_offset);
 1722|     82|}
fuzz_pkcs15init.c:do_pin_attempts:
 1726|  1.43k|{
 1727|  1.43k|	struct pin_info	*pi = cur->pin;
 1728|  1.43k|	unsigned int	count;
 1729|       |
 1730|  1.43k|	if (get_uint(cur, argv[0], &count))
  ------------------
  |  Branch (1730:6): [True: 2, False: 1.42k]
  ------------------
 1731|      2|		return 1;
 1732|  1.42k|	pi->pin.tries_left = count;
 1733|  1.42k|	return 0;
 1734|  1.43k|}
fuzz_pkcs15init.c:do_pin_type:
 1750|    213|{
 1751|    213|	unsigned int	type;
 1752|       |
 1753|    213|	if (map_str2int(cur, argv[0], &type, pinTypeNames))
  ------------------
  |  Branch (1753:6): [True: 1, False: 212]
  ------------------
 1754|      1|		return 1;
 1755|    212|	if (cur->pin->pin.auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|    212|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (1755:6): [True: 0, False: 212]
  ------------------
 1756|      0|		return 1;
 1757|    212|	cur->pin->pin.attrs.pin.type = type;
 1758|    212|	return 0;
 1759|    212|}
fuzz_pkcs15init.c:do_pin_reference:
 1763|  1.88k|{
 1764|  1.88k|	unsigned int	reference;
 1765|       |
 1766|  1.88k|	if (get_uint(cur, argv[0], &reference))
  ------------------
  |  Branch (1766:6): [True: 8, False: 1.87k]
  ------------------
 1767|      8|		return 1;
 1768|  1.87k|	if (cur->pin->pin.auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|  1.87k|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (1768:6): [True: 0, False: 1.87k]
  ------------------
 1769|      0|		return 1;
 1770|  1.87k|	cur->pin->pin.attrs.pin.reference = reference;
 1771|  1.87k|	return 0;
 1772|  1.87k|}
fuzz_pkcs15init.c:do_pin_authid:
 1776|  1.30k|{
 1777|  1.30k|	sc_pkcs15_format_id(argv[0], &cur->pin->pin.auth_id);
 1778|  1.30k|	return 0;
 1779|  1.30k|}
fuzz_pkcs15init.c:do_pin_maxlength:
 1796|  1.36k|{
 1797|  1.36k|	unsigned int	len;
 1798|       |
 1799|  1.36k|	if (get_uint(cur, argv[0], &len))
  ------------------
  |  Branch (1799:6): [True: 1, False: 1.36k]
  ------------------
 1800|      1|		return 1;
 1801|  1.36k|	if (cur->pin->pin.auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|  1.36k|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (1801:6): [True: 0, False: 1.36k]
  ------------------
 1802|      0|		return 1;
 1803|  1.36k|	cur->pin->pin.attrs.pin.max_length = len;
 1804|  1.36k|	return 0;
 1805|  1.36k|}
fuzz_pkcs15init.c:do_pin_minlength:
 1783|  1.39k|{
 1784|  1.39k|	unsigned int	len;
 1785|       |
 1786|  1.39k|	if (get_uint(cur, argv[0], &len))
  ------------------
  |  Branch (1786:6): [True: 3, False: 1.38k]
  ------------------
 1787|      3|		return 1;
 1788|  1.38k|	if (cur->pin->pin.auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|  1.38k|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (1788:6): [True: 0, False: 1.38k]
  ------------------
 1789|      0|		return 1;
 1790|  1.38k|	cur->pin->pin.attrs.pin.min_length = len;
 1791|  1.38k|	return 0;
 1792|  1.38k|}
fuzz_pkcs15init.c:do_pin_storedlength:
 1809|    210|{
 1810|    210|	unsigned int	len;
 1811|       |
 1812|    210|	if (get_uint(cur, argv[0], &len))
  ------------------
  |  Branch (1812:6): [True: 1, False: 209]
  ------------------
 1813|      1|		return 1;
 1814|    209|	if (cur->pin->pin.auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|    209|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (1814:6): [True: 0, False: 209]
  ------------------
 1815|      0|		return 1;
 1816|    209|	cur->pin->pin.attrs.pin.stored_length = len;
 1817|    209|	return 0;
 1818|    209|}
fuzz_pkcs15init.c:do_pin_maxunlocks:
 1738|     68|{
 1739|     68|	struct pin_info	*pi = cur->pin;
 1740|     68|	unsigned int	count;
 1741|       |
 1742|     68|	if (get_uint(cur, argv[0], &count))
  ------------------
  |  Branch (1742:6): [True: 1, False: 67]
  ------------------
 1743|      1|		return 1;
 1744|     67|	pi->pin.max_unlocks = count;
 1745|     67|	return 0;
 1746|     68|}
fuzz_pkcs15init.c:do_pin_flags:
 1822|  1.16k|{
 1823|  1.16k|	unsigned int flags = 0;
 1824|  1.16k|	int		i, r;
 1825|       |
 1826|  1.16k|	if (cur->pin->pin.auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|  1.16k|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (1826:6): [True: 0, False: 1.16k]
  ------------------
 1827|      0|		return -1;
 1828|       |
 1829|  1.16k|	cur->pin->pin.attrs.pin.flags = 0;
 1830|  3.21k|	for (i = 0; i < argc; i++) {
  ------------------
  |  Branch (1830:14): [True: 2.11k, False: 1.09k]
  ------------------
 1831|  2.11k|		if ((r = map_str2int(cur, argv[i], &flags, pinFlagNames)) < 0)
  ------------------
  |  Branch (1831:7): [True: 68, False: 2.04k]
  ------------------
 1832|     68|			return r;
 1833|  2.04k|		cur->pin->pin.attrs.pin.flags |= flags;
 1834|  2.04k|	}
 1835|       |
 1836|  1.09k|	return 0;
 1837|  1.16k|}
fuzz_pkcs15init.c:process_option:
  937|  1.45k|{
  938|  1.45k|	sc_profile_t	*profile = cur->profile;
  939|  1.45k|	int		match = 0, i;
  940|       |
  941|  1.76k|	for (i = 0; profile->options[i]; i++)
  ------------------
  |  Branch (941:14): [True: 309, False: 1.45k]
  ------------------
  942|    309|		match |= !strcmp(profile->options[i], name);
  943|  1.45k|	if (!match && strcmp("default", name))
  ------------------
  |  Branch (943:6): [True: 1.37k, False: 84]
  |  Branch (943:16): [True: 722, False: 650]
  ------------------
  944|    722|		return 0;
  945|    734|	return process_block(cur, info, name, blk);
  946|  1.45k|}
fuzz_pkcs15init.c:process_macros:
 1842|  1.72k|{
 1843|  1.72k|	scconf_item	*item;
 1844|  1.72k|	const char	*name;
 1845|  1.72k|	int		 r;
 1846|       |
 1847|  11.7k|	for (item = blk->items; item; item = item->next) {
  ------------------
  |  Branch (1847:26): [True: 10.0k, False: 1.68k]
  ------------------
 1848|  10.0k|		char *s = item->key;
 1849|  10.0k|		name = item->key;
 1850|  10.0k|		if (item->type != SCCONF_ITEM_TYPE_VALUE || !name)
  ------------------
  |  |   44|  20.1k|#define SCCONF_ITEM_TYPE_VALUE		2	/* key = key, list */
  ------------------
  |  Branch (1850:7): [True: 592, False: 9.49k]
  |  Branch (1850:47): [True: 197, False: 9.29k]
  ------------------
 1851|    789|			continue;
 1852|       |
 1853|       |		/* make sure the macro name consist only of allowed characters.
 1854|       |		 * This is not guaranteed by the tokenizer */
 1855|   101k|		while (is_macro_character(*s)) {
  ------------------
  |  Branch (1855:10): [True: 92.6k, False: 9.29k]
  ------------------
 1856|  92.6k|			s++;
 1857|  92.6k|		}
 1858|  9.29k|		if (*s != '\0') {
  ------------------
  |  Branch (1858:7): [True: 35, False: 9.26k]
  ------------------
 1859|       |#ifdef DEBUG_PROFILE
 1860|       |			printf("Invalid macro name %s\n", name);
 1861|       |#endif
 1862|     35|			return SC_ERROR_SYNTAX_ERROR;
  ------------------
  |  |  103|     35|#define SC_ERROR_SYNTAX_ERROR			-1501
  ------------------
 1863|     35|		}
 1864|       |#ifdef DEBUG_PROFILE
 1865|       |		printf("Defining %s\n", name);
 1866|       |#endif
 1867|  9.26k|		r = new_macro(cur->profile, name, item->value.list);
 1868|  9.26k|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|  9.26k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1868:7): [True: 14, False: 9.25k]
  ------------------
 1869|     14|			return r;
 1870|  9.26k|	}
 1871|       |
 1872|  1.68k|	return SC_SUCCESS;
  ------------------
  |  |   28|  1.68k|#define SC_SUCCESS				0
  ------------------
 1873|  1.72k|}
fuzz_pkcs15init.c:new_macro:
 1877|  9.26k|{
 1878|  9.26k|	sc_macro_t	*mac;
 1879|       |
 1880|  9.26k|	if (!profile || !name || !value)
  ------------------
  |  Branch (1880:6): [True: 0, False: 9.26k]
  |  Branch (1880:18): [True: 0, False: 9.26k]
  |  Branch (1880:27): [True: 14, False: 9.25k]
  ------------------
 1881|     14|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|     14|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1882|       |
 1883|  9.25k|	if ((mac = find_macro(profile, name)) == NULL) {
  ------------------
  |  Branch (1883:6): [True: 2.76k, False: 6.48k]
  ------------------
 1884|  2.76k|		mac = calloc(1, sizeof(*mac));
 1885|  2.76k|		if (mac == NULL)
  ------------------
  |  Branch (1885:7): [True: 0, False: 2.76k]
  ------------------
 1886|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1887|  2.76k|		mac->name = strdup(name);
 1888|  2.76k|		mac->next = profile->macro_list;
 1889|  2.76k|		profile->macro_list = mac;
 1890|  2.76k|	}
 1891|       |
 1892|  9.25k|	mac->value = value;
 1893|  9.25k|	return SC_SUCCESS;
  ------------------
  |  |   28|  9.25k|#define SC_SUCCESS				0
  ------------------
 1894|  9.25k|}
fuzz_pkcs15init.c:do_direct_certificates:
  903|  1.04k|{
  904|  1.04k|	return get_bool(cur, argv[0], &cur->profile->pkcs15.direct_certificates);
  905|  1.04k|}
fuzz_pkcs15init.c:do_encode_df_length:
  909|    958|{
  910|    958|	return get_bool(cur, argv[0], &cur->profile->pkcs15.encode_df_length);
  911|    958|}
fuzz_pkcs15init.c:do_encode_update_field:
  915|    608|{
  916|    608|	return get_bool(cur, argv[0], &cur->profile->pkcs15.do_last_update);
  917|    608|}
fuzz_pkcs15init.c:do_pkcs15_id_style:
  921|    376|{
  922|    376|	return map_str2int(cur, argv[0], &cur->profile->id_style, idStyleNames);
  923|    376|}
fuzz_pkcs15init.c:do_minidriver_support_style:
  927|      1|{
  928|      1|	return map_str2int(cur, argv[0], &cur->profile->md_style, mdStyleNames);
  929|      1|}
fuzz_pkcs15init.c:sc_profile_find_file:
 2261|  77.1k|{
 2262|  77.1k|	struct file_info	*fi;
 2263|  77.1k|	size_t				len;
 2264|  77.1k|	const u8			*value;
 2265|       |
 2266|  77.1k|	value = path ? path->value : (const u8*) "";
  ------------------
  |  Branch (2266:10): [True: 19, False: 77.1k]
  ------------------
 2267|  77.1k|	len = path ? path->len : 0;
  ------------------
  |  Branch (2267:8): [True: 19, False: 77.1k]
  ------------------
 2268|   248k|	for (fi = pro->ef_list; fi; fi = fi->next) {
  ------------------
  |  Branch (2268:26): [True: 198k, False: 49.8k]
  ------------------
 2269|   198k|		sc_path_t *fpath = &fi->file->path;
 2270|       |
 2271|   198k|		if (!strcasecmp(fi->ident, name) && fpath->len >= len && !memcmp(fpath->value, value, len))
  ------------------
  |  Branch (2271:7): [True: 27.3k, False: 171k]
  |  Branch (2271:39): [True: 27.3k, False: 1]
  |  Branch (2271:60): [True: 27.3k, False: 0]
  ------------------
 2272|  27.3k|			return fi;
 2273|   198k|	}
 2274|  49.8k|	return NULL;
 2275|  77.1k|}
fuzz_pkcs15init.c:sc_profile_find_file_by_path:
 2280|  6.97k|{
 2281|  6.97k|	struct file_info *fi, *out = NULL;
 2282|  6.97k|	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|  6.97k|	if (!path || (!path->len && !path->aid.len))
  ------------------
  |  Branch (2297:6): [True: 0, False: 6.97k]
  |  Branch (2297:16): [True: 2.97k, False: 3.99k]
  |  Branch (2297:30): [True: 2.00k, False: 971]
  ------------------
 2298|  2.00k|		return NULL;
 2299|       |
 2300|   103k|	for (fi = pro->ef_list; fi; fi = fi->next) {
  ------------------
  |  Branch (2300:26): [True: 98.4k, False: 4.97k]
  ------------------
 2301|  98.4k|		fp_path = &fi->file->path;
 2302|  98.4k|		fpp_path = fi->parent ? &fi->parent->file->path : NULL;
  ------------------
  |  Branch (2302:14): [True: 92.8k, False: 5.55k]
  ------------------
 2303|       |
 2304|  98.4k|		if (fp_path->len != path->len)
  ------------------
  |  Branch (2304:7): [True: 14.9k, False: 83.4k]
  ------------------
 2305|  14.9k|			continue;
 2306|  83.4k|		if (fp_path->len && memcmp(fp_path->value, path->value, path->len))
  ------------------
  |  Branch (2306:7): [True: 13.6k, False: 69.8k]
  |  Branch (2306:23): [True: 8.36k, False: 5.27k]
  ------------------
 2307|  8.36k|			continue;
 2308|       |
 2309|  75.1k|		if (path->aid.len && fp_path->aid.len)   {
  ------------------
  |  Branch (2309:7): [True: 69.8k, False: 5.23k]
  |  Branch (2309:24): [True: 34.4k, False: 35.3k]
  ------------------
 2310|  34.4k|			if (memcmp(fp_path->aid.value, path->aid.value, path->aid.len))
  ------------------
  |  Branch (2310:8): [True: 120, False: 34.3k]
  ------------------
 2311|    120|				continue;
 2312|  34.4k|		}
 2313|  40.6k|		else if (path->aid.len && !fp_path->aid.len && fpp_path)   {
  ------------------
  |  Branch (2313:12): [True: 35.3k, False: 5.23k]
  |  Branch (2313:29): [True: 35.3k, False: 0]
  |  Branch (2313:50): [True: 34.4k, False: 883]
  ------------------
 2314|  34.4k|			if (fpp_path->type == SC_PATH_TYPE_DF_NAME && fpp_path->len)   {
  ------------------
  |  |  118|  68.9k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (2314:8): [True: 694, False: 33.7k]
  |  Branch (2314:50): [True: 48, False: 646]
  ------------------
 2315|     48|				if (fpp_path->len != path->aid.len)
  ------------------
  |  Branch (2315:9): [True: 20, False: 28]
  ------------------
 2316|     20|					continue;
 2317|     28|				if (memcmp(fpp_path->value, path->aid.value, path->aid.len))
  ------------------
  |  Branch (2317:9): [True: 17, False: 11]
  ------------------
 2318|     17|					continue;
 2319|     28|			}
 2320|  34.4k|			else if (fpp_path->aid.len)   {
  ------------------
  |  Branch (2320:13): [True: 646, False: 33.7k]
  ------------------
 2321|    646|				if (fpp_path->aid.len != path->aid.len)
  ------------------
  |  Branch (2321:9): [True: 117, False: 529]
  ------------------
 2322|    117|					continue;
 2323|    529|				if (memcmp(fpp_path->aid.value, path->aid.value, path->aid.len))
  ------------------
  |  Branch (2323:9): [True: 112, False: 417]
  ------------------
 2324|    112|					continue;
 2325|    529|			}
 2326|  34.4k|		}
 2327|       |
 2328|  74.7k|		out = fi;
 2329|  74.7k|	}
 2330|       |
 2331|       |#ifdef DEBUG_PROFILE
 2332|       |	sc_log(ctx, "returns (%s)", out ? out->ident: "<null>");
 2333|       |#endif
 2334|  4.97k|	return out;
 2335|  6.97k|}

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

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

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

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

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

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

