From 00a150f74ccdac71b48a8e8531c5ecd1fdd9053d Mon Sep 17 00:00:00 2001 From: Frank Morgner Date: Thu, 22 Nov 2018 23:10:49 +0100 Subject: [PATCH] replaced SC_FUNC_RETURN with LOG_FUNC_RETURN --- src/libopensc/card-akis.c | 6 +- src/libopensc/card-asepcos.c | 2 +- src/libopensc/card-atrust-acos.c | 6 +- src/libopensc/card-cac.c | 36 ++++----- src/libopensc/card-cac1.c | 12 +-- src/libopensc/card-cardos.c | 12 +-- src/libopensc/card-coolkey.c | 22 +++--- src/libopensc/card-entersafe.c | 14 ++-- src/libopensc/card-flex.c | 6 +- src/libopensc/card-gids.c | 108 +++++++++++++-------------- src/libopensc/card-gpk.c | 2 +- src/libopensc/card-incrypto34.c | 14 ++-- src/libopensc/card-itacns.c | 2 +- src/libopensc/card-jcop.c | 2 +- src/libopensc/card-masktech.c | 6 +- src/libopensc/card-mcrd.c | 12 +-- src/libopensc/card-miocos.c | 8 +- src/libopensc/card-muscle.c | 16 ++-- src/libopensc/card-npa.c | 2 +- src/libopensc/card-oberthur.c | 2 +- src/libopensc/card-rtecp.c | 26 +++---- src/libopensc/card-rutoken.c | 68 ++++++++--------- src/libopensc/card-setcos.c | 8 +- src/libopensc/card-starcos.c | 6 +- src/libopensc/card-tcos.c | 6 +- src/libopensc/card.c | 4 +- src/libopensc/iso7816.c | 4 +- src/libopensc/muscle.c | 80 ++++++++++---------- src/libopensc/p15card-helper.c | 10 +-- src/libopensc/pkcs15-cac.c | 12 +-- src/libopensc/pkcs15-coolkey.c | 4 +- src/libopensc/pkcs15-data.c | 2 +- src/libopensc/pkcs15-oberthur.c | 8 +- src/libopensc/pkcs15-pin.c | 2 +- src/libopensc/pkcs15-piv.c | 12 +-- src/libopensc/reader-ctapi.c | 2 +- src/pkcs15init/pkcs15-gpk.c | 10 +-- src/pkcs15init/pkcs15-miocos.c | 6 +- src/pkcs15init/pkcs15-oberthur-awp.c | 82 ++++++++++---------- src/pkcs15init/pkcs15-oberthur.c | 34 ++++----- src/pkcs15init/pkcs15-rtecp.c | 20 ++--- src/pkcs15init/pkcs15-setcos.c | 10 +-- src/sm/sm-eac.c | 18 ++--- 43 files changed, 362 insertions(+), 362 deletions(-) diff --git a/src/libopensc/card-akis.c b/src/libopensc/card-akis.c index 5cd2b1e9..5b88a0e2 100644 --- a/src/libopensc/card-akis.c +++ b/src/libopensc/card-akis.c @@ -102,7 +102,7 @@ select_file(sc_card_t *card, sc_apdu_t *apdu, const sc_path_t *path, file = sc_file_new(); if (file == NULL) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); r = card->ops->process_fci(card, file, apdu->resp + 2, apdu->resp[1]); if (r) { @@ -185,7 +185,7 @@ akis_list_files(sc_card_t *card, u8 *buf, size_t buflen) } r = fids; - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } static int @@ -320,7 +320,7 @@ akis_delete_file(sc_card_t *card, const sc_path_t *path) break; default: sc_log(card->ctx, "File type has to be FID or PATH"); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); } sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x16, type, 0x00); apdu.cla = 0x80; diff --git a/src/libopensc/card-asepcos.c b/src/libopensc/card-asepcos.c index fb5eb957..fdad6618 100644 --- a/src/libopensc/card-asepcos.c +++ b/src/libopensc/card-asepcos.c @@ -313,7 +313,7 @@ static int asepcos_select_file(sc_card_t *card, const sc_path_t *in_path, if (r != SC_SUCCESS) sc_log(card->ctx, "error parsing security attributes"); } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } static int asepcos_set_security_env(sc_card_t *card, diff --git a/src/libopensc/card-atrust-acos.c b/src/libopensc/card-atrust-acos.c index 86102b44..64e14f5e 100644 --- a/src/libopensc/card-atrust-acos.c +++ b/src/libopensc/card-atrust-acos.c @@ -263,7 +263,7 @@ static int atrust_acos_select_aid(struct sc_card *card, if (file_out) { sc_file_t *file = sc_file_new(); if (!file) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); file->type = SC_FILE_TYPE_DF; file->ef_structure = SC_FILE_EF_UNKNOWN; file->path.len = 0; @@ -348,7 +348,7 @@ static int atrust_acos_select_fid(struct sc_card *card, if (file_out) { sc_file_t *file = sc_file_new(); if (!file) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); file->id = (id_hi << 8) + id_lo; file->path = card->cache.current_path; @@ -494,7 +494,7 @@ static int atrust_acos_select_file(struct sc_card *card, if (file_out) { sc_file_t *file = sc_file_new(); if (!file) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); file->id = (path[pathlen-2] << 8) + path[pathlen-1]; file->path = card->cache.current_path; diff --git a/src/libopensc/card-cac.c b/src/libopensc/card-cac.c index b2c0c3ce..4ffe7497 100644 --- a/src/libopensc/card-cac.c +++ b/src/libopensc/card-cac.c @@ -336,7 +336,7 @@ static int cac_apdu_io(sc_card_t *card, int ins, int p1, int p2, } err: - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } /* @@ -469,11 +469,11 @@ static int cac_read_binary(sc_card_t *card, unsigned int idx, "returning cached value idx=%d count=%"SC_FORMAT_LEN_SIZE_T"u", idx, count); if (idx > priv->cache_buf_len) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_FILE_END_REACHED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_FILE_END_REACHED); } len = MIN(count, priv->cache_buf_len-idx); memcpy(buf, &priv->cache_buf[idx], len); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, len); + LOG_FUNC_RETURN(card->ctx, len); } sc_log(card->ctx, @@ -487,7 +487,7 @@ static int cac_read_binary(sc_card_t *card, unsigned int idx, if (priv->object_type <= 0) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL); r = cac_read_file(card, CAC_FILE_TAG, &tl, &tl_len); if (r < 0) { @@ -617,7 +617,7 @@ done: free(tl); if (val) free(val); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } /* CAC driver is read only */ @@ -626,7 +626,7 @@ static int cac_write_binary(sc_card_t *card, unsigned int idx, { SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED); } /* initialize getting a list and return the number of elements in the list */ @@ -670,14 +670,14 @@ static int cac_get_serial_nr_from_CUID(sc_card_t* card, sc_serial_number_t* seri LOG_FUNC_CALLED(card->ctx); if (card->serialnr.len) { *serial = card->serialnr; - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(card->ctx, SC_SUCCESS); } if (priv->cac_id_len) { serial->len = MIN(priv->cac_id_len, SC_MAX_SERIALNR); memcpy(serial->value, priv->cac_id, serial->len); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(card->ctx, SC_SUCCESS); } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_FILE_NOT_FOUND); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_FILE_NOT_FOUND); } static int cac_get_ACA_path(sc_card_t *card, sc_path_t *path) @@ -688,7 +688,7 @@ static int cac_get_ACA_path(sc_card_t *card, sc_path_t *path) if (priv->aca_path) { *path = *priv->aca_path; } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(card->ctx, SC_SUCCESS); } static int cac_card_ctl(sc_card_t *card, unsigned long cmd, void *ptr) @@ -741,7 +741,7 @@ static int cac_get_challenge(sc_card_t *card, u8 *rnd, size_t len) } memcpy(rnd, rbuf, out_len); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, (int) out_len); + LOG_FUNC_RETURN(card->ctx, (int) out_len); } static int cac_set_security_env(sc_card_t *card, const sc_security_env_t *env, int se_num) @@ -769,7 +769,7 @@ static int cac_restore_security_env(sc_card_t *card, int se_num) { SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(card->ctx, SC_SUCCESS); } @@ -795,7 +795,7 @@ static int cac_rsa_op(sc_card_t *card, * different sets of APDU's that need to be called), so this call is really a little bit of paranoia */ r = sc_lock(card); if (r != SC_SUCCESS) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); rbuf = NULL; @@ -844,7 +844,7 @@ err: free(rbuf); } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } static int cac_compute_signature(sc_card_t *card, @@ -1225,7 +1225,7 @@ static int cac_select_file_by_type(sc_card_t *card, const sc_path_t *in_path, sc file->size = CAC_MAX_SIZE; /* we don't know how big, just give a large size until we can read the file */ *file_out = file; - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(ctx, SC_SUCCESS); } @@ -1742,7 +1742,7 @@ static int cac_process_ACA(sc_card_t *card, cac_private_data_t *priv) done: if (val) free(val); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } /* @@ -1847,7 +1847,7 @@ static int cac_init(sc_card_t *card) r = cac_find_and_initialize(card, 1); if (r < 0) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_CARD); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_CARD); } flags = SC_ALGORITHM_RSA_RAW; @@ -1857,7 +1857,7 @@ static int cac_init(sc_card_t *card) card->caps |= SC_CARD_CAP_RNG | SC_CARD_CAP_ISO7816_PIN_INFO; - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(card->ctx, SC_SUCCESS); } static int cac_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *data, int *tries_left) diff --git a/src/libopensc/card-cac1.c b/src/libopensc/card-cac1.c index abfc408c..86c4fcc7 100644 --- a/src/libopensc/card-cac1.c +++ b/src/libopensc/card-cac1.c @@ -140,11 +140,11 @@ static int cac_read_binary(sc_card_t *card, unsigned int idx, "returning cached value idx=%d count=%"SC_FORMAT_LEN_SIZE_T"u", idx, count); if (idx > priv->cache_buf_len) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_FILE_END_REACHED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_FILE_END_REACHED); } len = MIN(count, priv->cache_buf_len-idx); memcpy(buf, &priv->cache_buf[idx], len); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, len); + LOG_FUNC_RETURN(card->ctx, len); } sc_log(card->ctx, @@ -196,7 +196,7 @@ static int cac_read_binary(sc_card_t *card, unsigned int idx, done: if (val) free(val); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } /* @@ -337,7 +337,7 @@ static int cac_select_file_by_type(sc_card_t *card, const sc_path_t *in_path, sc file->size = CAC_MAX_SIZE; /* we don't know how big, just give a large size until we can read the file */ *file_out = file; - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(ctx, SC_SUCCESS); } @@ -515,7 +515,7 @@ static int cac_init(sc_card_t *card) r = cac_find_and_initialize(card, 1); if (r < 0) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_CARD); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_CARD); } flags = SC_ALGORITHM_RSA_RAW; @@ -525,7 +525,7 @@ static int cac_init(sc_card_t *card) card->caps |= SC_CARD_CAP_RNG | SC_CARD_CAP_ISO7816_PIN_INFO; - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(card->ctx, SC_SUCCESS); } static struct sc_card_operations cac_ops; diff --git a/src/libopensc/card-cardos.c b/src/libopensc/card-cardos.c index c1ca1201..c74e3f49 100644 --- a/src/libopensc/card-cardos.c +++ b/src/libopensc/card-cardos.c @@ -392,7 +392,7 @@ get_next_part: r = fids; - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } static void add_acl_entry(sc_file_t *file, int op, u8 byte) @@ -491,7 +491,7 @@ static int cardos_select_file(sc_card_t *card, r = iso_ops->select_file(card, in_path, file); if (r >= 0 && file) parse_sec_attr((*file), (*file)->sec_attr, (*file)->sec_attr_len); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } static int cardos_acl_to_bytes(sc_card_t *card, const sc_file_t *file, @@ -757,7 +757,7 @@ cardos_restore_security_env(sc_card_t *card, int se_num) r = sc_check_sw(card, apdu.sw1, apdu.sw2); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "Card returned error"); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } /* @@ -1049,7 +1049,7 @@ cardos_lifecycle_get(sc_card_t *card, int *mode) r = SC_ERROR_INTERNAL; } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } static int @@ -1085,7 +1085,7 @@ cardos_lifecycle_set(sc_card_t *card, int *mode) r = sc_check_sw(card, apdu.sw1, apdu.sw2); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "Card returned error"); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } static int @@ -1113,7 +1113,7 @@ cardos_put_data_oci(sc_card_t *card, r = sc_check_sw(card, apdu.sw1, apdu.sw2); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "Card returned error"); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } static int diff --git a/src/libopensc/card-coolkey.c b/src/libopensc/card-coolkey.c index 4fd76f0a..42b76eab 100644 --- a/src/libopensc/card-coolkey.c +++ b/src/libopensc/card-coolkey.c @@ -1041,7 +1041,7 @@ static int coolkey_apdu_io(sc_card_t *card, int cla, int ins, int p1, int p2, } err: - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } /* @@ -1211,7 +1211,7 @@ static int coolkey_read_binary(sc_card_t *card, unsigned int idx, SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); if (idx > priv->obj->length) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_FILE_END_REACHED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_FILE_END_REACHED); } /* if we've already read the data, just return it */ @@ -1221,7 +1221,7 @@ static int coolkey_read_binary(sc_card_t *card, unsigned int idx, idx, count); len = MIN(count, priv->obj->length-idx); memcpy(buf, &priv->obj->data[idx], len); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, len); + LOG_FUNC_RETURN(card->ctx, len); } sc_log(card->ctx, @@ -1256,7 +1256,7 @@ static int coolkey_read_binary(sc_card_t *card, unsigned int idx, done: if (data) free(data); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } /* COOLKEY driver is read only. NOTE: The applet supports w/r operations, so it's perfectly @@ -1267,7 +1267,7 @@ static int coolkey_write_binary(sc_card_t *card, unsigned int idx, { SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED); } /* initialize getting a list and return the number of elements in the list */ @@ -1383,7 +1383,7 @@ static int coolkey_get_serial_nr_from_CUID(sc_card_t* card, sc_serial_number_t* LOG_FUNC_CALLED(card->ctx); memcpy(serial->value, &priv->cuid, sizeof(priv->cuid)); serial->len = sizeof(priv->cuid); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(card->ctx, SC_SUCCESS); } int @@ -1631,7 +1631,7 @@ static int coolkey_get_challenge(sc_card_t *card, u8 *rnd, size_t len) NULL, 0, &rnd, &len, NULL, 0), "Could not get challenge"); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, (int) len); + LOG_FUNC_RETURN(card->ctx, (int) len); } static int coolkey_set_security_env(sc_card_t *card, const sc_security_env_t *env, int se_num) @@ -1661,7 +1661,7 @@ static int coolkey_restore_security_env(sc_card_t *card, int se_num) { SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(card->ctx, SC_SUCCESS); } #define MAX_COMPUTE_BUF 200 @@ -1930,7 +1930,7 @@ static int coolkey_select_file(sc_card_t *card, const sc_path_t *in_path, sc_fil if (file_out) { file = sc_file_new(); if (file == NULL) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); file->path = *in_path; /* this could be like the FCI */ file->type = SC_PATH_TYPE_FILE_ID; @@ -2276,7 +2276,7 @@ static int coolkey_init(sc_card_t *card) r = coolkey_initialize(card); if (r < 0) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_CARD); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_CARD); } card->type = SC_CARD_TYPE_COOLKEY_GENERIC; @@ -2301,7 +2301,7 @@ static int coolkey_init(sc_card_t *card) card->caps |= SC_CARD_CAP_ISO7816_PIN_INFO; } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(card->ctx, SC_SUCCESS); } diff --git a/src/libopensc/card-entersafe.c b/src/libopensc/card-entersafe.c index fe732b3e..feea41ad 100644 --- a/src/libopensc/card-entersafe.c +++ b/src/libopensc/card-entersafe.c @@ -188,10 +188,10 @@ static int entersafe_gen_random(sc_card_t *card,u8 *buff,size_t size) SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "entersafe gen random failed"); if(apdu.resplen!=size) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL,SC_ERROR_INTERNAL); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL); memcpy(buff,rbuf,size); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL,r); + LOG_FUNC_RETURN(card->ctx, r); } static int entersafe_cipher_apdu(sc_card_t *card, sc_apdu_t *apdu, @@ -217,7 +217,7 @@ static int entersafe_cipher_apdu(sc_card_t *card, sc_apdu_t *apdu, ctx = EVP_CIPHER_CTX_new(); if (ctx == NULL) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); EVP_CIPHER_CTX_set_padding(ctx,0); if(keylen == 8) @@ -225,12 +225,12 @@ static int entersafe_cipher_apdu(sc_card_t *card, sc_apdu_t *apdu, else if (keylen == 16) EVP_EncryptInit_ex(ctx, EVP_des_ede(), NULL, key, iv); else - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL); len = apdu->lc; if(!EVP_EncryptUpdate(ctx, buff, &len, buff, buffsize)){ sc_log(card->ctx, "entersafe encryption error."); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL); } apdu->lc = len; @@ -544,7 +544,7 @@ static int entersafe_select_aid(sc_card_t *card, { *file_out = sc_file_new(); if(!file_out) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); } } else @@ -649,7 +649,7 @@ static int entersafe_select_path(sc_card_t *card, if (file_out) { sc_file_t *file = sc_file_new(); if (!file) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); file->id = (path[pathlen-2] << 8) + path[pathlen-1]; file->path = card->cache.current_path; diff --git a/src/libopensc/card-flex.c b/src/libopensc/card-flex.c index c6c8fbf0..d9470421 100644 --- a/src/libopensc/card-flex.c +++ b/src/libopensc/card-flex.c @@ -547,7 +547,7 @@ static int select_file_id(sc_card_t *card, const u8 *buf, size_t buflen, } file = sc_file_new(); if (file == NULL) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); /* We abuse process_fci here even though it's not the real FCI. */ r = card->ops->process_fci(card, file, apdu.resp, apdu.resplen); @@ -699,7 +699,7 @@ static int flex_delete_file(sc_card_t *card, const sc_path_t *path) SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); if (path->type != SC_PATH_TYPE_FILE_ID && path->len != 2) { sc_log(card->ctx, "File type has to be SC_PATH_TYPE_FILE_ID\n"); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); } sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE4, 0x00, 0x00); if (!IS_CYBERFLEX(card)) @@ -1301,7 +1301,7 @@ static int flex_logout(sc_card_t *card) r = sc_check_sw(card, apdu.sw1, apdu.sw2); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "Card returned error"); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } diff --git a/src/libopensc/card-gids.c b/src/libopensc/card-gids.c index ba80e931..41e662e8 100644 --- a/src/libopensc/card-gids.c +++ b/src/libopensc/card-gids.c @@ -234,10 +234,10 @@ static int gids_get_DO(sc_card_t* card, int fileIdentifier, int dataObjectIdenti p = sc_asn1_find_tag(card->ctx, buffer, sizeof(buffer), dataObjectIdentifier, &datasize); if (!p) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_FILE_NOT_FOUND); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_FILE_NOT_FOUND); } if (datasize > *responselen) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_BUFFER_TOO_SMALL); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_BUFFER_TOO_SMALL); } memcpy(response, p, datasize); *responselen = datasize; @@ -324,7 +324,7 @@ static int gids_write_gidsfile_without_cache(sc_card_t* card, u8* masterfile, si SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); if (datalen > MAX_GIDS_FILE_SIZE) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_DATA); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_DATA); } r = gids_get_identifiers(card, masterfile, masterfilesize, directory, filename, &fileIdentifier, &dataObjectIdentifier); @@ -343,11 +343,11 @@ static int gids_read_masterfile(sc_card_t* card) { r = gids_get_DO(card, MF_FI, MF_DO, data->masterfile, &data->masterfilesize); if (r<0) { data->masterfilesize = sizeof(data->masterfile); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_CARD); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_CARD); } if (data->masterfilesize < 1 || data->masterfile[0] != 1) { data->masterfilesize = sizeof(data->masterfile); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_CARD); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_CARD); } return r; } @@ -529,7 +529,7 @@ static int gids_get_pin_status(sc_card_t *card, int pinreference, int *tries_lef dataObjectIdentifier = GIDS_PUK_STATUS_OBJECT_IDENTIFIER; break; default: - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OBJECT_NOT_FOUND); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_OBJECT_NOT_FOUND); } r = gids_get_DO(card, GIDS_APPLET_EFID, dataObjectIdentifier, buffer, &buffersize); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "unable to update the masterfile"); @@ -554,7 +554,7 @@ static int gids_get_pin_status(sc_card_t *card, int pinreference, int *tries_lef sc_log(card->ctx, "Pin information for PIN 0x%x: triesleft=%d trieslimit=%d\n", pinreference, (tries_left?*tries_left:-1), (max_tries?*max_tries:-1)); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(card->ctx, SC_SUCCESS); } static int gids_match_card(sc_card_t * card) @@ -610,7 +610,7 @@ static int gids_get_serialnr(sc_card_t * card, sc_serial_number_t * serial) if (SC_MAX_SERIALNR < buffersize) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL); } /* cache serial number */ @@ -621,7 +621,7 @@ static int gids_get_serialnr(sc_card_t * card, sc_serial_number_t * serial) if (serial) memcpy(serial, &card->serialnr, sizeof(*serial)); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(card->ctx, SC_SUCCESS); } // initialize the driver @@ -634,7 +634,7 @@ static int gids_init(sc_card_t * card) // cache some data in memory data = (struct gids_private_data*) calloc(1, sizeof(struct gids_private_data)); if (!data) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); } memset(data, 0, sizeof(struct gids_private_data)); card->drv_data = data; @@ -670,7 +670,7 @@ static int gids_get_crypto_identifier_from_key_ref(sc_card_t *card, const unsign int recordsnum = (int) (data->cmapfilesize / sizeof(CONTAINER_MAP_RECORD)); int index = keyref - GIDS_FIRST_KEY_IDENTIFIER; if (index >= recordsnum) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); } *cryptoidentifier = 0x00; /* initialize to zero */ if (records[index].wKeyExchangeKeySizeBits == 1024 || records[index].wSigKeySizeBits == 1024) { @@ -709,7 +709,7 @@ static int gids_get_crypto_identifier_from_key_ref(sc_card_t *card, const unsign *cryptoidentifier = GIDS_ECC_521_IDENTIFIER; return SC_SUCCESS; } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); } // same here @@ -774,7 +774,7 @@ static int gids_set_security_env(sc_card_t *card, } } if (!(env->flags & SC_SEC_ENV_KEY_REF_PRESENT)) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED); } if (env->flags & SC_SEC_ENV_KEY_REF_SYMMETRIC) *p++ = 0x83; @@ -997,7 +997,7 @@ static int gids_read_binary(sc_card_t *card, unsigned int offset, r = gids_get_DO(card, data->currentEFID, data->currentDO, buffer, &(buffersize)); if (r <0) return r; if (buffersize < 4) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_DATA); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_DATA); } if (buffer[0] == 1 && buffer[1] == 0) { size_t expectedsize = buffer[2] + buffer[3] * 0x100; @@ -1005,17 +1005,17 @@ static int gids_read_binary(sc_card_t *card, unsigned int offset, r = sc_decompress(data->buffer, &(data->buffersize), buffer+4, buffersize-4, COMPRESSION_ZLIB); if (r != SC_SUCCESS) { sc_log(card->ctx, "Zlib error: %d", r); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } if (data->buffersize != expectedsize) { sc_log(card->ctx, "expected size: %"SC_FORMAT_LEN_SIZE_T"u real size: %"SC_FORMAT_LEN_SIZE_T"u", expectedsize, data->buffersize); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_DATA); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_DATA); } } else { sc_log(card->ctx, "unknown compression method %d", buffer[0] + (buffer[1] <<8)); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_DATA); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_DATA); } data->state = GIDS_STATE_READ_DATA_PRESENT; } @@ -1116,7 +1116,7 @@ gids_select_key_reference(sc_card_t *card, sc_pkcs15_prkey_info_t* key_info) { } // use a new key number if (recordsnum > GIDS_MAX_CONTAINER) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_ENOUGH_MEMORY); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_ENOUGH_MEMORY); } key_info->key_reference = (int) (GIDS_FIRST_KEY_IDENTIFIER + recordsnum); } else { @@ -1124,13 +1124,13 @@ gids_select_key_reference(sc_card_t *card, sc_pkcs15_prkey_info_t* key_info) { size_t i = key_info->key_reference - GIDS_FIRST_KEY_IDENTIFIER; if (i > GIDS_MAX_CONTAINER) { sc_log(card->ctx, "invalid key ref %d", key_info->key_reference); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); } if (i > recordsnum) { sc_log(card->ctx, "container num is not allowed %"SC_FORMAT_LEN_SIZE_T"u %"SC_FORMAT_LEN_SIZE_T"u", i, recordsnum); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); } } snprintf(ch_tmp, sizeof(ch_tmp), "3FFFB0%02X", (u8) (0xFF & key_info->key_reference)); @@ -1197,7 +1197,7 @@ static int gids_perform_create_keyfile(sc_card_t *card, u8 keytype, u8 kid, u8 a apdu.datalen = sizeof(sign); apdu.data = sign; } else { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED); } r = sc_transmit_apdu(card, &apdu); @@ -1214,7 +1214,7 @@ static int gids_perform_create_keyfile(sc_card_t *card, u8 keytype, u8 kid, u8 a r = sc_check_sw(card, apdu.sw1, apdu.sw2); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "ACTIVATE_FILE returned error"); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } // perform the creation of the keyfile and its registration in the cmapfile and keymap file @@ -1242,7 +1242,7 @@ static int gids_create_keyfile(sc_card_t *card, sc_pkcs15_object_t *object) { assert((object->type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PRKEY); if (!algid) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED); } // masterfile & cmapfile have been refreshed in gids_perform_create_keyfile @@ -1251,7 +1251,7 @@ static int gids_create_keyfile(sc_card_t *card, sc_pkcs15_object_t *object) { // sanity check if (containernum > recordnum || containernum > GIDS_MAX_CONTAINER) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL); // refresh the key map file keymapbuffersize = sizeof(keymapbuffer); @@ -1259,7 +1259,7 @@ static int gids_create_keyfile(sc_card_t *card, sc_pkcs15_object_t *object) { if (r<0) { // the keymap DO should be present if the cmapfile is not empty if (recordnum > 0) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL); } // else can be empty if not record keymapbuffersize = 0; @@ -1270,7 +1270,7 @@ static int gids_create_keyfile(sc_card_t *card, sc_pkcs15_object_t *object) { sc_log(card->ctx , "keymaprecordnum = %"SC_FORMAT_LEN_SIZE_T"u recordnum = %"SC_FORMAT_LEN_SIZE_T"u", keymaprecordnum, recordnum); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL); } } @@ -1307,7 +1307,7 @@ static int gids_create_keyfile(sc_card_t *card, sc_pkcs15_object_t *object) { records->wSigKeySizeBits = (unsigned short) key_info->modulus_length; keymaprecord->keytype = GIDS_KEY_TYPE_AT_SIGNATURE; } else { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED); } //the GIDS card must have unique container names @@ -1345,7 +1345,7 @@ static int gids_create_keyfile(sc_card_t *card, sc_pkcs15_object_t *object) { r = gids_write_gidsfile(card, "mscp", "cmapfile", cmapbuffer, cmapbuffersize); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "unable to write the cmap file after the container creation"); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } // generate a key on an existing container @@ -1367,7 +1367,7 @@ static int gids_generate_key(sc_card_t *card, sc_pkcs15_object_t *object, struct assert((object->type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PRKEY); if ((key_info->key_reference > GIDS_FIRST_KEY_IDENTIFIER + GIDS_MAX_CONTAINER) || (kid < GIDS_FIRST_KEY_IDENTIFIER)) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_DATA); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_DATA); } sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, INS_GENERATE_ASYMECTRIC_KEY_PAIR, 0x00, 0x00); @@ -1386,7 +1386,7 @@ static int gids_generate_key(sc_card_t *card, sc_pkcs15_object_t *object, struct r = sc_pkcs15_decode_pubkey(card->ctx, pubkey, buffer, buffersize); if (buffer) free(buffer); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } // import the key in an existing container @@ -1496,7 +1496,7 @@ static int gids_encode_certificate(sc_card_t *card, u8* source, size_t sourcesiz return SC_ERROR_BUFFER_TOO_SMALL; } if (sourcesize > 0xFFFF) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); } // format is: // 2 bytes for compression version @@ -1579,18 +1579,18 @@ static int gids_delete_container_num(sc_card_t *card, size_t containernum) { // sanity check if (containernum >= recordnum || recordnum > GIDS_MAX_CONTAINER) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL); // refresh the key map file keymapbuffersize = sizeof(keymapbuffer); r = gids_get_DO(card, KEYMAP_FI, KEYMAP_DO, keymapbuffer, &keymapbuffersize); if (r<0) { // the keymap DO should be present if the cmapfile is not empty - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL); } keymaprecordnum = (keymapbuffersize - 1) / sizeof(struct gids_keymap_record); if (keymaprecordnum != recordnum) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL); } // update the key map file @@ -1615,7 +1615,7 @@ static int gids_delete_container_num(sc_card_t *card, size_t containernum) { r = gids_write_gidsfile(card, "mscp", "cmapfile", cmapbuffer, cmapbuffersize); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "unable to write the cmap file after the container creation"); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(card->ctx, SC_SUCCESS); } // delete a certificate associated to a container @@ -1640,7 +1640,7 @@ static int gids_delete_cert(sc_card_t *card, sc_pkcs15_object_t* object) { // remove the file reference from the masterfile if (cert_info->path.len != 4) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL); } fileIdentifier = cert_info->path.value[0] * 0x100 + cert_info->path.value[1]; DO = cert_info->path.value[2] * 0x100 + cert_info->path.value[3]; @@ -1656,7 +1656,7 @@ static int gids_delete_cert(sc_card_t *card, sc_pkcs15_object_t* object) { } } if (recordnum == (size_t) -1) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_FILE_NOT_FOUND); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_FILE_NOT_FOUND); } for (i = 1 + (recordnum+1) * sizeof(gids_mf_record_t); i < masterfilebuffersize; i++) { @@ -1717,7 +1717,7 @@ static int gids_initialize_create_file(sc_card_t *card, u8* command, size_t comm r = sc_transmit_apdu(card, &apdu); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "APDU2 transmit failed"); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, sc_check_sw(card, apdu.sw1, apdu.sw2), "invalid return"); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } // used by gids_initialize to set the admin key @@ -1862,7 +1862,7 @@ static int gids_initialize(sc_card_t *card, sc_cardctl_gids_init_param_t* param) r = sc_transmit_apdu(card, &apdu); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "APDU transmit failed"); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, sc_check_sw(card, apdu.sw1, apdu.sw2), "invalid return"); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } // execute an admin authentication based on a secret key @@ -1873,7 +1873,7 @@ static int gids_initialize(sc_card_t *card, sc_cardctl_gids_init_param_t* param) // this data comes from the reverse of the GIDS minidriver. static int gids_authenticate_admin(sc_card_t *card, u8* key) { #ifndef ENABLE_OPENSSL - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED); #else EVP_CIPHER_CTX *ctx = NULL; int r; @@ -1896,7 +1896,7 @@ static int gids_authenticate_admin(sc_card_t *card, u8* key) { // this is CBC instead of ECB cipher = EVP_des_ede3_cbc(); if (!cipher) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL); } // select the admin key @@ -1938,22 +1938,22 @@ static int gids_authenticate_admin(sc_card_t *card, u8* key) { // init crypto ctx = EVP_CIPHER_CTX_new(); if (ctx == NULL) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL); } if (!EVP_EncryptInit(ctx, cipher, key, NULL)) { EVP_CIPHER_CTX_free(ctx); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL); } EVP_CIPHER_CTX_set_padding(ctx,0); if (!EVP_EncryptUpdate(ctx, buffer2, &buffer2size, buffer, sizeof(buffer))) { EVP_CIPHER_CTX_free(ctx); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL); } if(!EVP_EncryptFinal(ctx, buffer2+buffer2size, &buffer2size)) { EVP_CIPHER_CTX_free(ctx); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL); } EVP_CIPHER_CTX_free(ctx); ctx = NULL; @@ -1972,45 +1972,45 @@ static int gids_authenticate_admin(sc_card_t *card, u8* key) { if (apdu.resplen != 44) { sc_log(card->ctx, "Expecting a response len of 44 - found %d",(int) apdu.resplen); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL); } // init crypto ctx = EVP_CIPHER_CTX_new(); if (ctx == NULL) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL); } if (!EVP_DecryptInit(ctx, cipher, key, NULL)) { EVP_CIPHER_CTX_free(ctx); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL); } EVP_CIPHER_CTX_set_padding(ctx,0); if (!EVP_DecryptUpdate(ctx, buffer3, &buffer3size, apdu.resp + 4, apdu.resplen - 4)) { sc_log(card->ctx, "unable to decrypt data"); EVP_CIPHER_CTX_free(ctx); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_PIN_CODE_INCORRECT); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_PIN_CODE_INCORRECT); } if(!EVP_DecryptFinal(ctx, buffer3+buffer3size, &buffer3size)) { sc_log(card->ctx, "unable to decrypt final data"); EVP_CIPHER_CTX_free(ctx); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_PIN_CODE_INCORRECT); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_PIN_CODE_INCORRECT); } sc_log(card->ctx, "data has been decrypted using the key"); if (memcmp(buffer3, randomR1, 16) != 0) { sc_log(card->ctx, "R1 doesn't match"); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_PIN_CODE_INCORRECT); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_PIN_CODE_INCORRECT); } if (memcmp(buffer3 + 16, randomR2, 16) != 0) { sc_log(card->ctx, "R2 doesn't match"); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_PIN_CODE_INCORRECT); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_PIN_CODE_INCORRECT); } if (buffer[39] != 0x80) { sc_log(card->ctx, "Padding not found"); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_PIN_CODE_INCORRECT); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_PIN_CODE_INCORRECT); } EVP_CIPHER_CTX_free(ctx); ctx = NULL; - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(card->ctx, SC_SUCCESS); #endif } diff --git a/src/libopensc/card-gpk.c b/src/libopensc/card-gpk.c index 88590aaf..982f9101 100644 --- a/src/libopensc/card-gpk.c +++ b/src/libopensc/card-gpk.c @@ -1572,7 +1572,7 @@ gpk_pkfile_load(sc_card_t *card, struct sc_cardctl_gpk_pkload *args) r = sc_check_sw(card, apdu.sw1, apdu.sw2); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "Card returned error"); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } /* diff --git a/src/libopensc/card-incrypto34.c b/src/libopensc/card-incrypto34.c index 79c49350..26db4d17 100644 --- a/src/libopensc/card-incrypto34.c +++ b/src/libopensc/card-incrypto34.c @@ -212,7 +212,7 @@ get_next_part: end: r = fids; - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } static void add_acl_entry(sc_file_t *file, int op, u8 byte) @@ -311,7 +311,7 @@ static int incrypto34_select_file(sc_card_t *card, r = iso_ops->select_file(card, in_path, file); if (r >= 0 && file) parse_sec_attr((*file), (*file)->sec_attr, (*file)->sec_attr_len); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } static int incrypto34_create_file(sc_card_t *card, sc_file_t *file) @@ -403,7 +403,7 @@ static int incrypto34_create_file(sc_card_t *card, sc_file_t *file) /* FIXME: if this is a DF and there's an AID, set it here * using PUT_DATA_FCI */ -out: SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); +out: LOG_FUNC_RETURN(card->ctx, r); } /* @@ -424,7 +424,7 @@ static int incrypto34_restore_security_env(sc_card_t *card, int se_num) r = sc_check_sw(card, apdu.sw1, apdu.sw2); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "Card returned error"); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } /* @@ -480,7 +480,7 @@ static int incrypto34_set_security_env(sc_card_t *card, r = sc_check_sw(card, apdu.sw1, apdu.sw2); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "Card returned error"); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } /* @@ -619,7 +619,7 @@ incrypto34_lifecycle_get(sc_card_t *card, int *mode) r = SC_ERROR_INTERNAL; } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } static int @@ -647,7 +647,7 @@ incrypto34_put_data_oci(sc_card_t *card, r = sc_check_sw(card, apdu.sw1, apdu.sw2); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "Card returned error"); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } static int diff --git a/src/libopensc/card-itacns.c b/src/libopensc/card-itacns.c index 73412383..04bfec68 100644 --- a/src/libopensc/card-itacns.c +++ b/src/libopensc/card-itacns.c @@ -478,7 +478,7 @@ static int itacns_select_file(sc_card_t *card, parse_sec_attr((*file), (*file)->sec_attr, (*file)->sec_attr_len); } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } static int itacns_get_serialnr(sc_card_t *card, sc_serial_number_t *serial) diff --git a/src/libopensc/card-jcop.c b/src/libopensc/card-jcop.c index 85feddc6..1e5643b2 100644 --- a/src/libopensc/card-jcop.c +++ b/src/libopensc/card-jcop.c @@ -610,7 +610,7 @@ static int jcop_set_security_env(sc_card_t *card, assert(card != NULL && env != NULL); if (se_num) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); if (drvdata->selected == SELECT_MF || drvdata->selected == SELECT_EFDIR) { drvdata->invalid_senv=1; diff --git a/src/libopensc/card-masktech.c b/src/libopensc/card-masktech.c index a8d11160..a696af71 100644 --- a/src/libopensc/card-masktech.c +++ b/src/libopensc/card-masktech.c @@ -309,7 +309,7 @@ static int masktech_get_serialnr(sc_card_t * card, sc_serial_number_t * serial) int rv; if (!serial) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); /* Get smart card serial number */ card->cla = 0x80; @@ -327,7 +327,7 @@ static int masktech_get_serialnr(sc_card_t * card, sc_serial_number_t * serial) if (SC_MAX_SERIALNR < apdu.resplen) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL); } /* cache serial number */ card->serialnr.len = apdu.resplen; @@ -337,7 +337,7 @@ static int masktech_get_serialnr(sc_card_t * card, sc_serial_number_t * serial) if (serial) memcpy(serial, &card->serialnr, sizeof(*serial)); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(card->ctx, SC_SUCCESS); } diff --git a/src/libopensc/card-mcrd.c b/src/libopensc/card-mcrd.c index d110aa59..2d7b1cb2 100644 --- a/src/libopensc/card-mcrd.c +++ b/src/libopensc/card-mcrd.c @@ -409,7 +409,7 @@ static int load_special_files(sc_card_t * card) return 0; /* yes. */ clear_special_files(dfi); if (!dfi) - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL); + LOG_FUNC_RETURN(ctx, SC_ERROR_INTERNAL); /* Read rule file. Note that we bypass our cache here. */ r = select_part(card, MCRD_SEL_EF, EF_Rule, NULL); @@ -427,7 +427,7 @@ static int load_special_files(sc_card_t * card) } else { rule = malloc(sizeof *rule + r); if (!rule) - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY); rule->recno = recno; rule->datalen = r; memcpy(rule->data, recbuf, r); @@ -458,7 +458,7 @@ static int load_special_files(sc_card_t * card) } else { keyd = malloc(sizeof *keyd + r); if (!keyd) - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY); keyd->recno = recno; keyd->datalen = r; memcpy(keyd->data, recbuf, r); @@ -794,7 +794,7 @@ do_select(sc_card_t * card, u8 kind, if (file) { *file = sc_file_new(); if (!*file) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); (*file)->type = SC_FILE_TYPE_DF; return SC_SUCCESS; } @@ -803,7 +803,7 @@ do_select(sc_card_t * card, u8 kind, if (p2 == 0x04 && apdu.resp[0] == 0x62) { *file = sc_file_new(); if (!*file) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); /* EstEID v3.0 cards are buggy and sometimes return a double 0x62 tag */ if (card->type == SC_CARD_TYPE_MCRD_ESTEID_V30 && apdu.resp[2] == 0x62) process_fcp(card, *file, apdu.resp + 4, apdu.resp[3]); @@ -815,7 +815,7 @@ do_select(sc_card_t * card, u8 kind, if (p2 != 0x0C && apdu.resp[0] == 0x6F) { *file = sc_file_new(); if (!*file) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); if (apdu.resp[1] <= apdu.resplen) process_fcp(card, *file, apdu.resp + 2, apdu.resp[1]); return SC_SUCCESS; diff --git a/src/libopensc/card-miocos.c b/src/libopensc/card-miocos.c index a41ce153..ab02be76 100644 --- a/src/libopensc/card-miocos.c +++ b/src/libopensc/card-miocos.c @@ -337,7 +337,7 @@ static int miocos_get_acl(sc_card_t *card, sc_file_t *file) seq = sc_asn1_skip_tag(card->ctx, &seq, &left, SC_ASN1_SEQUENCE | SC_ASN1_CONS, &left); if (seq == NULL) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_UNKNOWN_DATA_RECEIVED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "Unable to process reply"); for (i = 1; i < 15; i++) { int j; @@ -415,7 +415,7 @@ static int miocos_delete_file(sc_card_t *card, const sc_path_t *path) SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); if (path->type != SC_PATH_TYPE_FILE_ID && path->len != 2) { sc_log(card->ctx, "File type has to be SC_PATH_TYPE_FILE_ID\n"); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); } r = sc_select_file(card, path, NULL); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "Unable to select file to be deleted"); @@ -437,11 +437,11 @@ static int miocos_create_ac(sc_card_t *card, size_t sendsize; if (ac->max_tries > 15) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); switch (ac->type) { case SC_CARDCTL_MIOCOS_AC_PIN: if (ac->max_unblock_tries > 15) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); miocos_type = 0x01; sbuf[0] = (ac->max_tries << 4) | ac->max_tries; sbuf[1] = 0xFF; /* FIXME... */ diff --git a/src/libopensc/card-muscle.c b/src/libopensc/card-muscle.c index bc660d2f..d62317a0 100644 --- a/src/libopensc/card-muscle.c +++ b/src/libopensc/card-muscle.c @@ -205,7 +205,7 @@ static int muscle_read_binary(sc_card_t *card, unsigned int idx, u8* buf, size_t mscfs_file_t *file; r = mscfs_check_selection(fs, -1); - if(r < 0) SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + if(r < 0) LOG_FUNC_RETURN(card->ctx, r); file = &fs->cache.array[fs->currentFileIndex]; objectId = file->objectId; /* memcpy(objectId.id, file->objectId.id, 4); */ @@ -215,7 +215,7 @@ static int muscle_read_binary(sc_card_t *card, unsigned int idx, u8* buf, size_t oid[2] = oid[3] = 0; } r = msc_read_object(card, objectId, idx, buf, count); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } static int muscle_update_binary(sc_card_t *card, unsigned int idx, const u8* buf, size_t count, unsigned long flags) @@ -227,7 +227,7 @@ static int muscle_update_binary(sc_card_t *card, unsigned int idx, const u8* buf u8* oid = objectId.id; r = mscfs_check_selection(fs, -1); - if(r < 0) SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + if(r < 0) LOG_FUNC_RETURN(card->ctx, r); file = &fs->cache.array[fs->currentFileIndex]; objectId = file->objectId; @@ -240,7 +240,7 @@ static int muscle_update_binary(sc_card_t *card, unsigned int idx, const u8* buf if(file->size < idx + count) { int newFileSize = idx + count; u8* buffer = malloc(newFileSize); - if(buffer == NULL) SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + if(buffer == NULL) LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); r = msc_read_object(card, objectId, 0, buffer, file->size); /* TODO: RETRIEVE ACLS */ @@ -255,7 +255,7 @@ static int muscle_update_binary(sc_card_t *card, unsigned int idx, const u8* buf file->size = newFileSize; update_bin_free_buffer: free(buffer); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } else { r = msc_update_object(card, objectId, idx, buf, count); } @@ -378,7 +378,7 @@ static int select_item(sc_card_t *card, const sc_path_t *path_in, sc_file_t ** f /* Check if its the right type */ if(requiredType >= 0 && requiredType != file_data->ef) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); } oid = file_data->objectId.id; /* Is it a file or directory */ @@ -460,7 +460,7 @@ static int muscle_init(sc_card_t *card) card->name = "MuscleApplet"; card->drv_data = malloc(sizeof(muscle_private_t)); if(!card->drv_data) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); } memset(card->drv_data, 0, sizeof(muscle_private_t)); priv = MUSCLE_DATA(card); @@ -468,7 +468,7 @@ static int muscle_init(sc_card_t *card) priv->fs = mscfs_new(); if(!priv->fs) { free(card->drv_data); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); } priv->fs->udata = card; priv->fs->listFile = _listFile; diff --git a/src/libopensc/card-npa.c b/src/libopensc/card-npa.c index c8e981f5..2c225002 100644 --- a/src/libopensc/card-npa.c +++ b/src/libopensc/card-npa.c @@ -763,7 +763,7 @@ static int npa_pin_cmd(struct sc_card *card, } err: - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } static int npa_logout(sc_card_t *card) diff --git a/src/libopensc/card-oberthur.c b/src/libopensc/card-oberthur.c index 6ca49f1a..97db1490 100644 --- a/src/libopensc/card-oberthur.c +++ b/src/libopensc/card-oberthur.c @@ -1348,7 +1348,7 @@ auth_update_component(struct sc_card *card, struct auth_update_component_info *a ctx = EVP_CIPHER_CTX_new(); if (ctx == NULL) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL,SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); p2 = 0; if (args->len == 24) diff --git a/src/libopensc/card-rtecp.c b/src/libopensc/card-rtecp.c index c86f77e0..5fead222 100644 --- a/src/libopensc/card-rtecp.c +++ b/src/libopensc/card-rtecp.c @@ -57,9 +57,9 @@ static int rtecp_match_card(sc_card_t *card) i = _sc_match_atr(card, rtecp_atrs, &card->type); if (i >= 0) { card->name = rtecp_atrs[i].name; - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, 1); + LOG_FUNC_RETURN(card->ctx, 1); } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, 0); + LOG_FUNC_RETURN(card->ctx, 0); } static int rtecp_init(sc_card_t *card) @@ -261,7 +261,7 @@ static int rtecp_select_file(sc_card_t *card, case SC_PATH_TYPE_DF_NAME: case SC_PATH_TYPE_FROM_CURRENT: case SC_PATH_TYPE_PARENT: - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED); } assert(iso_ops && iso_ops->select_file); file_out_copy = file_out; @@ -352,7 +352,7 @@ static int rtecp_cipher(sc_card_t *card, const u8 *data, size_t data_len, { free(buf); free(buf_out); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); } for (i = 0; i < data_len; ++i) @@ -438,7 +438,7 @@ static int rtecp_change_reference_data(sc_card_t *card, unsigned int type, sc_log(card->ctx, "newlen = %"SC_FORMAT_LEN_SIZE_T"u\n", newlen); if (newlen > 0xFFFF) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); if (type == SC_AC_CHV && old && oldlen != 0) { r = sc_verify(card, type, ref_qualifier, old, oldlen, tries_left); @@ -456,7 +456,7 @@ static int rtecp_change_reference_data(sc_card_t *card, unsigned int type, buf_length = (2 + sizeof(rsf_length)) + newlen + 2*(transmits_num); p = buf = (u8 *)malloc(buf_length); if (buf == NULL) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); buf_end = buf + buf_length; sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x24, 0x01, ref_qualifier); @@ -575,13 +575,13 @@ static int rtecp_list_files(sc_card_t *card, u8 *buf, size_t buflen) SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, ""); if (apdu.resplen <= 2) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_WRONG_LENGTH); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_WRONG_LENGTH); /* save first file(dir) ID */ tag = sc_asn1_find_tag(card->ctx, apdu.resp + 2, apdu.resplen - 2, 0x83, &taglen); if (!tag || taglen != sizeof(previd)) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_UNKNOWN_DATA_RECEIVED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED); memcpy(previd, tag, sizeof(previd)); if (len + sizeof(previd) <= buflen) @@ -593,7 +593,7 @@ static int rtecp_list_files(sc_card_t *card, u8 *buf, size_t buflen) tag = sc_asn1_find_tag(card->ctx, apdu.resp + 2, apdu.resplen - 2, 0x82, &taglen); if (!tag || taglen != 2) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_UNKNOWN_DATA_RECEIVED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED); if (tag[0] == 0x38) { /* Select parent DF of the current DF */ @@ -632,7 +632,7 @@ static int rtecp_card_ctl(sc_card_t *card, unsigned long request, void *data) break; case SC_CARDCTL_GET_SERIALNR: if (!serial) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xCA, 0x01, 0x81); apdu.resp = buf; apdu.resplen = sizeof(buf); @@ -641,7 +641,7 @@ static int rtecp_card_ctl(sc_card_t *card, unsigned long request, void *data) break; case SC_CARDCTL_RTECP_GENERATE_KEY: if (!genkey_data) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0x46, 0x80, genkey_data->key_id); apdu.resp = buf; @@ -656,7 +656,7 @@ static int rtecp_card_ctl(sc_card_t *card, unsigned long request, void *data) default: sc_log(card->ctx, "request = 0x%lx\n", request); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED); } r = sc_transmit_apdu(card, &apdu); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "APDU transmit failed"); @@ -731,7 +731,7 @@ static int rtecp_construct_fci(sc_card_t *card, const sc_file_t *file, break; case SC_FILE_TYPE_INTERNAL_EF: default: - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED); } buf[1] = 0; sc_asn1_put_tag(0x82, buf, 2, p, *outlen - (p - out), &p); diff --git a/src/libopensc/card-rutoken.c b/src/libopensc/card-rutoken.c index 57d7f43f..6fcea6c5 100644 --- a/src/libopensc/card-rutoken.c +++ b/src/libopensc/card-rutoken.c @@ -95,7 +95,7 @@ static int rutoken_finish(sc_card_t *card) SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); assert(card->drv_data); free(card->drv_data); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(card->ctx, SC_SUCCESS); } static int rutoken_match_card(sc_card_t *card) @@ -104,9 +104,9 @@ static int rutoken_match_card(sc_card_t *card) if (_sc_match_atr(card, rutoken_atrs, &card->type) >= 0) { sc_log(card->ctx, "ATR recognized as Rutoken\n"); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, 1); + LOG_FUNC_RETURN(card->ctx, 1); } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, 0); + LOG_FUNC_RETURN(card->ctx, 0); } static int token_init(sc_card_t *card, const char *card_name) @@ -136,7 +136,7 @@ static int rutoken_init(sc_card_t *card) if (ret != SC_SUCCESS) { ret = SC_ERROR_INVALID_CARD; } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, ret); + LOG_FUNC_RETURN(card->ctx, ret); } static const struct sc_card_error rutoken_errors[] = { @@ -265,13 +265,13 @@ static int rutoken_list_files(sc_card_t *card, u8 *buf, size_t buflen) SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, ret, ""); if (apdu.resplen <= 2) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_WRONG_LENGTH); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_WRONG_LENGTH); /* save first file(dir) ID */ tag = sc_asn1_find_tag(card->ctx, apdu.resp + 2, apdu.resplen - 2, 0x83, &taglen); if (!tag || taglen != sizeof(previd)) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_UNKNOWN_DATA_RECEIVED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED); memcpy(previd, tag, sizeof(previd)); if (len + sizeof(previd) <= buflen) @@ -283,7 +283,7 @@ static int rutoken_list_files(sc_card_t *card, u8 *buf, size_t buflen) tag = sc_asn1_find_tag(card->ctx, apdu.resp + 2, apdu.resplen - 2, 0x82, &taglen); if (!tag || taglen != 2) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_UNKNOWN_DATA_RECEIVED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED); if (tag[0] == 0x38) { /* Select parent DF of the current DF */ @@ -301,7 +301,7 @@ static int rutoken_list_files(sc_card_t *card, u8 *buf, size_t buflen) apdu.data = previd; apdu.datalen = sizeof(previd); } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, len); + LOG_FUNC_RETURN(card->ctx, len); } static void set_acl_from_sec_attr(sc_card_t *card, sc_file_t *file) @@ -377,7 +377,7 @@ static int rutoken_select_file(sc_card_t *card, { case SC_PATH_TYPE_FILE_ID: if (pathlen != 2) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); break; case SC_PATH_TYPE_PATH: if (pathlen >= 2 && memcmp(path, "\x3F\x00", 2) == 0) @@ -392,9 +392,9 @@ static int rutoken_select_file(sc_card_t *card, case SC_PATH_TYPE_DF_NAME: case SC_PATH_TYPE_FROM_CURRENT: case SC_PATH_TYPE_PARENT: - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED); default: - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); } swap_pair(path, pathlen); apdu.lc = pathlen; @@ -417,16 +417,16 @@ static int rutoken_select_file(sc_card_t *card, SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, ret, ""); if (apdu.resplen > 0 && apdu.resp[0] != 0x62) /* Tag 0x62 - FCP */ - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_UNKNOWN_DATA_RECEIVED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED); file = sc_file_new(); if (file == NULL) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); file->path = *in_path; if (card->ops->process_fci == NULL) { sc_file_free(file); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED); } if (apdu.resplen > 1 && apdu.resplen >= (size_t)apdu.resp[1] + 2) { @@ -443,7 +443,7 @@ static int rutoken_select_file(sc_card_t *card, assert(file_out); *file_out = file; } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, ret); + LOG_FUNC_RETURN(card->ctx, ret); } static int rutoken_process_fci(struct sc_card *card, sc_file_t *file, @@ -470,7 +470,7 @@ static int rutoken_process_fci(struct sc_card *card, sc_file_t *file, sc_log(card->ctx, " bytes in file: %"SC_FORMAT_LEN_SIZE_T"u", file->size); } } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, ret); + LOG_FUNC_RETURN(card->ctx, ret); } static int rutoken_construct_fci(sc_card_t *card, const sc_file_t *file, @@ -511,7 +511,7 @@ static int rutoken_construct_fci(sc_card_t *card, const sc_file_t *file, break; case SC_FILE_TYPE_INTERNAL_EF: default: - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED); } buf[1] = 0; sc_asn1_put_tag(0x82, buf, 2, p, *outlen - (p - out), &p); @@ -609,7 +609,7 @@ static int rutoken_create_file(sc_card_t *card, sc_file_t *file) } assert(iso_ops && iso_ops->create_file); ret = iso_ops->create_file(card, file); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, ret); + LOG_FUNC_RETURN(card->ctx, ret); } static int rutoken_delete_file(sc_card_t *card, const sc_path_t *path) @@ -621,7 +621,7 @@ static int rutoken_delete_file(sc_card_t *card, const sc_path_t *path) if (!path || path->type != SC_PATH_TYPE_FILE_ID || (path->len != 0 && path->len != 2)) { sc_log(card->ctx, "File type has to be SC_PATH_TYPE_FILE_ID\n"); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); } if (path->len == sizeof(sbuf)) { @@ -635,7 +635,7 @@ static int rutoken_delete_file(sc_card_t *card, const sc_path_t *path) else /* No file ID given: means currently selected file */ sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0xE4, 0x00, 0x00); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, sc_transmit_apdu(card, &apdu), "APDU transmit failed"); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, sc_check_sw(card, apdu.sw1, apdu.sw2)); + LOG_FUNC_RETURN(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2)); } static int rutoken_verify(sc_card_t *card, unsigned int type, int ref_qualifier, @@ -679,7 +679,7 @@ static int rutoken_verify(sc_card_t *card, unsigned int type, int ref_qualifier, if (ret == SC_ERROR_PIN_CODE_INCORRECT) *tries_left = (int)(apdu.sw2 & 0x0f); } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, ret); + LOG_FUNC_RETURN(card->ctx, ret); } static int rutoken_logout(sc_card_t *card) @@ -698,7 +698,7 @@ static int rutoken_logout(sc_card_t *card) ret = sc_transmit_apdu(card, &apdu); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, ret, "APDU transmit failed"); ret = sc_check_sw(card, apdu.sw1, apdu.sw2); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, ret); + LOG_FUNC_RETURN(card->ctx, ret); } static int rutoken_change_reference_data(sc_card_t *card, unsigned int type, @@ -721,7 +721,7 @@ static int rutoken_change_reference_data(sc_card_t *card, unsigned int type, ret = sc_transmit_apdu(card, &apdu); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, ret, "APDU transmit failed"); ret = sc_check_sw(card, apdu.sw1, apdu.sw2); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, ret); + LOG_FUNC_RETURN(card->ctx, ret); } static int rutoken_reset_retry_counter(sc_card_t *card, unsigned int type, @@ -747,7 +747,7 @@ static int rutoken_reset_retry_counter(sc_card_t *card, unsigned int type, ret = sc_transmit_apdu(card, &apdu); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, ret, "APDU transmit failed"); ret = sc_check_sw(card, apdu.sw1, apdu.sw2); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, ret); + LOG_FUNC_RETURN(card->ctx, ret); } static int rutoken_restore_security_env(sc_card_t *card, int se_num) @@ -760,7 +760,7 @@ static int rutoken_restore_security_env(sc_card_t *card, int se_num) ret = sc_transmit_apdu(card, &apdu); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, ret, "APDU transmit failed"); ret = sc_check_sw(card, apdu.sw1, apdu.sw2); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, ret); + LOG_FUNC_RETURN(card->ctx, ret); } static int rutoken_set_security_env(sc_card_t *card, @@ -774,18 +774,18 @@ static int rutoken_set_security_env(sc_card_t *card, SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); if (!env) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); senv = (auth_senv_t*)card->drv_data; if (!senv) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL); if (env->algorithm != SC_ALGORITHM_GOST) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED); senv->algorithm = SC_ALGORITHM_GOST; if (env->key_ref_len != 1) { sc_log(card->ctx, "No or invalid key reference\n"); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); } data[2] = env->key_ref[0]; /* select component */ @@ -804,13 +804,13 @@ static int rutoken_set_security_env(sc_card_t *card, apdu.p2 = 0xAA; break; default: - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); } /* set SE */ ret = sc_transmit_apdu(card, &apdu); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, ret, "APDU transmit failed"); ret = sc_check_sw(card, apdu.sw1, apdu.sw2); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, ret); + LOG_FUNC_RETURN(card->ctx, ret); } static void rutoken_set_do_hdr(u8 *data, size_t *data_len, sc_DOHdrV2_t *hdr) @@ -1128,13 +1128,13 @@ static int rutoken_compute_signature(struct sc_card *card, SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); if (!senv) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL); if (senv->algorithm == SC_ALGORITHM_GOST) ret = rutoken_compute_mac_gost(card, data, datalen, out, outlen); else ret = SC_ERROR_NOT_SUPPORTED; - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, ret); + LOG_FUNC_RETURN(card->ctx, ret); } static int rutoken_get_challenge(sc_card_t *card, u8 *rnd, size_t len) @@ -1264,7 +1264,7 @@ static int rutoken_card_ctl(sc_card_t *card, unsigned long cmd, void *ptr) break; } } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, ret); + LOG_FUNC_RETURN(card->ctx, ret); } static struct sc_card_driver* get_rutoken_driver(void) diff --git a/src/libopensc/card-setcos.c b/src/libopensc/card-setcos.c index f78fd9da..a1facab0 100644 --- a/src/libopensc/card-setcos.c +++ b/src/libopensc/card-setcos.c @@ -1003,7 +1003,7 @@ static int setcos_putdata(struct sc_card *card, struct sc_cardctl_setcos_data_ob r = sc_check_sw(card, apdu.sw1, apdu.sw2); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "PUT_DATA returned error"); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } /* Read internal data, e.g. get RSA public key */ @@ -1039,7 +1039,7 @@ static int setcos_getdata(struct sc_card *card, struct sc_cardctl_setcos_data_ob else data_obj->DataLen = apdu.resplen; - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } /* Generate or store a key */ @@ -1090,7 +1090,7 @@ static int setcos_generate_store_key(sc_card_t *card, r = sc_check_sw(card, apdu.sw1, apdu.sw2); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "STORE/GENERATE_KEY returned error"); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } static int setcos_activate_file(sc_card_t *card) @@ -1108,7 +1108,7 @@ static int setcos_activate_file(sc_card_t *card) r = sc_check_sw(card, apdu.sw1, apdu.sw2); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "ACTIVATE_FILE returned error"); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } static int setcos_card_ctl(sc_card_t *card, unsigned long cmd, void *ptr) diff --git a/src/libopensc/card-starcos.c b/src/libopensc/card-starcos.c index d7b86516..1e34ef67 100644 --- a/src/libopensc/card-starcos.c +++ b/src/libopensc/card-starcos.c @@ -476,7 +476,7 @@ static int starcos_select_aid(sc_card_t *card, if (file_out) { sc_file_t *file = sc_file_new(); if (!file) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); file->type = SC_FILE_TYPE_DF; file->ef_structure = SC_FILE_EF_UNKNOWN; file->path.len = 0; @@ -594,7 +594,7 @@ static int starcos_select_fid(sc_card_t *card, if (file_out) { sc_file_t *file = sc_file_new(); if (!file) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); file->id = (id_hi << 8) + id_lo; file->path = card->cache.current_path; @@ -763,7 +763,7 @@ static int starcos_select_file(sc_card_t *card, if (file_out) { sc_file_t *file = sc_file_new(); if (!file) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); file->id = (path[pathlen-2] << 8) + path[pathlen-1]; file->path = card->cache.current_path; diff --git a/src/libopensc/card-tcos.c b/src/libopensc/card-tcos.c index 8ab1e679..d9db4aed 100644 --- a/src/libopensc/card-tcos.c +++ b/src/libopensc/card-tcos.c @@ -402,7 +402,7 @@ static int tcos_select_file(sc_card_t *card, } file = sc_file_new(); - if (file == NULL) SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + if (file == NULL) LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY); *file_out = file; file->path = *in_path; @@ -458,7 +458,7 @@ static int tcos_delete_file(sc_card_t *card, const sc_path_t *path) SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); if (path->type != SC_PATH_TYPE_FILE_ID && path->len != 2) { sc_log(card->ctx, "File type has to be SC_PATH_TYPE_FILE_ID\n"); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); } sbuf[0] = path->value[0]; sbuf[1] = path->value[1]; @@ -488,7 +488,7 @@ static int tcos_set_security_env(sc_card_t *card, const sc_security_env_t *env, data=(tcos_data *)card->drv_data; if (se_num || (env->operation!=SC_SEC_OPERATION_DECIPHER && env->operation!=SC_SEC_OPERATION_SIGN)){ - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS); + LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS); } if(!(env->flags & SC_SEC_ENV_KEY_REF_PRESENT)) sc_log(ctx, diff --git a/src/libopensc/card.c b/src/libopensc/card.c index 5c3bacdc..ad04774d 100644 --- a/src/libopensc/card.c +++ b/src/libopensc/card.c @@ -834,13 +834,13 @@ int sc_get_challenge(sc_card_t *card, u8 *rnd, size_t len) r = sc_lock(card); if (r != SC_SUCCESS) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); while (len > 0 && retry > 0) { r = card->ops->get_challenge(card, rnd, len); if (r < 0) { sc_unlock(card); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } if (r > 0) { diff --git a/src/libopensc/iso7816.c b/src/libopensc/iso7816.c index f3bae483..f69f480e 100644 --- a/src/libopensc/iso7816.c +++ b/src/libopensc/iso7816.c @@ -784,7 +784,7 @@ iso7816_delete_file(struct sc_card *card, const sc_path_t *path) SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); if (path->type != SC_PATH_TYPE_FILE_ID || (path->len != 0 && path->len != 2)) { sc_log(card->ctx, "File type has to be SC_PATH_TYPE_FILE_ID"); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); } if (path->len == 2) { @@ -1217,7 +1217,7 @@ static int iso7816_get_data(struct sc_card *card, unsigned int tag, u8 *buf, si else r = apdu.resplen; - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } diff --git a/src/libopensc/muscle.c b/src/libopensc/muscle.c index 1252f6e9..2715a4be 100644 --- a/src/libopensc/muscle.c +++ b/src/libopensc/muscle.c @@ -302,11 +302,11 @@ int msc_verify_pin(sc_card_t *card, int pinNumber, const u8 *pinValue, int pinLe } else if(apdu.sw1 == 0x63) { /* Invalid auth */ if(tries) *tries = apdu.sw2 & 0x0F; - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_PIN_CODE_INCORRECT); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_PIN_CODE_INCORRECT); } else if(apdu.sw1 == 0x9C && apdu.sw2 == 0x02) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_PIN_CODE_INCORRECT); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_PIN_CODE_INCORRECT); } else if(apdu.sw1 == 0x69 && apdu.sw2 == 0x83) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_AUTH_METHOD_BLOCKED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_AUTH_METHOD_BLOCKED); } SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_PIN_CODE_INCORRECT); @@ -347,11 +347,11 @@ int msc_unblock_pin(sc_card_t *card, int pinNumber, const u8 *pukValue, int pukL } else if(apdu.sw1 == 0x63) { /* Invalid auth */ if(tries) *tries = apdu.sw2 & 0x0F; - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_PIN_CODE_INCORRECT); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_PIN_CODE_INCORRECT); } else if(apdu.sw1 == 0x9C && apdu.sw2 == 0x02) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_PIN_CODE_INCORRECT); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_PIN_CODE_INCORRECT); } else if(apdu.sw1 == 0x69 && apdu.sw2 == 0x83) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_AUTH_METHOD_BLOCKED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_AUTH_METHOD_BLOCKED); } SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_PIN_CODE_INCORRECT); @@ -389,11 +389,11 @@ int msc_change_pin(sc_card_t *card, int pinNumber, const u8 *pinValue, int pinLe } else if(apdu.sw1 == 0x63) { /* Invalid auth */ if(tries) *tries = apdu.sw2 & 0x0F; - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_PIN_CODE_INCORRECT); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_PIN_CODE_INCORRECT); } else if(apdu.sw1 == 0x9C && apdu.sw2 == 0x02) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_PIN_CODE_INCORRECT); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_PIN_CODE_INCORRECT); } else if(apdu.sw1 == 0x69 && apdu.sw2 == 0x83) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_AUTH_METHOD_BLOCKED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_AUTH_METHOD_BLOCKED); } SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_PIN_CODE_INCORRECT); @@ -441,7 +441,7 @@ int msc_get_challenge(sc_card_t *card, unsigned short dataLength, unsigned short assert(dataLength < MSC_MAX_READ - 9); /* Output buffer doesn't seem to operate as desired.... nobody can read/delete */ buffer = malloc(len); - if(!buffer) SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + if(!buffer) LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); ptr = buffer; ushort2bebytes(ptr, dataLength); ptr+=2; @@ -457,7 +457,7 @@ int msc_get_challenge(sc_card_t *card, unsigned short dataLength, unsigned short if(location == 1) { u8* outputBuffer = malloc(dataLength + 2); - if(outputBuffer == NULL) SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + if(outputBuffer == NULL) LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); apdu.le = dataLength + 2; apdu.resp = outputBuffer; apdu.resplen = dataLength + 2; @@ -479,9 +479,9 @@ int msc_get_challenge(sc_card_t *card, unsigned short dataLength, unsigned short sc_log(card->ctx, "got strange SWs: 0x%02X 0x%02X\n", apdu.sw1, apdu.sw2); } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_CARD_CMD_FAILED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_CARD_CMD_FAILED); } } else { if(apdu.sw1 != 0x90 || apdu.sw2 != 0x00) { @@ -491,15 +491,15 @@ int msc_get_challenge(sc_card_t *card, unsigned short dataLength, unsigned short sc_log(card->ctx, "got strange SWs: 0x%02X 0x%02X\n", apdu.sw1, apdu.sw2); } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_CARD_CMD_FAILED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_CARD_CMD_FAILED); } r = msc_read_object(card, inputId, 2, outputData, dataLength); if(r < 0) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); msc_delete_object(card, inputId,0); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } } @@ -552,9 +552,9 @@ int msc_generate_keypair(sc_card_t *card, int privateKey, int publicKey, int alg sc_log(card->ctx, "got strange SWs: 0x%02X 0x%02X\n", apdu.sw1, apdu.sw2); } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_CARD_CMD_FAILED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_CARD_CMD_FAILED); } int msc_extract_key(sc_card_t *card, @@ -579,9 +579,9 @@ int msc_extract_key(sc_card_t *card, sc_log(card->ctx, "got strange SWs: 0x%02X 0x%02X\n", apdu.sw1, apdu.sw2); } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_CARD_CMD_FAILED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_CARD_CMD_FAILED); } int msc_extract_rsa_public_key(sc_card_t *card, @@ -596,25 +596,25 @@ int msc_extract_rsa_public_key(sc_card_t *card, int fileLocation = 1; r = msc_extract_key(card, keyLocation); - if(r < 0) SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + if(r < 0) LOG_FUNC_RETURN(card->ctx, r); /* Read keyType, keySize, and what should be the modulus size */ r = msc_read_object(card, inputId, fileLocation, buffer, 5); fileLocation += 5; - if(r < 0) SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + if(r < 0) LOG_FUNC_RETURN(card->ctx, r); - if(buffer[0] != MSC_RSA_PUBLIC) SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_UNKNOWN_DATA_RECEIVED); + if(buffer[0] != MSC_RSA_PUBLIC) LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED); *modLength = (buffer[3] << 8) | buffer[4]; /* Read the modulus and the exponent length */ if (*modLength + 2 > sizeof buffer) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); r = msc_read_object(card, inputId, fileLocation, buffer, *modLength + 2); fileLocation += *modLength + 2; - if(r < 0) SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + if(r < 0) LOG_FUNC_RETURN(card->ctx, r); *modulus = malloc(*modLength); - if(!*modulus) SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + if(!*modulus) LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); memcpy(*modulus, buffer, *modLength); *expLength = (buffer[*modLength] << 8) | buffer[*modLength + 1]; if (*expLength > sizeof buffer) @@ -622,12 +622,12 @@ int msc_extract_rsa_public_key(sc_card_t *card, r = msc_read_object(card, inputId, fileLocation, buffer, *expLength); if(r < 0) { free(*modulus); *modulus = NULL; - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } *exponent = malloc(*expLength); if(!*exponent) { free(*modulus); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); } memcpy(*exponent, buffer, *expLength); return 0; @@ -685,9 +685,9 @@ int msc_compute_crypt_init(sc_card_t *card, sc_log(card->ctx, "init: got strange SWs: 0x%02X 0x%02X\n", apdu.sw1, apdu.sw2); } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_CARD_CMD_FAILED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_CARD_CMD_FAILED); } int msc_compute_crypt_final( @@ -735,9 +735,9 @@ int msc_compute_crypt_final( sc_log(card->ctx, "final: got strange SWs: 0x%02X 0x%02X\n", apdu.sw1, apdu.sw2); } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_CARD_CMD_FAILED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_CARD_CMD_FAILED); } /* Stream data to the card through file IO */ @@ -808,7 +808,7 @@ static int msc_compute_crypt_final_object( /* this is last ditch cleanup */ msc_delete_object(card, outputId, 0); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } int msc_compute_crypt(sc_card_t *card, @@ -839,7 +839,7 @@ int msc_compute_crypt(sc_card_t *card, outPtr, toSend, &received); - if(r < 0) SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + if(r < 0) LOG_FUNC_RETURN(card->ctx, r); left -= toSend; inPtr += toSend; outPtr += received; @@ -854,7 +854,7 @@ int msc_compute_crypt(sc_card_t *card, outPtr, toSend, &received); - if(r < 0) SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + if(r < 0) LOG_FUNC_RETURN(card->ctx, r); } else { /* Data is too big: use objects */ r = msc_compute_crypt_final_object(card, keyLocation, @@ -862,7 +862,7 @@ int msc_compute_crypt(sc_card_t *card, outPtr, toSend, &received); - if(r < 0) SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + if(r < 0) LOG_FUNC_RETURN(card->ctx, r); } outPtr += received; @@ -912,7 +912,7 @@ int msc_import_key(sc_card_t *card, + data->dp1Length + data->dq1Length; } buffer = malloc(bufferSize); - if(!buffer) SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + if(!buffer) LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); p = buffer; *p = 0x00; p++; /* Encoding plain */ *p = data->keyType; p++; /* RSA_PRIVATE */ @@ -972,11 +972,11 @@ int msc_import_key(sc_card_t *card, } /* this is last ditch cleanup */ msc_delete_object(card, outputId, 0); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } /* this is last ditch cleanup */ msc_delete_object(card, outputId, 0); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_CARD_CMD_FAILED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_CARD_CMD_FAILED); } #undef CPYVAL diff --git a/src/libopensc/p15card-helper.c b/src/libopensc/p15card-helper.c index 70e47924..e641858d 100644 --- a/src/libopensc/p15card-helper.c +++ b/src/libopensc/p15card-helper.c @@ -61,7 +61,7 @@ int sc_pkcs15emu_initialize_objects(sc_pkcs15_card_t *p15card, p15data_items *it r = sc_pkcs15emu_object_add(p15card, SC_PKCS15_TYPE_DATA_OBJECT, &obj_obj, &obj_info); if (r < 0) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } return SC_SUCCESS; } @@ -212,7 +212,7 @@ err: X509_free(cert_data); cert_data = NULL; } - SC_FUNC_RETURN(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(p15card->card->ctx, r); } int sc_pkcs15emu_initialize_certificates(sc_pkcs15_card_t *p15card, p15data_items* items) { @@ -307,7 +307,7 @@ int sc_pkcs15emu_initialize_pins(sc_pkcs15_card_t *p15card, p15data_items* items pin_obj.flags = pins[i].obj_flags; if(0 > (r = sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info))) - SC_FUNC_RETURN(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(p15card->card->ctx, r); } return SC_SUCCESS; } @@ -320,7 +320,7 @@ int sc_pkcs15emu_initialize_private_keys(sc_pkcs15_card_t *p15card, p15data_item for (i = 0; prkeys[i].label; i++) { r = add_private_key(p15card, &prkeys[i], 0, 0); if (r < 0) - SC_FUNC_RETURN(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(p15card->card->ctx, r); } return SC_SUCCESS; } @@ -333,7 +333,7 @@ int sc_pkcs15emu_initialize_public_keys(sc_pkcs15_card_t *p15card, p15data_items for (i = 0; keys[i].label; i++) { r = add_public_key(p15card, &keys[i], 0, 0); if (r < 0) - SC_FUNC_RETURN(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(p15card->card->ctx, r); } return SC_SUCCESS; diff --git a/src/libopensc/pkcs15-cac.c b/src/libopensc/pkcs15-cac.c index 4010e05b..5f4a8994 100644 --- a/src/libopensc/pkcs15-cac.c +++ b/src/libopensc/pkcs15-cac.c @@ -256,12 +256,12 @@ static int sc_pkcs15emu_cac_init(sc_pkcs15_card_t *p15card) /* get the ACA path in case it needs to be selected before PIN verify */ r = sc_card_ctl(card, SC_CARDCTL_CAC_GET_ACA_PATH, &pin_info.path); if (r < 0) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } r = sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info); if (r < 0) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } /* set other objects */ @@ -274,14 +274,14 @@ static int sc_pkcs15emu_cac_init(sc_pkcs15_card_t *p15card) r = (card->ops->card_ctl)(card, SC_CARDCTL_CAC_GET_NEXT_GENERIC_OBJECT, &obj_info); if (r < 0) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); memset(&obj_obj, 0, sizeof(obj_obj)); memcpy(obj_obj.label, obj_info.app_label, sizeof(obj_obj.label)); r = sc_pkcs15emu_object_add(p15card, SC_PKCS15_TYPE_DATA_OBJECT, &obj_obj, &obj_info); if (r < 0) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } r = (card->ops->card_ctl)(card, SC_CARDCTL_CAC_FINAL_GET_GENERIC_OBJECTS, &count); LOG_TEST_RET(card->ctx, r, "Can not finalize generic objects."); @@ -433,13 +433,13 @@ static int sc_pkcs15emu_cac_init(sc_pkcs15_card_t *p15card) fail: sc_pkcs15_free_certificate(cert_out); if (r < 0) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); /* should not fail */ + LOG_FUNC_RETURN(card->ctx, r); /* should not fail */ } r = (card->ops->card_ctl)(card, SC_CARDCTL_CAC_FINAL_GET_CERT_OBJECTS, &count); LOG_TEST_RET(card->ctx, r, "Can not finalize cert objects."); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(card->ctx, SC_SUCCESS); } int sc_pkcs15emu_cac_init_ex(sc_pkcs15_card_t *p15card, diff --git a/src/libopensc/pkcs15-coolkey.c b/src/libopensc/pkcs15-coolkey.c index 58826ed8..f0ec8f48 100644 --- a/src/libopensc/pkcs15-coolkey.c +++ b/src/libopensc/pkcs15-coolkey.c @@ -534,7 +534,7 @@ static int sc_pkcs15emu_coolkey_init(sc_pkcs15_card_t *p15card) r = sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info); if (r < 0) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } /* set other objects */ @@ -556,7 +556,7 @@ static int sc_pkcs15emu_coolkey_init(sc_pkcs15_card_t *p15card) r = (card->ops->card_ctl)(card, SC_CARDCTL_COOLKEY_GET_NEXT_OBJECT, &coolkey_obj); if (r < 0) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); memset(&obj_obj, 0, sizeof(obj_obj)); diff --git a/src/libopensc/pkcs15-data.c b/src/libopensc/pkcs15-data.c index d1d389d4..47573bb5 100644 --- a/src/libopensc/pkcs15-data.c +++ b/src/libopensc/pkcs15-data.c @@ -133,7 +133,7 @@ int sc_pkcs15_decode_dodf_entry(struct sc_pkcs15_card *p15card, obj->type = SC_PKCS15_TYPE_DATA_OBJECT; obj->data = malloc(sizeof(info)); if (obj->data == NULL) - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY); memcpy(obj->data, &info, sizeof(info)); return SC_SUCCESS; diff --git a/src/libopensc/pkcs15-oberthur.c b/src/libopensc/pkcs15-oberthur.c index 8c126e46..d744d807 100644 --- a/src/libopensc/pkcs15-oberthur.c +++ b/src/libopensc/pkcs15-oberthur.c @@ -688,7 +688,7 @@ sc_pkcs15emu_oberthur_add_cert(struct sc_pkcs15_card *p15card, unsigned int file rv = sc_pkcs15emu_add_x509_cert(p15card, &cobj, &cinfo); - SC_FUNC_RETURN(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(p15card->card->ctx, rv); } @@ -903,7 +903,7 @@ sc_pkcs15emu_oberthur_add_data(struct sc_pkcs15_card *p15card, rv = sc_pkcs15emu_add_data_object(p15card, &dobj, &dinfo); - SC_FUNC_RETURN(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(p15card->card->ctx, rv); } @@ -1043,8 +1043,8 @@ oberthur_detect_card(struct sc_pkcs15_card * p15card) SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); if (p15card->card->type != SC_CARD_TYPE_OBERTHUR_64K) - SC_FUNC_RETURN(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_WRONG_CARD); - SC_FUNC_RETURN(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(p15card->card->ctx, SC_ERROR_WRONG_CARD); + LOG_FUNC_RETURN(p15card->card->ctx, SC_SUCCESS); } diff --git a/src/libopensc/pkcs15-pin.c b/src/libopensc/pkcs15-pin.c index 459230b5..5237e006 100644 --- a/src/libopensc/pkcs15-pin.c +++ b/src/libopensc/pkcs15-pin.c @@ -199,7 +199,7 @@ sc_pkcs15_decode_aodf_entry(struct sc_pkcs15_card *p15card, struct sc_pkcs15_obj obj->data = malloc(sizeof(info)); if (obj->data == NULL) - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY); memcpy(obj->data, &info, sizeof(info)); SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_ASN1, SC_SUCCESS); diff --git a/src/libopensc/pkcs15-piv.c b/src/libopensc/pkcs15-piv.c index efd4407d..858f914f 100644 --- a/src/libopensc/pkcs15-piv.c +++ b/src/libopensc/pkcs15-piv.c @@ -676,7 +676,7 @@ static int sc_pkcs15emu_piv_init(sc_pkcs15_card_t *p15card) r = sc_pkcs15emu_object_add(p15card, SC_PKCS15_TYPE_DATA_OBJECT, &obj_obj, &obj_info); if (r < 0) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); /* TODO * PIV key 9C requires the pin verify be done just before any * crypto operation using the key. @@ -969,7 +969,7 @@ sc_log(card->ctx, "DEE Adding pin %d label=%s",i, label); r = sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info); if (r < 0) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } @@ -1095,7 +1095,7 @@ sc_log(card->ctx, "DEE Adding pin %d label=%s",i, label); r = sc_pkcs15emu_add_rsa_pubkey(p15card, &pubkey_obj, &pubkey_info); if (r < 0) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); /* should not fail */ + LOG_FUNC_RETURN(card->ctx, r); /* should not fail */ ckis[i].pubkey_found = 1; break; @@ -1111,7 +1111,7 @@ sc_log(card->ctx, "DEE Adding pin %d label=%s",i, label); r = sc_pkcs15emu_add_ec_pubkey(p15card, &pubkey_obj, &pubkey_info); if (r < 0) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); /* should not fail */ + LOG_FUNC_RETURN(card->ctx, r); /* should not fail */ ckis[i].pubkey_found = 1; break; default: @@ -1196,12 +1196,12 @@ sc_log(card->ctx, "DEE Adding pin %d label=%s",i, label); } sc_log(card->ctx, "USAGE: cert_keyUsage_present:%d usage:0x%8.8x", ckis[i].cert_keyUsage_present ,prkey_info.usage); if (r < 0) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } p15card->ops.get_guid = piv_get_guid; - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(card->ctx, SC_SUCCESS); } int sc_pkcs15emu_piv_init_ex(sc_pkcs15_card_t *p15card, diff --git a/src/libopensc/reader-ctapi.c b/src/libopensc/reader-ctapi.c index 4b94337f..db08465b 100644 --- a/src/libopensc/reader-ctapi.c +++ b/src/libopensc/reader-ctapi.c @@ -258,7 +258,7 @@ static int ctapi_connect(sc_reader_t *reader) return SC_ERROR_TRANSMIT_FAILED; } if (lr < 2) - SC_FUNC_RETURN(reader->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL); + LOG_FUNC_RETURN(reader->ctx, SC_ERROR_INTERNAL); lr -= 2; if (lr > SC_MAX_ATR_SIZE) return SC_ERROR_INTERNAL; diff --git a/src/pkcs15init/pkcs15-gpk.c b/src/pkcs15init/pkcs15-gpk.c index 46bbccc9..54cd1d46 100644 --- a/src/pkcs15init/pkcs15-gpk.c +++ b/src/pkcs15init/pkcs15-gpk.c @@ -154,7 +154,7 @@ gpk_create_dir(sc_profile_t *profile, sc_pkcs15_card_t *p15card, sc_file_t *df) */ } - SC_FUNC_RETURN(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(p15card->card->ctx, r); } /* @@ -190,7 +190,7 @@ gpk_select_pin_reference(sc_profile_t *profile, sc_pkcs15_card_t *p15card, if (current > preferred) return SC_ERROR_TOO_MANY_OBJECTS; auth_info->attrs.pin.reference = preferred; - SC_FUNC_RETURN(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, 0); + LOG_FUNC_RETURN(p15card->card->ctx, 0); } /* @@ -263,7 +263,7 @@ gpk_create_pin(sc_profile_t *profile, sc_pkcs15_card_t *p15card, sc_file_t *df, if (r < 0) return r; - SC_FUNC_RETURN(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(p15card->card->ctx, r); } @@ -307,7 +307,7 @@ gpk_lock_pinfile(struct sc_profile *profile, sc_pkcs15_card_t *p15card, r = gpk_lock(p15card->card, pinfile, SC_AC_OP_WRITE); sc_file_free(parent); - SC_FUNC_RETURN(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(p15card->card->ctx, r); } /* @@ -386,7 +386,7 @@ gpk_init_pinfile(struct sc_profile *profile, sc_pkcs15_card_t *p15card, r = gpk_lock_pinfile(profile, p15card, pinfile); out: sc_file_free(pinfile); - SC_FUNC_RETURN(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(p15card->card->ctx, r); } /* diff --git a/src/pkcs15init/pkcs15-miocos.c b/src/pkcs15init/pkcs15-miocos.c index d6fe7304..d1ae67b0 100644 --- a/src/pkcs15init/pkcs15-miocos.c +++ b/src/pkcs15init/pkcs15-miocos.c @@ -187,7 +187,7 @@ miocos_create_pin(struct sc_profile *profile, sc_pkcs15_card_t *p15card, struct r = sc_card_ctl(p15card->card, SC_CARDCTL_MIOCOS_CREATE_AC, &ac_info); SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, r, "Miocos create AC failed"); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(ctx, SC_SUCCESS); } @@ -223,7 +223,7 @@ miocos_create_key(struct sc_profile *profile, struct sc_pkcs15_card *p15card, r = sc_pkcs15init_create_file(profile, p15card, file); sc_file_free(file); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(ctx, r); } @@ -261,7 +261,7 @@ miocos_store_key(struct sc_profile *profile, struct sc_pkcs15_card *p15card, r = miocos_update_private_key(profile, p15card->card, rsa); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(ctx, r); } static struct sc_pkcs15init_operations sc_pkcs15init_miocos_operations = { diff --git a/src/pkcs15init/pkcs15-oberthur-awp.c b/src/pkcs15init/pkcs15-oberthur-awp.c index a29010f5..fad869c6 100644 --- a/src/pkcs15init/pkcs15-oberthur-awp.c +++ b/src/pkcs15init/pkcs15-oberthur-awp.c @@ -190,7 +190,7 @@ awp_new_file(struct sc_pkcs15_card *p15card, struct sc_profile *profile, sc_file_free(ofile); } - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(ctx, SC_SUCCESS); } @@ -231,7 +231,7 @@ awp_update_blob(struct sc_context *ctx, *blob = pp; - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(ctx, SC_SUCCESS); } @@ -261,7 +261,7 @@ awp_new_container_entry(struct sc_pkcs15_card *p15card, unsigned char *buff, int } *(buff + 14 + ii*2 + mm) = (unsigned char)'}'; - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(ctx, rv); } @@ -279,7 +279,7 @@ awp_create_container_record (struct sc_pkcs15_card *p15card, struct sc_profile * buff = malloc(list_file->record_length); if (!buff) - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY); memset(buff, 0, list_file->record_length); @@ -287,7 +287,7 @@ awp_create_container_record (struct sc_pkcs15_card *p15card, struct sc_profile * if (rv < 0) { free(buff); sc_log(ctx, "Cannot create container"); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(ctx, rv); } *(buff + 0) = (acc->pubkey_id >> 8) & 0xFF; @@ -305,7 +305,7 @@ awp_create_container_record (struct sc_pkcs15_card *p15card, struct sc_profile * rv = sc_append_record(p15card->card, buff, list_file->record_length, SC_RECORD_BY_REC_NR); free(buff); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(ctx, rv); } @@ -336,7 +336,7 @@ awp_create_container(struct sc_pkcs15_card *p15card, struct sc_profile *profile, sc_file_free(file); sc_file_free(clist); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(ctx, rv); } @@ -358,7 +358,7 @@ awp_update_container_entry (struct sc_pkcs15_card *p15card, struct sc_profile *p buff = malloc(list_file->record_length); if (!buff) - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY); memset(buff, 0, list_file->record_length); @@ -372,7 +372,7 @@ awp_update_container_entry (struct sc_pkcs15_card *p15card, struct sc_profile *p } if (rv < 0) { free(buff); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(ctx, rv); } switch (type) { @@ -400,7 +400,7 @@ awp_update_container_entry (struct sc_pkcs15_card *p15card, struct sc_profile *p break; default: free(buff); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INCORRECT_PARAMETERS); + LOG_FUNC_RETURN(ctx, SC_ERROR_INCORRECT_PARAMETERS); } if (rec > list_file->record_count) { @@ -416,7 +416,7 @@ awp_update_container_entry (struct sc_pkcs15_card *p15card, struct sc_profile *p } free(buff); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(ctx, rv); } @@ -540,7 +540,7 @@ done: sc_file_free(file); if (list) free(list); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(ctx, rv); } @@ -624,7 +624,7 @@ done: if (blob) free(blob); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(ctx, r); } @@ -752,7 +752,7 @@ done: sc_file_free(obj_file); sc_file_free(file); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(ctx, rv); } @@ -825,7 +825,7 @@ awp_encode_key_info(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *obj done: ERR_load_ERR_strings(); ERR_load_crypto_strings(); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(ctx, r); } @@ -911,7 +911,7 @@ done: if (blob) free(blob); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(ctx, r); } @@ -1063,7 +1063,7 @@ done: if (mem) BIO_free(mem); if (buff) OPENSSL_free(buff); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(ctx, r); } @@ -1122,7 +1122,7 @@ awp_encode_data_info(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *ob if (di->app.len) { di->app.value = (unsigned char *)strdup(data_info->app_label); if (!di->app.value) - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY); } r = sc_asn1_encode_object_id(&buf, &buflen, &data_info->app_oid); @@ -1140,7 +1140,7 @@ awp_encode_data_info(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *ob memcpy(di->oid.value + 2, buf, buflen); free(buf); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(ctx, r); } @@ -1204,7 +1204,7 @@ done: if (blob) free(blob); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(ctx, r); } @@ -1254,7 +1254,7 @@ awp_parse_key_info(struct sc_context *ctx, unsigned char *buf, size_t buf_len, /* Flags */ if (buf_len - offs < 2) - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(ctx, SC_SUCCESS); ikey->flags = *(buf + offs) * 0x100 + *(buf + offs + 1); offs += 2; @@ -1262,14 +1262,14 @@ awp_parse_key_info(struct sc_context *ctx, unsigned char *buf, size_t buf_len, len = awp_get_lv(ctx, buf, buf_len, offs, 2, &ikey->label); SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, len, "AWP parse key info failed: label"); if (!len) - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(ctx, SC_SUCCESS); offs += len; /* Ignore Key ID */ len = awp_get_lv(ctx, buf, buf_len, offs, 2, &ikey->id); SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, len, "AWP parse key info failed: ID"); if (!len) - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(ctx, SC_SUCCESS); offs += len; while (*(buf + offs) == '0') @@ -1279,7 +1279,7 @@ awp_parse_key_info(struct sc_context *ctx, unsigned char *buf, size_t buf_len, len = awp_get_lv(ctx, buf, buf_len, offs, 2, &ikey->subject); SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, len, "AWP parse key info failed: subject"); if (!len) - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(ctx, SC_SUCCESS); offs += len; /* Modulus */ @@ -1291,16 +1291,16 @@ awp_parse_key_info(struct sc_context *ctx, unsigned char *buf, size_t buf_len, len = awp_get_lv(ctx, buf, buf_len, offs, 256, &ikey->modulus); SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, len, "AWP parse key info failed: modulus"); if (!len) - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(ctx, SC_SUCCESS); offs += len; /* Exponent */ len = awp_get_lv(ctx, buf, buf_len, offs, 1, &ikey->exponent); SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, len, "AWP parse key info failed: exponent"); if (!len) - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(ctx, SC_SUCCESS); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(ctx, SC_SUCCESS); } @@ -1359,7 +1359,7 @@ done: sc_file_free(key_file); sc_file_free(info_file); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(ctx, rv); } @@ -1411,7 +1411,7 @@ err: sc_file_free(info_file); sc_file_free(obj_file); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(ctx, rv); } @@ -1499,7 +1499,7 @@ err: awp_free_cert_info(&icert); awp_free_key_info(&ikey); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(ctx, rv); } @@ -1549,7 +1549,7 @@ awp_update_df_create_pubkey(struct sc_pkcs15_card *p15card, struct sc_profile *p err: awp_free_key_info(&ikey); sc_file_free(info_file); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(ctx, rv); } @@ -1591,7 +1591,7 @@ awp_update_df_create_data(struct sc_pkcs15_card *p15card, struct sc_profile *pro sc_file_free(info_file); sc_file_free(obj_file); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(ctx, rv); } @@ -1604,7 +1604,7 @@ awp_update_df_create(struct sc_pkcs15_card *p15card, struct sc_profile *profile, LOG_FUNC_CALLED(ctx); if (!object) - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(ctx, SC_SUCCESS); switch (object->type) { case SC_PKCS15_TYPE_AUTH_PIN: @@ -1626,7 +1626,7 @@ awp_update_df_create(struct sc_pkcs15_card *p15card, struct sc_profile *profile, SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS, "'Create' update DF failed: unsupported object type"); } - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(ctx, rv); } @@ -1707,7 +1707,7 @@ awp_delete_from_container(struct sc_pkcs15_card *p15card, sc_file_free(clist); sc_file_free(file); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(ctx, rv); } @@ -1782,7 +1782,7 @@ done: sc_file_free(lst); sc_file_free(lst_file); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(ctx, rv); } @@ -1816,7 +1816,7 @@ awp_update_df_delete_cert(struct sc_pkcs15_card *p15card, struct sc_profile *pro rv = awp_remove_from_object_list(p15card, profile, obj->type, file_id); SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP 'delete cert' update DF failed: cannot remove object"); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(ctx, rv); } @@ -1850,7 +1850,7 @@ awp_update_df_delete_prvkey(struct sc_pkcs15_card *p15card, struct sc_profile *p rv = awp_remove_from_object_list(p15card, profile, obj->type, file_id); SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP 'delete prkey' update DF failed: cannot remove object"); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(ctx, rv); } @@ -1884,7 +1884,7 @@ awp_update_df_delete_pubkey(struct sc_pkcs15_card *p15card, struct sc_profile *p rv = awp_remove_from_object_list(p15card, profile, obj->type, file_id); SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP 'delete pubkey' update DF failed: cannot remove object"); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(ctx, rv); } @@ -1915,7 +1915,7 @@ awp_update_df_delete_data(struct sc_pkcs15_card *p15card, struct sc_profile *pro rv = awp_remove_from_object_list(p15card, profile, obj->type, file_id); SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP 'delete DATA' update DF failed: cannot remove object"); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(ctx, rv); } @@ -1928,7 +1928,7 @@ awp_update_df_delete(struct sc_pkcs15_card *p15card, struct sc_profile *profile, LOG_FUNC_CALLED(ctx); if (!object) - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(ctx, SC_SUCCESS); switch (object->type) { case SC_PKCS15_TYPE_CERT_X509: diff --git a/src/pkcs15init/pkcs15-oberthur.c b/src/pkcs15init/pkcs15-oberthur.c index aaaf25e5..6b690867 100644 --- a/src/pkcs15init/pkcs15-oberthur.c +++ b/src/pkcs15init/pkcs15-oberthur.c @@ -113,7 +113,7 @@ cosm_write_tokeninfo (struct sc_pkcs15_card *p15card, struct sc_profile *profile err: sc_file_free(file); free(buffer); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(ctx, rv); } @@ -152,7 +152,7 @@ cosm_delete_file(struct sc_pkcs15_card *p15card, struct sc_profile *profile, rv = sc_delete_file(p15card->card, &path); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(ctx, rv); } @@ -214,7 +214,7 @@ done: if (rv == SC_ERROR_FILE_NOT_FOUND) rv = 0; - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(ctx, rv); } @@ -257,7 +257,7 @@ cosm_create_dir(struct sc_profile *profile, struct sc_pkcs15_card *p15card, rv = cosm_write_tokeninfo(p15card, profile, NULL, COSM_TOKEN_FLAG_TOKEN_INITIALIZED | COSM_TOKEN_FLAG_PRN_GENERATION); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(ctx, rv); } @@ -328,7 +328,7 @@ cosm_create_reference_data(struct sc_profile *profile, struct sc_pkcs15_card *p1 sc_file_free(file); } - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(ctx, rv); } @@ -367,7 +367,7 @@ cosm_update_pin(struct sc_profile *profile, struct sc_pkcs15_card *p15card, SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "cosm_update_pin() failed to update tokeninfo"); } - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(ctx, rv); } @@ -408,7 +408,7 @@ cosm_select_pin_reference(struct sc_profile *profile, struct sc_pkcs15_card *p15 pin_attrs->reference |= 0x80; } - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(ctx, SC_SUCCESS); } @@ -467,7 +467,7 @@ cosm_create_pin(struct sc_profile *profile, struct sc_pkcs15_card *p15card, SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "Update PIN failed"); } - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(ctx, rv); } @@ -529,7 +529,7 @@ cosm_new_file(struct sc_profile *profile, struct sc_card *card, if (sc_profile_get_file(profile, _template, &file) < 0) { sc_log(card->ctx, "Profile doesn't define %s template '%s'", desc, _template); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED); } file->id |= (num & 0xFF); @@ -543,7 +543,7 @@ cosm_new_file(struct sc_profile *profile, struct sc_card *card, file->size, file->type, file->ef_structure, file->id); *out = file; - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(card->ctx, SC_SUCCESS); } @@ -558,11 +558,11 @@ cosm_get_temporary_public_key_file(struct sc_card *card, SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); if (!pubkey_file || !prvkey_file) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); file = sc_file_new(); if (!file) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); file->status = SC_FILE_STATUS_ACTIVATED; file->type = SC_FILE_TYPE_INTERNAL_EF; @@ -587,7 +587,7 @@ cosm_get_temporary_public_key_file(struct sc_card *card, *pubkey_file = file; - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(card->ctx, rv); } @@ -669,7 +669,7 @@ cosm_generate_key(struct sc_profile *profile, struct sc_pkcs15_card *p15card, sc_file_free(tmpf); sc_file_free(prkf); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(ctx, rv); } @@ -719,7 +719,7 @@ cosm_create_key(struct sc_profile *profile, struct sc_pkcs15_card *p15card, err: sc_file_free(file); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(ctx, rv); } @@ -751,7 +751,7 @@ cosm_store_key(struct sc_profile *profile, struct sc_pkcs15_card *p15card, SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "No authorisation to store private key"); if (key_info->id.len > sizeof(update_info.id)) - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS); + LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS); memset(&update_info, 0, sizeof(update_info)); update_info.type = SC_CARDCTL_OBERTHUR_KEY_RSA_CRT; @@ -765,7 +765,7 @@ cosm_store_key(struct sc_profile *profile, struct sc_pkcs15_card *p15card, sc_file_free(file); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv); + LOG_FUNC_RETURN(ctx, rv); } diff --git a/src/pkcs15init/pkcs15-rtecp.c b/src/pkcs15init/pkcs15-rtecp.c index bbf9f916..de97f793 100644 --- a/src/pkcs15init/pkcs15-rtecp.c +++ b/src/pkcs15init/pkcs15-rtecp.c @@ -153,7 +153,7 @@ static int rtecp_select_pin_reference(sc_profile_t *profile, sc_pkcs15_card_t *p else pin_ref = RTECP_USER_PIN_REF; if (auth_info->attrs.pin.reference != pin_ref) - SC_FUNC_RETURN(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED); + LOG_FUNC_RETURN(p15card->card->ctx, SC_ERROR_NOT_SUPPORTED); return SC_SUCCESS; } @@ -225,7 +225,7 @@ static int rtecp_create_pin(sc_profile_t *profile, sc_pkcs15_card_t *p15card, file = sc_file_new(); if (!file) - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY); file->id = auth_info->attrs.pin.reference; file->size = pin_len; assert(sizeof(sec)/sizeof(sec[0]) > 2); @@ -248,7 +248,7 @@ static int rtecp_create_pin(sc_profile_t *profile, sc_pkcs15_card_t *p15card, if (r == SC_SUCCESS) r = sc_change_reference_data(p15card->card, SC_AC_CHV, auth_info->attrs.pin.reference, NULL, 0, pin, pin_len, NULL); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(ctx, r); } /* @@ -350,7 +350,7 @@ static int rtecp_create_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card, file = sc_file_new(); if (!file) - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY); file->id = key_info->key_reference; r = sc_file_set_type_attr(file, (const u8*)"\x10\x00", 2); @@ -402,7 +402,7 @@ static int rtecp_create_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card, r = sc_create_file(p15card->card, file); } sc_file_free(file); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(ctx, r); } /* @@ -462,7 +462,7 @@ static int rtecp_store_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card, return SC_ERROR_INVALID_ARGUMENTS; buf = calloc(1, buf_len); if (!buf) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY); assert(key_len <= buf_len); if (key->algorithm == SC_ALGORITHM_RSA) { @@ -536,7 +536,7 @@ static int rtecp_store_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card, end: assert(buf); free(buf); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } /* @@ -583,7 +583,7 @@ static int rtecp_generate_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card, { free(data.u.rsa.modulus); free(data.u.rsa.exponent); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY); } break; case SC_ALGORITHM_GOSTR3410: @@ -593,7 +593,7 @@ static int rtecp_generate_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card, if (!data.u.gostr3410.xy) { free(data.u.gostr3410.xy); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); + LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY); } break; default: @@ -618,7 +618,7 @@ static int rtecp_generate_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card, break; } } - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(ctx, r); } /* diff --git a/src/pkcs15init/pkcs15-setcos.c b/src/pkcs15init/pkcs15-setcos.c index 768f66c5..8770ed94 100644 --- a/src/pkcs15init/pkcs15-setcos.c +++ b/src/pkcs15init/pkcs15-setcos.c @@ -138,7 +138,7 @@ setcos_init_card(sc_profile_t *profile, sc_pkcs15_card_t *p15card) sc_file_free(pinfile); SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, r, "Select pinfile failed"); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(ctx, r); } /* @@ -158,7 +158,7 @@ setcos_create_dir(sc_profile_t *profile, sc_pkcs15_card_t *p15card, sc_file_t *d r = sc_create_file(p15card->card, df); SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, r, "SetCOS create file failed"); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(ctx, r); } @@ -242,7 +242,7 @@ setcos_create_pin(sc_profile_t *profile, sc_pkcs15_card_t *p15card, sc_file_free(pinfile); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(ctx, r); } /* @@ -367,7 +367,7 @@ setcos_create_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card, SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, r, "Cannot create private key file"); sc_file_free(file); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(ctx, r); } @@ -419,7 +419,7 @@ setcos_store_key(struct sc_profile *profile, struct sc_pkcs15_card *p15card, sc_file_free(file); - SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(ctx, r); } diff --git a/src/sm/sm-eac.c b/src/sm/sm-eac.c index c937439b..ee7b6f8a 100644 --- a/src/sm/sm-eac.c +++ b/src/sm/sm-eac.c @@ -1381,7 +1381,7 @@ err: if (r < 0) EAC_CTX_clear_free(eac_ctx); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } static int eac_mse_set_at_ta(sc_card_t *card, int protocol, @@ -1658,7 +1658,7 @@ err: BUF_MEM_clear_free(signature); if (card) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); else return r; } @@ -1806,7 +1806,7 @@ err: BUF_MEM_clear_free(picc_pubkey); if (card) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); else return r; } @@ -1891,7 +1891,7 @@ err: BUF_MEM_clear_free(eph_pub_key); if (card) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); else return r; } @@ -2310,14 +2310,14 @@ err: if (msesetat) EAC_MSE_C_free(msesetat); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); + LOG_FUNC_RETURN(card->ctx, r); } static int eac_sm_post_transmit(sc_card_t *card, const struct iso_sm_ctx *ctx, sc_apdu_t *sm_apdu) { - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, + LOG_FUNC_RETURN(card->ctx, increment_ssc(ctx->priv_data)); } @@ -2329,7 +2329,7 @@ eac_sm_finish(sc_card_t *card, const struct iso_sm_ctx *ctx, if (!card) return SC_ERROR_INVALID_ARGUMENTS; if(!ctx || !ctx->priv_data || !apdu) - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); eacsmctx = ctx->priv_data; @@ -2351,13 +2351,13 @@ eac_sm_finish(sc_card_t *card, const struct iso_sm_ctx *ctx, if (!r) { ssl_error(card->ctx); - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL); + LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL); } } } } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); + LOG_FUNC_RETURN(card->ctx, SC_SUCCESS); } static void