IAS/ECC: remove dead code and '//' coments, resolve some warnings ...
to be continued, thanks to Martin git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5200 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
e02becc6e2
commit
53dd2ceafa
|
@ -566,9 +566,10 @@ iasecc_read_binary(struct sc_card *card, unsigned int offs,
|
|||
LOG_TEST_RET(ctx, rv, "APDU transmit failed");
|
||||
rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
|
||||
LOG_TEST_RET(ctx, rv, "iasecc_read_binary() failed");
|
||||
//if (apdu.resplen == 0)
|
||||
// SC_FUNC_RETURN(ctx, 2, sc_check_sw(card, apdu.sw1, apdu.sw2));
|
||||
|
||||
/*
|
||||
if (apdu.resplen == 0)
|
||||
SC_FUNC_RETURN(ctx, 2, sc_check_sw(card, apdu.sw1, apdu.sw2));
|
||||
*/
|
||||
sc_log(ctx, "iasecc_read_binary() apdu.resplen %i", apdu.resplen);
|
||||
|
||||
if (apdu.resplen == IASECC_READ_BINARY_LENGTH_MAX && apdu.resplen < count) {
|
||||
|
@ -880,10 +881,11 @@ iasecc_process_fci(struct sc_card *card, struct sc_file *file,
|
|||
|
||||
rv = iso_ops->process_fci(card, file, buf, buflen);
|
||||
LOG_TEST_RET(ctx, rv, "ISO parse FCI failed");
|
||||
|
||||
// Gemalto: 6F 19 80 02 02 ED 82 01 01 83 02 B0 01 88 00 8C 07 7B 17 17 17 17 17 00 8A 01 05 90 00
|
||||
// Sagem: 6F 17 62 15 80 02 00 7D 82 01 01 8C 02 01 00 83 02 2F 00 88 01 F0 8A 01 05 90 00
|
||||
// Oberthur: 62 1B 80 02 05 DC 82 01 01 83 02 B0 01 88 00 A1 09 8C 07 7B 17 FF 17 17 17 00 8A 01 05 90 00
|
||||
/*
|
||||
Gemalto: 6F 19 80 02 02 ED 82 01 01 83 02 B0 01 88 00 8C 07 7B 17 17 17 17 17 00 8A 01 05 90 00
|
||||
Sagem: 6F 17 62 15 80 02 00 7D 82 01 01 8C 02 01 00 83 02 2F 00 88 01 F0 8A 01 05 90 00
|
||||
Oberthur: 62 1B 80 02 05 DC 82 01 01 83 02 B0 01 88 00 A1 09 8C 07 7B 17 FF 17 17 17 00 8A 01 05 90 00
|
||||
*/
|
||||
|
||||
sc_log(ctx, "iasecc_process_fci() type %i; let's parse file ACLs", file->type);
|
||||
tag = sc_asn1_find_tag(ctx, buf, buflen, IASECC_DOCP_TAG_ACLS, &taglen);
|
||||
|
@ -1193,34 +1195,6 @@ iasecc_check_sw(struct sc_card *card, unsigned int sw1, unsigned int sw2)
|
|||
}
|
||||
|
||||
|
||||
#if 0
|
||||
const struct sc_supported_algo_info *
|
||||
iasecc_get_algorithm(struct sc_context *ctx, const struct sc_security_env *env,
|
||||
unsigned operation, unsigned mechanism)
|
||||
{
|
||||
const struct sc_supported_algo_info *info = NULL;
|
||||
int ii;
|
||||
|
||||
if (!env)
|
||||
return NULL;
|
||||
|
||||
for (ii=0;ii<SC_MAX_SUPPORTED_ALGORITHMS && env->supported_algos[ii].reference; ii++)
|
||||
if ((env->supported_algos[ii].operations & operation)
|
||||
&& (env->supported_algos[ii].mechanism == mechanism))
|
||||
break;
|
||||
|
||||
if (ii < SC_MAX_SUPPORTED_ALGORITHMS && env->supported_algos[ii].reference) {
|
||||
info = &env->supported_algos[ii];
|
||||
sc_log(ctx, "found IAS/ECC algorithm %X:%X:%X:%X",
|
||||
info->reference, info->mechanism, info->operations, info->algo_ref);
|
||||
}
|
||||
else {
|
||||
sc_log(ctx, "cannot find IAS/ECC algorithm (operation:%X,mechanism:%X)", operation, mechanism);
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
#else
|
||||
static unsigned
|
||||
iasecc_get_algorithm(struct sc_context *ctx, const struct sc_security_env *env,
|
||||
unsigned operation, unsigned mechanism)
|
||||
|
@ -1247,7 +1221,6 @@ iasecc_get_algorithm(struct sc_context *ctx, const struct sc_security_env *env,
|
|||
|
||||
return info ? info->algo_ref : 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static int
|
||||
|
@ -1382,7 +1355,6 @@ iasecc_set_security_env(struct sc_card *card,
|
|||
struct sc_context *ctx = card->ctx;
|
||||
struct iasecc_sdo sdo;
|
||||
struct iasecc_private_data *prv = (struct iasecc_private_data *) card->drv_data;
|
||||
//const struct sc_supported_algo_info *algo_info = NULL;
|
||||
unsigned algo_ref;
|
||||
struct sc_apdu apdu;
|
||||
unsigned sign_meth, sign_ref, auth_meth, auth_ref, aflags;
|
||||
|
@ -2045,11 +2017,9 @@ iasecc_pin_reset(struct sc_card *card, struct sc_pin_cmd_data *data, int *tries_
|
|||
ignore_ext_auth = ((scb & IASECC_SCB_METHOD_EXT_AUTH) && !need_all && (scb & IASECC_SCB_METHOD_SM));
|
||||
#endif
|
||||
if (scb & IASECC_SCB_METHOD_USER_AUTH) {
|
||||
int puk_tries_left;
|
||||
|
||||
sc_log(ctx, "Try to verify PUK code: pin1.data:%p, pin1.len:%i", data->pin1.data, data->pin1.len);
|
||||
rv = iasecc_pin_verify(card, SC_AC_SEN, scb & IASECC_SCB_METHOD_MASK_REF,
|
||||
data->pin1.data, data->pin1.len, &puk_tries_left);
|
||||
data->pin1.data, data->pin1.len, tries_left);
|
||||
sc_log(ctx, "Verify PUK code returned %i", rv);
|
||||
LOG_TEST_RET(ctx, rv, "iasecc_pin_reset() PIN verification error");
|
||||
|
||||
|
@ -2192,7 +2162,6 @@ iasecc_get_serialnr(struct sc_card *card, struct sc_serial_number *serial)
|
|||
unsigned char rbuf[0xC0];
|
||||
size_t ii, offs;
|
||||
int rv;
|
||||
int coucou;
|
||||
|
||||
LOG_FUNC_CALLED(ctx);
|
||||
if (card->serialnr.len)
|
||||
|
@ -2853,7 +2822,10 @@ iasecc_compute_signature(struct sc_card *card,
|
|||
LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* FIXME: Should we implement 'read-public-key' facility, or assume that public key will be always present as
|
||||
* 'direct' PKCS#15 ObjectValue ?
|
||||
|
||||
static int
|
||||
iasecc_read_public_key(struct sc_card *card, unsigned type, void *data,
|
||||
unsigned char **out, size_t *out_len)
|
||||
|
@ -2915,7 +2887,7 @@ iasecc_read_public_key(struct sc_card *card, unsigned type, void *data,
|
|||
|
||||
SC_FUNC_RETURN(ctx, 1, rv);
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
static int
|
||||
iasecc_get_free_reference(struct sc_card *card, struct iasecc_ctl_get_free_reference *ctl_data)
|
||||
|
@ -3032,36 +3004,35 @@ sc_get_driver(void)
|
|||
iasecc_ops.init = iasecc_init;
|
||||
iasecc_ops.finish = iasecc_finish;
|
||||
iasecc_ops.read_binary = iasecc_read_binary;
|
||||
// write_binary: ISO7816 implementation works
|
||||
// update_binary: ISO7816 implementation works
|
||||
/* write_binary: ISO7816 implementation works */
|
||||
/* update_binary: ISO7816 implementation works */
|
||||
iasecc_ops.erase_binary = iasecc_erase_binary;
|
||||
// resize_binary
|
||||
// read_record: Untested
|
||||
// write_record: Untested
|
||||
// append_record: Untested
|
||||
// update_record: Untested
|
||||
/* resize_binary */
|
||||
/* read_record: Untested */
|
||||
/* write_record: Untested */
|
||||
/* append_record: Untested */
|
||||
/* update_record: Untested */
|
||||
iasecc_ops.select_file = iasecc_select_file;
|
||||
// get_response: Untested
|
||||
// get_challenge: ISO7816 implementation works
|
||||
/* get_response: Untested */
|
||||
/* get_challenge: ISO7816 implementation works */
|
||||
iasecc_ops.logout = iasecc_logout;
|
||||
// restore_security_env
|
||||
/* restore_security_env */
|
||||
iasecc_ops.set_security_env = iasecc_set_security_env;
|
||||
// decipher: Untested
|
||||
iasecc_ops.decipher = iasecc_decipher;
|
||||
iasecc_ops.compute_signature = iasecc_compute_signature;
|
||||
iasecc_ops.create_file = iasecc_create_file;
|
||||
iasecc_ops.delete_file = iasecc_delete_file;
|
||||
// list_files
|
||||
/* list_files */
|
||||
iasecc_ops.check_sw = iasecc_check_sw;
|
||||
iasecc_ops.card_ctl = iasecc_card_ctl;
|
||||
iasecc_ops.process_fci = iasecc_process_fci;
|
||||
// construct_fci: Not needed
|
||||
/* construct_fci: Not needed */
|
||||
iasecc_ops.pin_cmd = iasecc_pin_cmd;
|
||||
// get_data:
|
||||
// put_data: Not implemented
|
||||
// delete_record: Not implemented
|
||||
/* get_data: Not implemented */
|
||||
/* put_data: Not implemented */
|
||||
/* delete_record: Not implemented */
|
||||
|
||||
// iasecc_ops.read_public_key = iasecc_read_public_key;
|
||||
/* iasecc_ops.read_public_key = iasecc_read_public_key */
|
||||
|
||||
return &iasecc_drv;
|
||||
}
|
||||
|
|
|
@ -987,16 +987,8 @@ iasecc_sdo_encode_rsa_update(struct sc_context *ctx, struct iasecc_sdo *sdo,
|
|||
memset(sdo_update, 0, sizeof(*sdo_update));
|
||||
if (sdo->sdo_class == IASECC_SDO_CLASS_RSA_PRIVATE) {
|
||||
sc_log(ctx, "iasecc_sdo_encode_rsa_update(IASECC_SDO_CLASS_RSA_PRIVATE)");
|
||||
if (!rsa->p.len || !rsa->q.len || !rsa->iqmp.len || !rsa->dmp1.len || !rsa->dmq1.len) {
|
||||
#if 0
|
||||
if (!rsa->encrypted_key.value || !rsa->encrypted_key.len)
|
||||
LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "need all private RSA key components");
|
||||
|
||||
LOG_FUNC_RETURN(ctx, SC_SUCCESS);
|
||||
#else
|
||||
if (!rsa->p.len || !rsa->q.len || !rsa->iqmp.len || !rsa->dmp1.len || !rsa->dmq1.len)
|
||||
LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "need all private RSA key components");
|
||||
#endif
|
||||
}
|
||||
|
||||
sdo_update->magic = SC_CARDCTL_IASECC_SDO_MAGIC_PUT_DATA;
|
||||
sdo_update->sdo_ref = sdo->sdo_ref;
|
||||
|
@ -1028,7 +1020,7 @@ iasecc_sdo_encode_rsa_update(struct sc_context *ctx, struct iasecc_sdo *sdo,
|
|||
sdo_update->fields[4].value = rsa->dmq1.data;
|
||||
sdo_update->fields[4].size = rsa->dmq1.len;
|
||||
|
||||
// TODO: Activated for Oberthur -- check for others
|
||||
/* FIXME: Activated for Oberthur -- check for others */
|
||||
sc_log(ctx, "prv_key.compulsory.on_card %i", sdo->data.prv_key.compulsory.on_card);
|
||||
if (!sdo->data.prv_key.compulsory.on_card) {
|
||||
if (sdo->data.prv_key.compulsory.value) {
|
||||
|
@ -1104,7 +1096,7 @@ iasecc_sdo_parse_card_answer(struct sc_context *ctx, unsigned char *data, size_t
|
|||
struct iasecc_sm_card_answer *out)
|
||||
{
|
||||
int offs, have_mac = 0, have_status = 0;
|
||||
size_t size, size_size;
|
||||
size_t size = 0, size_size;
|
||||
|
||||
LOG_FUNC_CALLED(ctx);
|
||||
if (!data || !data_len || !out)
|
||||
|
|
|
@ -63,7 +63,7 @@ iasecc_reference_to_pkcs15_id (unsigned int ref, struct sc_pkcs15_id *id)
|
|||
{
|
||||
int ii, sz;
|
||||
|
||||
for (ii=0, sz = 0; ii<sizeof(unsigned int); ii++)
|
||||
for (ii=0, sz = 0; (unsigned)ii < sizeof(unsigned int); ii++)
|
||||
if (ref >> 8*ii)
|
||||
sz++;
|
||||
|
||||
|
@ -306,7 +306,6 @@ iasecc_sdo_get_data(struct sc_card *card, struct iasecc_sdo *sdo)
|
|||
static int
|
||||
iasecc_file_convert_acls(struct sc_context *ctx, struct sc_profile *profile, struct sc_file *file)
|
||||
{
|
||||
/* struct pin_info *pi = NULL, **tail = NULL; */
|
||||
int ii;
|
||||
|
||||
for (ii=0; ii<SC_MAX_AC_OPS;ii++) {
|
||||
|
@ -315,28 +314,7 @@ iasecc_file_convert_acls(struct sc_context *ctx, struct sc_profile *profile, str
|
|||
if (acl) {
|
||||
switch (acl->method) {
|
||||
case SC_AC_IDA:
|
||||
#if 0
|
||||
for (tail = &profile->pin_list; (pi = *tail); tail = &pi->next) {
|
||||
if (pi->pin.reference == acl->key_ref && pi->pin.sen_reference) {
|
||||
acl->method = SC_AC_SEN;
|
||||
acl->key_ref = pi->pin.sen_reference;
|
||||
break;
|
||||
}
|
||||
if (pi->pin.reference == acl->key_ref && pi->pin.chv_reference) {
|
||||
acl->method = SC_AC_CHV;
|
||||
acl->key_ref = pi->pin.chv_reference;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!pi) {
|
||||
sc_log(ctx, "convert ACLs error: no PIN found for SC_AC_IDA(ref:%X)", acl->key_ref);
|
||||
LOG_TEST_RET(ctx, SC_ERROR_INCONSISTENT_PROFILE, "Cannot convert ACL(s)");
|
||||
}
|
||||
break;
|
||||
#else
|
||||
LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "'IDA' not actually supported");
|
||||
#endif
|
||||
case SC_AC_SCB:
|
||||
if ((acl->key_ref & IASECC_SCB_METHOD_MASK) == IASECC_SCB_METHOD_USER_AUTH) {
|
||||
acl->method = SC_AC_SEN;
|
||||
|
@ -461,8 +439,7 @@ iasecc_sdo_allocate_prvkey(struct sc_profile *profile, struct sc_card *card,
|
|||
rv = iasecc_sdo_set_key_acls_from_profile(profile, card, "private-key", sdo);
|
||||
LOG_TEST_RET(ctx, rv, "IasEcc: cannot set ACLs for SDO from the 'private-key'");
|
||||
|
||||
//sdo->docp.name =
|
||||
//sdo->docp.idata =
|
||||
/* FIXME: set here sdo->docp.name and sdo->docp.idata */
|
||||
|
||||
sdo->docp.non_repudiation.value = calloc(1, 1);
|
||||
if (!sdo->docp.non_repudiation.value)
|
||||
|
@ -483,11 +460,12 @@ iasecc_sdo_allocate_prvkey(struct sc_profile *profile, struct sc_card *card,
|
|||
sdo->docp.size.size = 2;
|
||||
*(sdo->docp.size.value + 0) = (sz >> 8) & 0xFF;
|
||||
*(sdo->docp.size.value + 1) = sz & 0xFF;
|
||||
|
||||
// TODO: Manage CRT key types: IASECC_GEN_KEY_TYPE_*: X509_usage
|
||||
// Optional PRIVATE KEY SDO attribute 'Algorithm to compulsorily use' can have one of the three values:
|
||||
// B6(Sign), A4(Authentication), B8(Confidentiality).
|
||||
// If present, this attribute has to be the same in a 'GENERATE KEY' template data.
|
||||
/*
|
||||
FIXME: Manage CRT key types: IASECC_GEN_KEY_TYPE_*: X509_usage
|
||||
Optional PRIVATE KEY SDO attribute 'Algorithm to compulsorily use' can have one of the three values:
|
||||
B6(Sign), A4(Authentication), B8(Confidentiality).
|
||||
If present, this attribute has to be the same in the 'GENERATE KEY' template data.
|
||||
*/
|
||||
if (!(key_info->access_flags & SC_PKCS15_PRKEY_ACCESS_LOCAL) && (key_info->usage & SC_PKCS15_PRKEY_USAGE_NONREPUDIATION))
|
||||
sc_log(ctx, "Non fatal error: NON_REPUDATION can be used only for the localy generated keys");
|
||||
|
||||
|
@ -1331,7 +1309,8 @@ iasecc_store_cert(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
|
|||
}
|
||||
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* FIXME: Implement 'store data object'
|
||||
static int
|
||||
iasecc_store_opaqueDO(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
|
||||
struct sc_pkcs15_object *object, struct sc_pkcs15_id *id,
|
||||
|
@ -1447,7 +1426,7 @@ iasecc_store_opaqueDO(struct sc_pkcs15_card *p15card, struct sc_profile *profile
|
|||
|
||||
LOG_FUNC_RETURN(ctx, rv);
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
|
||||
static int
|
||||
|
@ -1468,11 +1447,11 @@ iasecc_emu_store_data(struct sc_pkcs15_card *p15card, struct sc_profile *profile
|
|||
case SC_PKCS15_TYPE_CERT:
|
||||
rv = iasecc_store_cert(p15card, profile, object, data, path);
|
||||
break;
|
||||
#if 0
|
||||
/*
|
||||
case SC_PKCS15_TYPE_DATA_OBJECT:
|
||||
rv = iasecc_store_opaqueDO(p15card, profile, object, id, data, path);
|
||||
break;
|
||||
#endif
|
||||
*/
|
||||
}
|
||||
|
||||
LOG_FUNC_RETURN(ctx, rv);
|
||||
|
@ -1510,11 +1489,13 @@ sc_pkcs15init_iasecc_operations = {
|
|||
iasecc_emu_update_tokeninfo,
|
||||
NULL,
|
||||
iasecc_emu_store_data,
|
||||
#if 0
|
||||
iasecc_pkcs15init_select_id, /* ext_select_id */
|
||||
|
||||
NULL, /* sanity_check */
|
||||
/*
|
||||
iasecc_pkcs15init_select_id,
|
||||
iasecc_pkcs15init_set_pin,
|
||||
iasecc_pkcs15init_erase_application
|
||||
#endif
|
||||
*/
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue