From d21830344f55976f5b00a04727d81c2491a64747 Mon Sep 17 00:00:00 2001 From: Frank Morgner Date: Sat, 25 May 2013 04:22:28 +0200 Subject: [PATCH] fixed a ton of compiler warnings --- src/libopensc/card-belpic.c | 2 -- src/libopensc/card-cardos.c | 12 +++++++----- src/libopensc/card-epass2003.c | 4 +--- src/libopensc/card-jcop.c | 4 +--- src/libopensc/card-miocos.c | 4 +--- src/libopensc/card-myeid.c | 2 +- src/libopensc/card-openpgp.c | 9 ++------- src/libopensc/card-sc-hsm.c | 6 +----- src/libopensc/pkcs15-sc-hsm.c | 29 +++++++++++++--------------- src/pkcs15init/pkcs15-iasecc.c | 16 ++++------------ src/pkcs15init/pkcs15-lib.c | 7 +++---- src/pkcs15init/pkcs15-sc-hsm.c | 26 ++----------------------- src/smm/sm-card-authentic.c | 2 +- src/smm/sm-global-platform.c | 2 +- src/tools/openpgp-tool.c | 35 +--------------------------------- src/tools/sc-hsm-tool.c | 6 +++--- 16 files changed, 42 insertions(+), 124 deletions(-) diff --git a/src/libopensc/card-belpic.c b/src/libopensc/card-belpic.c index 3f7cf44f0d..27a4947c8c 100644 --- a/src/libopensc/card-belpic.c +++ b/src/libopensc/card-belpic.c @@ -981,14 +981,12 @@ static int belpic_init(sc_card_t *card) static int belpic_select_file(sc_card_t *card, const sc_path_t *in_path, sc_file_t **file_out) { - sc_context_t *ctx; sc_apdu_t apdu; u8 pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf; int r, pathlen; sc_file_t *file = NULL; assert(card != NULL && in_path != NULL); - ctx = card->ctx; memcpy(path, in_path->value, in_path->len); pathlen = in_path->len; diff --git a/src/libopensc/card-cardos.c b/src/libopensc/card-cardos.c index 55ea890a8a..303bdfdc81 100644 --- a/src/libopensc/card-cardos.c +++ b/src/libopensc/card-cardos.c @@ -864,7 +864,7 @@ cardos_compute_signature(sc_card_t *card, const u8 *data, size_t datalen, * and www.crysys.hu/infsec/M40_Manual_E_2001_10.pdf) */ - if (card->caps & SC_CARD_CAP_ONLY_RAW_HASH_STRIPPED){ + if (card->caps & SC_CARD_CAP_ONLY_RAW_HASH_STRIPPED){ sc_log(ctx, "Forcing RAW_HASH_STRIPPED"); do_rsa_sig = 1; } @@ -873,7 +873,7 @@ cardos_compute_signature(sc_card_t *card, const u8 *data, size_t datalen, do_rsa_sig = 1; } else { - //check the the algorithmIDs from the AlgorithmInfo + /* check the the algorithmIDs from the AlgorithmInfo */ int i; for(i=0; ictx; epass2003_hook_path(in_path, 1); memcpy(path, in_path->value, in_path->len); pathlen = in_path->len; diff --git a/src/libopensc/card-jcop.c b/src/libopensc/card-jcop.c index 7dbc29b9ae..48602258f6 100644 --- a/src/libopensc/card-jcop.c +++ b/src/libopensc/card-jcop.c @@ -659,7 +659,7 @@ static int jcop_set_security_env(sc_card_t *card, apdu.le = 0; if (!env->flags & SC_SEC_ENV_ALG_REF_PRESENT) return SC_ERROR_INVALID_ARGUMENTS; - if (!env->flags & SC_SEC_ENV_FILE_REF_PRESENT) + if (!(env->flags & SC_SEC_ENV_FILE_REF_PRESENT)) return SC_ERROR_INVALID_ARGUMENTS; if (env->flags & SC_SEC_ENV_KEY_REF_PRESENT) { if (env->key_ref_len > 1 || env->key_ref[0] != 0) @@ -797,7 +797,6 @@ static int jcop_decipher(sc_card_t *card, } static int jcop_generate_key(sc_card_t *card, struct sc_cardctl_jcop_genkey *a) { - int modlen; int r; sc_apdu_t apdu; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; @@ -877,7 +876,6 @@ static int jcop_generate_key(sc_card_t *card, struct sc_cardctl_jcop_genkey *a) if (rbuf[0] != 0x4) { return SC_ERROR_INVALID_DATA; } - modlen=rbuf[1] * 32; if (a->pubkey_len < rbuf[1]) return SC_ERROR_BUFFER_TOO_SMALL; a->pubkey_len=rbuf[1] * 4; diff --git a/src/libopensc/card-miocos.c b/src/libopensc/card-miocos.c index 48c49cbdca..89638f5b88 100644 --- a/src/libopensc/card-miocos.c +++ b/src/libopensc/card-miocos.c @@ -320,7 +320,7 @@ static int miocos_get_acl(sc_card_t *card, sc_file_t *file) u8 rbuf[256]; const u8 *seq = rbuf; size_t left; - int acl_types[16], r; + int r; unsigned int i; sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xCA, 0x01, 0x01); @@ -331,8 +331,6 @@ static int miocos_get_acl(sc_card_t *card, sc_file_t *file) SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "APDU transmit failed"); if (apdu.resplen == 0) return sc_check_sw(card, apdu.sw1, apdu.sw2); - for (i = 0; i < 16; i++) - acl_types[i] = SC_AC_KEY_REF_NONE; left = apdu.resplen; seq = sc_asn1_skip_tag(card->ctx, &seq, &left, SC_ASN1_SEQUENCE | SC_ASN1_CONS, &left); diff --git a/src/libopensc/card-myeid.c b/src/libopensc/card-myeid.c index 3a86e568b4..2e5f9c68d9 100644 --- a/src/libopensc/card-myeid.c +++ b/src/libopensc/card-myeid.c @@ -1150,7 +1150,7 @@ static int myeid_get_info(struct sc_card *card, u8 *rbuf, size_t buflen) card->version.fw_major = rbuf[5] * 10 + rbuf[6]; card->version.fw_minor = rbuf[7]; /* add version to name */ - sprintf(nameBuf, "%s %d.%d.%d", card->name, rbuf[5], rbuf[6], rbuf[7]); + sprintf((char *) nameBuf, "%s %d.%d.%d", card->name, rbuf[5], rbuf[6], rbuf[7]); card->name = nameBuf; //card->driver->name LOG_FUNC_RETURN(card->ctx, r); diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c index cc422d3f25..e98f2ea2a6 100644 --- a/src/libopensc/card-openpgp.c +++ b/src/libopensc/card-openpgp.c @@ -549,7 +549,6 @@ pgp_set_blob(struct blob *blob, const u8 *data, size_t len) static void pgp_attach_acl(sc_card_t *card, sc_file_t *file, struct do_info *info) { - sc_acl_entry_t *acl; unsigned int method = SC_AC_NONE; unsigned long key_ref = SC_AC_KEY_REF_NONE; @@ -1676,7 +1675,6 @@ static int pgp_parse_and_set_pubkey_output(sc_card_t *card, u8* data, size_t data_len, sc_cardctl_openpgp_keygen_info_t *key_info) { - unsigned int blob_id; time_t ctime = 0; u8 *in = data; u8 *modulus = NULL; @@ -1772,10 +1770,7 @@ static int pgp_update_card_algorithms(sc_card_t *card, sc_cardctl_openpgp_keygen **/ static int pgp_gen_key(sc_card_t *card, sc_cardctl_openpgp_keygen_info_t *key_info) { - struct pgp_priv_data *priv = DRVDATA(card); - struct blob *algo_blob; sc_apdu_t apdu; - unsigned int modulus_bitlen; /* Temporary variables to hold APDU params */ u8 apdu_case; u8 *apdu_data; @@ -1784,6 +1779,8 @@ static int pgp_gen_key(sc_card_t *card, sc_cardctl_openpgp_keygen_info_t *key_in LOG_FUNC_CALLED(card->ctx); + /* FIXME the compilers doesn't assure that the buffers set here as + * apdu_data are present until the end of the function */ /* Set Control Reference Template for key */ if (key_info->keytype == SC_OPENPGP_KEY_SIGN) apdu_data = (unsigned char *) "\xb6"; @@ -1921,7 +1918,6 @@ static int pgp_build_extended_header_list(sc_card_t *card, sc_cardctl_openpgp_keystore_info_t *key_info, u8 **result, size_t *resultlen) { - struct pgp_priv_data *priv = DRVDATA(card); sc_context_t *ctx = card->ctx; /* The Cardholder private key template (7F48) part */ const size_t max_prtem_len = 7*(1 + 3); /* 7 components */ @@ -2078,7 +2074,6 @@ pgp_build_extended_header_list(sc_card_t *card, sc_cardctl_openpgp_keystore_info **/ static int pgp_store_key(sc_card_t *card, sc_cardctl_openpgp_keystore_info_t *key_info) { - struct pgp_priv_data *priv = DRVDATA(card); sc_context_t *ctx = card->ctx; sc_cardctl_openpgp_keygen_info_t pubkey; u8 *data; diff --git a/src/libopensc/card-sc-hsm.c b/src/libopensc/card-sc-hsm.c index 41176ec2e9..e25a55032a 100644 --- a/src/libopensc/card-sc-hsm.c +++ b/src/libopensc/card-sc-hsm.c @@ -137,7 +137,6 @@ static int sc_hsm_match_card(struct sc_card *card) static int sc_hsm_pin_info(sc_card_t *card, struct sc_pin_cmd_data *data, int *tries_left) { - sc_hsm_private_data_t *priv = (sc_hsm_private_data_t *) card->drv_data; sc_apdu_t apdu; int r; @@ -234,7 +233,6 @@ static int sc_hsm_update_binary(sc_card_t *card, { sc_context_t *ctx = card->ctx; sc_apdu_t apdu; - u8 recvbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 *cmdbuff, *p; size_t len; int r; @@ -621,7 +619,7 @@ static int sc_hsm_get_serialnr(sc_card_t *card, sc_serial_number_t *serial) static int sc_hsm_initialize(sc_card_t *card, sc_cardctl_sc_hsm_init_param_t *params) { sc_context_t *ctx = card->ctx; - int r, i; + int r; sc_apdu_t apdu; u8 ibuff[50], *p; @@ -760,7 +758,6 @@ static int sc_hsm_unwrap_key(sc_card_t *card, sc_cardctl_sc_hsm_wrapped_key_t *p { sc_context_t *ctx = card->ctx; sc_apdu_t apdu; - u8 status[MAX_EXT_APDU_LENGTH]; int r; LOG_FUNC_CALLED(card->ctx); @@ -888,7 +885,6 @@ static int sc_hsm_init_pin(sc_card_t *card, sc_cardctl_pkcs11_init_pin_t *params static int sc_hsm_generate_keypair(sc_card_t *card, sc_cardctl_sc_hsm_keygen_info_t *keyinfo) { - sc_hsm_private_data_t *priv = (sc_hsm_private_data_t *) card->drv_data; u8 rbuf[1024]; int r; sc_apdu_t apdu; diff --git a/src/libopensc/pkcs15-sc-hsm.c b/src/libopensc/pkcs15-sc-hsm.c index a4ec798b62..7a9799c5ca 100644 --- a/src/libopensc/pkcs15-sc-hsm.c +++ b/src/libopensc/pkcs15-sc-hsm.c @@ -147,13 +147,13 @@ int sc_pkcs15emu_sc_hsm_decode_cvc(sc_pkcs15_card_t * p15card, sc_format_asn1_entry(asn1_req , &asn1_authreq, NULL, 0); -// sc_asn1_print_tags(*buf, *buflen); +/* sc_asn1_print_tags(*buf, *buflen); */ tbuf = *buf; r = sc_asn1_read_tag(&tbuf, *buflen, &cla, &tag, &taglen); LOG_TEST_RET(card->ctx, r, "Could not decode card verifiable certificate"); - // Determine if we deal with an authenticated request, plain request or certificate + /* Determine if we deal with an authenticated request, plain request or certificate */ if ((cla == (SC_ASN1_TAG_APPLICATION|SC_ASN1_TAG_CONSTRUCTED)) && (tag == 7)) { r = sc_asn1_decode(card->ctx, asn1_req, *buf, *buflen, buf, buflen); } else { @@ -179,8 +179,6 @@ int sc_pkcs15emu_sc_hsm_encode_cvc(sc_pkcs15_card_t * p15card, struct sc_asn1_entry asn1_cvcert[C_ASN1_CVCERT_SIZE]; struct sc_asn1_entry asn1_cvc_body[C_ASN1_CVC_BODY_SIZE]; struct sc_asn1_entry asn1_cvc_pubkey[C_ASN1_CVC_PUBKEY_SIZE]; - unsigned int cla,tag; - size_t taglen; size_t lenchr; size_t lencar; int r; @@ -274,7 +272,7 @@ static int sc_pkcs15emu_sc_hsm_add_pubkey(sc_pkcs15_card_t *p15card, sc_pkcs15_p size_t cvclen; int r; - // EF.CERT is selected + /* EF.CERT is selected */ r = sc_read_binary(p15card->card, 0, efbin, sizeof(efbin), 0); LOG_TEST_RET(card->ctx, r, "Could not read CSR from EF"); @@ -286,7 +284,7 @@ static int sc_pkcs15emu_sc_hsm_add_pubkey(sc_pkcs15_card_t *p15card, sc_pkcs15_p LOG_TEST_RET(card->ctx, r, "Could decode certificate signing request"); if (cvc.publicPoint || cvc.publicPointlen) { - // ToDo implement support for EC Public Keys + /* ToDo implement support for EC Public Keys */ return SC_SUCCESS; } else { pubkey.algorithm = SC_ALGORITHM_RSA; @@ -330,7 +328,7 @@ static int sc_pkcs15emu_sc_hsm_add_prkd(sc_pkcs15_card_t * p15card, u8 keyid) { u8 efbin[512]; u8 *ptr; size_t len; - int r, i; + int r; fid[0] = PRKD_PREFIX; fid[1] = keyid; @@ -393,9 +391,9 @@ static int sc_pkcs15emu_sc_hsm_add_prkd(sc_pkcs15_card_t * p15card, u8 keyid) { return SC_SUCCESS; } - if (efbin[0] == 0x67) { // Decode CSR and create public key object + if (efbin[0] == 0x67) { /* Decode CSR and create public key object */ sc_pkcs15emu_sc_hsm_add_pubkey(p15card, key_info, prkd.label); - return SC_SUCCESS; // Ignore any errors + return SC_SUCCESS; /* Ignore any errors */ } if (efbin[0] != 0x30) { @@ -432,7 +430,7 @@ static int sc_pkcs15emu_sc_hsm_add_dcod(sc_pkcs15_card_t * p15card, u8 id) { u8 efbin[512]; const u8 *ptr; size_t len; - int r, i; + int r; fid[0] = DCOD_PREFIX; fid[1] = id; @@ -481,7 +479,7 @@ static int sc_pkcs15emu_sc_hsm_add_cd(sc_pkcs15_card_t * p15card, u8 id) { u8 efbin[512]; const u8 *ptr; size_t len; - int r, i; + int r; fid[0] = CD_PREFIX; fid[1] = id; @@ -532,7 +530,6 @@ static int sc_pkcs15emu_sc_hsm_init (sc_pkcs15_card_t * p15card) struct sc_app_info *appinfo; struct sc_pkcs15_auth_info pin_info; struct sc_pkcs15_object pin_obj; - u8 fid[2]; u8 efbin[512]; u8 *ptr; size_t len; @@ -558,15 +555,15 @@ static int sc_pkcs15emu_sc_hsm_init (sc_pkcs15_card_t * p15card) r = sc_select_file(card, &path, &file); LOG_TEST_RET(card->ctx, r, "Could not select SmartCard-HSM application"); - p15card->card->version.hw_major = 24; // JCOP 2.4.1r3 + p15card->card->version.hw_major = 24; /* JCOP 2.4.1r3 */ p15card->card->version.hw_minor = 13; p15card->card->version.fw_major = file->prop_attr[file->prop_attr_len - 2]; p15card->card->version.fw_minor = file->prop_attr[file->prop_attr_len - 1]; sc_file_free(file); - // Read device certificate to determine serial number - sc_path_set(&path, SC_PATH_TYPE_FILE_ID, "\x2F\x02", 2, 0, 0); + /* Read device certificate to determine serial number */ + sc_path_set(&path, SC_PATH_TYPE_FILE_ID, (u8 *) "\x2F\x02", 2, 0, 0); r = sc_select_file(card, &path, &file); LOG_TEST_RET(card->ctx, r, "Could not select EF.C_DevAut"); sc_file_free(file); @@ -581,7 +578,7 @@ static int sc_pkcs15emu_sc_hsm_init (sc_pkcs15_card_t * p15card) r = sc_pkcs15emu_sc_hsm_decode_cvc(p15card, (const u8 **)&ptr, &len, &devcert); LOG_TEST_RET(card->ctx, r, "Could not decode EF.C_DevAut"); - len = strlen(devcert.chr); // Strip last 5 digit sequence number from CHR + len = strlen(devcert.chr); /* Strip last 5 digit sequence number from CHR */ assert(len >= 8); len -= 5; diff --git a/src/pkcs15init/pkcs15-iasecc.c b/src/pkcs15init/pkcs15-iasecc.c index 3b6970ffde..f64e2f6de3 100644 --- a/src/pkcs15init/pkcs15-iasecc.c +++ b/src/pkcs15init/pkcs15-iasecc.c @@ -324,6 +324,9 @@ iasecc_file_convert_acls(struct sc_context *ctx, struct sc_profile *profile, str int ii; for (ii=0; iitype & SC_PKCS15_TYPE_CLASS_MASK) { case SC_PKCS15_TYPE_PUBKEY: - sc_log(ctx, "Ignore delete of SDO-PubKey(ref:%X) '%s', path %s", key_ref, object->label, sc_print_path(path)); key_ref = ((struct sc_pkcs15_pubkey_info *)object->data)->key_reference; + sc_log(ctx, "Ignore delete of SDO-PubKey(ref:%X) '%s', path %s", key_ref, object->label, sc_print_path(path)); LOG_FUNC_RETURN(ctx, SC_SUCCESS); case SC_PKCS15_TYPE_PRKEY: sc_log(ctx, "delete PrivKey '%s', path %s", object->label, sc_print_path(path)); @@ -1655,12 +1658,9 @@ iasecc_store_data_object(struct sc_pkcs15_card *p15card, struct sc_profile *prof LOG_TEST_RET(ctx, nn_objs, "IasEcc get pkcs15 DATA objects error"); for(indx = 1; indx < MAX_DATA_OBJS; indx++) { - struct sc_path fpath; - rv = iasecc_pkcs15_new_file(profile, card, SC_PKCS15_TYPE_DATA_OBJECT, indx, &file); LOG_TEST_RET(ctx, rv, "iasecc_store_data_object() pkcs15 new DATA file error"); - fpath = file->path; for (ii=0; iidata; int file_id = info->path.value[info->path.len - 2] * 0x100 + info->path.value[info->path.len - 1]; @@ -1788,14 +1788,6 @@ iasecc_emu_store_data(struct sc_pkcs15_card *p15card, struct sc_profile *profile } -static int -iasecc_emu_update_tokeninfo(struct sc_profile *profile, struct sc_pkcs15_card *p15card, - struct sc_pkcs15_tokeninfo *tinfo) -{ - LOG_FUNC_RETURN(p15card->card->ctx, SC_SUCCESS); -} - - static struct sc_pkcs15init_operations sc_pkcs15init_iasecc_operations = { iasecc_pkcs15_erase_card, diff --git a/src/pkcs15init/pkcs15-lib.c b/src/pkcs15init/pkcs15-lib.c index 28845625a9..4523b4a693 100644 --- a/src/pkcs15init/pkcs15-lib.c +++ b/src/pkcs15init/pkcs15-lib.c @@ -1368,9 +1368,8 @@ sc_pkcs15init_store_private_key(struct sc_pkcs15_card *p15card, { struct sc_context *ctx = p15card->card->ctx; struct sc_pkcs15_object *object; - struct sc_pkcs15_prkey_info *key_info; struct sc_pkcs15_prkey key; - int keybits, idx, r = 0; + int keybits, r = 0; LOG_FUNC_CALLED(ctx); /* Create a copy of the key first */ @@ -1404,13 +1403,13 @@ sc_pkcs15init_store_private_key(struct sc_pkcs15_card *p15card, /* Set up the PrKDF object */ r = sc_pkcs15init_init_prkdf(p15card, profile, keyargs, &key, keybits, &object); LOG_TEST_RET(ctx, r, "Failed to initialize private key object"); - key_info = (struct sc_pkcs15_prkey_info *) object->data; + /*key_info = (struct sc_pkcs15_prkey_info *) object->data;*/ r = sc_pkcs15init_encode_prvkey_content(p15card, &key, object); LOG_TEST_RET(ctx, r, "Failed to encode public key"); /* Get the number of private keys already on this card */ - idx = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_PRKEY, NULL, 0); + /*idx = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_PRKEY, NULL, 0);*/ r = profile->ops->create_key(profile, p15card, object); LOG_TEST_RET(ctx, r, "Card specific 'create key' failed"); diff --git a/src/pkcs15init/pkcs15-sc-hsm.c b/src/pkcs15init/pkcs15-sc-hsm.c index ed7b58b4d3..0508f0c553 100644 --- a/src/pkcs15init/pkcs15-sc-hsm.c +++ b/src/pkcs15init/pkcs15-sc-hsm.c @@ -153,7 +153,6 @@ static int sc_hsm_update_ef(sc_pkcs15_card_t *p15card, u8 prefix, u8 id, int era { sc_card_t *card = p15card->card; sc_file_t *file = NULL; - sc_file_t newfile; sc_path_t path; u8 fid[2]; int r; @@ -264,10 +263,9 @@ static int sc_hsm_get_curve(struct sc_pkcs15_card *p15card, struct ec_curve **cu static int sc_hsm_encode_gakp_ec(struct sc_pkcs15_card *p15card, sc_cvc_t *cvc, struct sc_pkcs15_prkey_info *key_info) { struct sc_object_id ecdsaWithSHA256 = { { 0,4,0,127,0,7,2,2,2,2,3,-1 } }; struct sc_pkcs15_ec_parameters *ecparams = (struct sc_pkcs15_ec_parameters *)key_info->params.data; - struct ec_curve *curve; + struct ec_curve *curve = NULL; u8 *curveoid; - int curveoidlen; - int r; + int curveoidlen, r; LOG_FUNC_CALLED(p15card->card->ctx); @@ -335,10 +333,6 @@ static int sc_hsm_decode_gakp_rsa(struct sc_pkcs15_card *p15card, struct sc_pkcs15_prkey_info *key_info, struct sc_pkcs15_pubkey *pubkey) { - u8 *buf; - size_t buflen; - int r; - LOG_FUNC_CALLED(p15card->card->ctx); if (((key_info->modulus_length + 7) / 8) != cvc->primeOrModuluslen) { @@ -367,13 +361,8 @@ static int sc_hsm_decode_gakp_ec(struct sc_pkcs15_card *p15card, struct sc_pkcs15_prkey_info *key_info, struct sc_pkcs15_pubkey *pubkey) { - struct sc_asn1_entry asn1_ec_pointQ[C_ASN1_EC_POINTQ_SIZE]; struct sc_pkcs15_ec_parameters *ecparams = (struct sc_pkcs15_ec_parameters *)(key_info->params.data); struct sc_ec_params *ecp; - u8 *buf; - size_t buflen; - int r; - LOG_FUNC_CALLED(p15card->card->ctx); pubkey->algorithm = SC_ALGORITHM_EC; @@ -417,7 +406,6 @@ static int sc_hsm_generate_key(struct sc_profile *profile, struct sc_pkcs15_card struct sc_pkcs15_object *object, struct sc_pkcs15_pubkey *pubkey) { - struct sc_context *ctx = p15card->card->ctx; struct sc_card *card = p15card->card; struct sc_pkcs15_prkey_info *key_info = (struct sc_pkcs15_prkey_info *)object->data; sc_cardctl_sc_hsm_keygen_info_t sc_hsm_keyinfo; @@ -523,7 +511,6 @@ static int sc_hsm_emu_store_cert(struct sc_pkcs15_card *p15card, struct sc_profi struct sc_pkcs15_der *data) { - struct sc_context *ctx = p15card->card->ctx; struct sc_pkcs15_cert_info *cert_info = (struct sc_pkcs15_cert_info *) object->data; struct sc_pkcs15_object *prkey; sc_path_t path; @@ -558,7 +545,6 @@ static int sc_hsm_emu_delete_cert(struct sc_pkcs15_card *p15card, struct sc_prof struct sc_pkcs15_object *object) { - struct sc_context *ctx = p15card->card->ctx; struct sc_pkcs15_cert_info *cert_info = (struct sc_pkcs15_cert_info *) object->data; struct sc_pkcs15_object *prkey; int r; @@ -581,7 +567,6 @@ static int sc_hsm_emu_store_binary(struct sc_pkcs15_card *p15card, struct sc_pro struct sc_pkcs15_der *data) { - struct sc_context *ctx = p15card->card->ctx; struct sc_pkcs15_data_info *data_info = (struct sc_pkcs15_data_info *) object->data; sc_path_t path; u8 id[2]; @@ -671,7 +656,6 @@ static int sc_hsm_emu_delete_object(struct sc_profile *profile, struct sc_pkcs15 static int sc_hsm_emu_update_prkd(struct sc_profile *profile, struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *object) { - struct sc_context *ctx = p15card->card->ctx; struct sc_pkcs15_prkey_info *key_info = (struct sc_pkcs15_prkey_info *)object->data; u8 *buf; size_t buflen; @@ -690,7 +674,6 @@ static int sc_hsm_emu_update_prkd(struct sc_profile *profile, struct sc_pkcs15_c static int sc_hsm_emu_update_dcod(struct sc_profile *profile, struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *object) { - struct sc_context *ctx = p15card->card->ctx; struct sc_pkcs15_data_info *data_info = (struct sc_pkcs15_data_info *) object->data; u8 *buf; size_t buflen; @@ -709,7 +692,6 @@ static int sc_hsm_emu_update_dcod(struct sc_profile *profile, struct sc_pkcs15_c static int sc_hsm_emu_update_cd(struct sc_profile *profile, struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *object) { - struct sc_context *ctx = p15card->card->ctx; struct sc_pkcs15_cert_info *cert_info = (struct sc_pkcs15_cert_info *) object->data; u8 *buf; size_t buflen; @@ -734,11 +716,7 @@ static int sc_hsm_emu_update_cd(struct sc_profile *profile, struct sc_pkcs15_car static int sc_hsm_emu_delete_cd(struct sc_profile *profile, struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *object) { - struct sc_context *ctx = p15card->card->ctx; struct sc_pkcs15_cert_info *cert_info = (struct sc_pkcs15_cert_info *) object->data; - u8 *buf; - size_t buflen; - int r; if ((cert_info->path.len < 2) || ((cert_info->path.value[cert_info->path.len - 2]) != CA_CERTIFICATE_PREFIX)) { diff --git a/src/smm/sm-card-authentic.c b/src/smm/sm-card-authentic.c index 47562344f2..8ebfbdc073 100644 --- a/src/smm/sm-card-authentic.c +++ b/src/smm/sm-card-authentic.c @@ -238,7 +238,6 @@ sm_authentic_get_apdu_create_file(struct sc_context *ctx, struct sm_info *sm_inf LOG_FUNC_RETURN(ctx, rv); } -#endif static int sm_authentic_get_apdu_release(struct sc_context *ctx, struct sm_info *sm_info, @@ -267,6 +266,7 @@ sm_authentic_get_apdu_release(struct sc_context *ctx, struct sm_info *sm_info, LOG_FUNC_RETURN(ctx, rv); } +#endif int diff --git a/src/smm/sm-global-platform.c b/src/smm/sm-global-platform.c index 1c450be997..d7561e7bab 100644 --- a/src/smm/sm-global-platform.c +++ b/src/smm/sm-global-platform.c @@ -343,7 +343,7 @@ sm_gp_external_authentication(struct sc_context *ctx, struct sm_info *sm_info, unsigned char host_cryptogram[8], raw_apdu[SC_MAX_APDU_BUFFER_SIZE]; struct sm_gp_session *gp_session = &sm_info->session.gp; DES_cblock mac; - int rv, idx = 0, offs = 0; + int rv, offs = 0; LOG_FUNC_CALLED(ctx); if (!sm_info || !init_data || !rdata || !rdata->alloc) diff --git a/src/tools/openpgp-tool.c b/src/tools/openpgp-tool.c index 9ebb2244c8..a5dcc8a413 100644 --- a/src/tools/openpgp-tool.c +++ b/src/tools/openpgp-tool.c @@ -33,6 +33,7 @@ #include "libopensc/cards.h" #include "libopensc/cardctl.h" #include "util.h" +#include "libopensc/log.h" #define OPT_RAW 256 #define OPT_PRETTY 257 @@ -346,40 +347,6 @@ static int do_userinfo(sc_card_t *card) } -/* Select and read a transparent EF */ -static int read_transp(sc_card_t *card, const char *pathstring, unsigned char *buf, int buflen) -{ - sc_path_t path; - int r; - - sc_format_path(pathstring, &path); - r = sc_select_file(card, &path, NULL); - if (r < 0) - fprintf(stderr, "\nFailed to select file %s: %s\n", pathstring, sc_strerror(r)); - else { - r = sc_read_binary(card, 0, buf, buflen, 0); - if (r < 0) - fprintf(stderr, "\nFailed to read %s: %s\n", pathstring, sc_strerror(r)); - } - - return r; -} - - -/* Hex-encode the buf, 2*len+1 bytes must be reserved. E.g. {'1','2'} -> {'3','1','3','2','\0'} */ -static void bintohex(char *buf, int len) -{ - static const char hextable[] = "0123456789ABCDEF"; - int i; - - for (i = len - 1; i >= 0; i--) { - unsigned char c = (unsigned char) buf[i]; - - buf[2 * i + 1] = hextable[c % 16]; - buf[2 * i] = hextable[c / 16]; - } -} - int do_genkey(sc_card_t *card, u8 key_id, unsigned int key_len) { int r; diff --git a/src/tools/sc-hsm-tool.c b/src/tools/sc-hsm-tool.c index 72b115d190..d6eb5ed357 100644 --- a/src/tools/sc-hsm-tool.c +++ b/src/tools/sc-hsm-tool.c @@ -37,6 +37,7 @@ #include #include #include +#include #include "libopensc/opensc.h" #include "libopensc/cardctl.h" @@ -922,7 +923,7 @@ static void create_dkek_share(sc_card_t *card, const char *outf, int iter, char r = sc_get_challenge(card, filebuff + 8, 8); if (r < 0) { - printf("Error generating random number failed with ", sc_strerror(r)); + printf("Error generating random number failed with %s", sc_strerror(r)); return; } @@ -936,7 +937,7 @@ static void create_dkek_share(sc_card_t *card, const char *outf, int iter, char r = sc_get_challenge(card, dkek_share, sizeof(dkek_share)); if (r < 0) { - printf("Error generating random number failed with ", sc_strerror(r)); + printf("Error generating random number failed with %s", sc_strerror(r)); return; } @@ -1037,7 +1038,6 @@ static void wrap_key(sc_card_t *card, u8 keyid, const char *outf, const char *pi { sc_cardctl_sc_hsm_wrapped_key_t wrapped_key; struct sc_pin_cmd_data data; - sc_file_t *file = NULL; sc_path_t path; FILE *out = NULL; u8 fid[2];