- Whitespace cleanup from me and Martin Paljak
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2181 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
df12bfb5b1
commit
df5e357694
|
@ -116,13 +116,12 @@ static int setcos_init(struct sc_card *card)
|
|||
|
||||
/* Handle unknown or forced cards */
|
||||
if (card->type < 0) {
|
||||
card->type = SC_CARD_TYPE_SETCOS_GENERIC;
|
||||
#if 0
|
||||
/* Hmm. For now, assume it's a bank card with FinEID application */
|
||||
if (match_hist_bytes(card, "AVANT", 0)) {
|
||||
card->type = SC_CARD_TYPE_SETCOS_FINEID;
|
||||
} else
|
||||
#endif
|
||||
card->type = SC_CARD_TYPE_SETCOS_GENERIC;
|
||||
}
|
||||
if (card->type == SC_CARD_TYPE_SETCOS_FINEID) {
|
||||
card->cla = 0x00;
|
||||
|
@ -313,7 +312,7 @@ static int setcos_set_security_env(struct sc_card *card,
|
|||
tmp.algorithm_ref |= 0x10;
|
||||
return setcos_set_security_env2(card, &tmp, se_num);
|
||||
}
|
||||
return setcos_set_security_env2(card, env, se_num);
|
||||
return setcos_set_security_env2(card, env, se_num);
|
||||
}
|
||||
|
||||
static void add_acl_entry(struct sc_file *file, int op, u8 byte)
|
||||
|
@ -410,15 +409,15 @@ static struct sc_card_driver * sc_get_driver(void)
|
|||
setcos_ops = *iso_drv->ops;
|
||||
setcos_ops.match_card = setcos_match_card;
|
||||
setcos_ops.init = setcos_init;
|
||||
setcos_ops.finish = setcos_finish;
|
||||
setcos_ops.finish = setcos_finish;
|
||||
if (iso_ops == NULL)
|
||||
iso_ops = iso_drv->ops;
|
||||
iso_ops = iso_drv->ops;
|
||||
setcos_ops.create_file = setcos_create_file;
|
||||
setcos_ops.set_security_env = setcos_set_security_env;
|
||||
setcos_ops.select_file = setcos_select_file;
|
||||
setcos_ops.list_files = setcos_list_files;
|
||||
|
||||
return &setcos_drv;
|
||||
return &setcos_drv;
|
||||
}
|
||||
|
||||
#if 1
|
||||
|
|
|
@ -519,9 +519,9 @@ int sc_unlock(struct sc_card *card)
|
|||
if (card->lock_count == 1) {
|
||||
if (card->reader->ops->unlock != NULL)
|
||||
r = card->reader->ops->unlock(card->reader, card->slot);
|
||||
}
|
||||
card->lock_count--;
|
||||
sc_mutex_unlock(card->mutex);
|
||||
}
|
||||
card->lock_count--;
|
||||
sc_mutex_unlock(card->mutex);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -531,10 +531,10 @@ int sc_list_files(struct sc_card *card, u8 *buf, size_t buflen)
|
|||
|
||||
assert(card != NULL);
|
||||
SC_FUNC_CALLED(card->ctx, 1);
|
||||
if (card->ops->list_files == NULL)
|
||||
if (card->ops->list_files == NULL)
|
||||
SC_FUNC_RETURN(card->ctx, 1, SC_ERROR_NOT_SUPPORTED);
|
||||
r = card->ops->list_files(card, buf, buflen);
|
||||
SC_FUNC_RETURN(card->ctx, 1, r);
|
||||
SC_FUNC_RETURN(card->ctx, 1, r);
|
||||
}
|
||||
|
||||
int sc_create_file(struct sc_card *card, struct sc_file *file)
|
||||
|
@ -549,10 +549,10 @@ int sc_create_file(struct sc_card *card, struct sc_file *file)
|
|||
in_path->type,
|
||||
sc_print_path(in_path), file->size);
|
||||
}
|
||||
if (card->ops->create_file == NULL)
|
||||
if (card->ops->create_file == NULL)
|
||||
SC_FUNC_RETURN(card->ctx, 1, SC_ERROR_NOT_SUPPORTED);
|
||||
r = card->ops->create_file(card, file);
|
||||
SC_FUNC_RETURN(card->ctx, 1, r);
|
||||
SC_FUNC_RETURN(card->ctx, 1, r);
|
||||
}
|
||||
|
||||
int sc_delete_file(struct sc_card *card, const struct sc_path *path)
|
||||
|
@ -565,10 +565,10 @@ int sc_delete_file(struct sc_card *card, const struct sc_path *path)
|
|||
path->type,
|
||||
sc_print_path(path));
|
||||
}
|
||||
if (card->ops->delete_file == NULL)
|
||||
if (card->ops->delete_file == NULL)
|
||||
SC_FUNC_RETURN(card->ctx, 1, SC_ERROR_NOT_SUPPORTED);
|
||||
r = card->ops->delete_file(card, path);
|
||||
SC_FUNC_RETURN(card->ctx, 1, r);
|
||||
SC_FUNC_RETURN(card->ctx, 1, r);
|
||||
}
|
||||
|
||||
int sc_read_binary(struct sc_card *card, unsigned int idx,
|
||||
|
@ -610,7 +610,7 @@ int sc_read_binary(struct sc_card *card, unsigned int idx,
|
|||
SC_FUNC_RETURN(card->ctx, 2, bytes_read);
|
||||
}
|
||||
r = card->ops->read_binary(card, idx, buf, count, flags);
|
||||
SC_FUNC_RETURN(card->ctx, 2, r);
|
||||
SC_FUNC_RETURN(card->ctx, 2, r);
|
||||
}
|
||||
|
||||
int sc_write_binary(struct sc_card *card, unsigned int idx,
|
||||
|
@ -652,7 +652,7 @@ int sc_write_binary(struct sc_card *card, unsigned int idx,
|
|||
SC_FUNC_RETURN(card->ctx, 2, bytes_written);
|
||||
}
|
||||
r = card->ops->write_binary(card, idx, buf, count, flags);
|
||||
SC_FUNC_RETURN(card->ctx, 2, r);
|
||||
SC_FUNC_RETURN(card->ctx, 2, r);
|
||||
}
|
||||
|
||||
int sc_update_binary(struct sc_card *card, unsigned int idx,
|
||||
|
@ -694,7 +694,7 @@ int sc_update_binary(struct sc_card *card, unsigned int idx,
|
|||
SC_FUNC_RETURN(card->ctx, 2, bytes_written);
|
||||
}
|
||||
r = card->ops->update_binary(card, idx, buf, count, flags);
|
||||
SC_FUNC_RETURN(card->ctx, 2, r);
|
||||
SC_FUNC_RETURN(card->ctx, 2, r);
|
||||
}
|
||||
|
||||
int sc_select_file(struct sc_card *card,
|
||||
|
@ -729,7 +729,7 @@ int sc_select_file(struct sc_card *card,
|
|||
/* Remember file path */
|
||||
if (r == 0 && file && *file)
|
||||
(*file)->path = *in_path;
|
||||
SC_FUNC_RETURN(card->ctx, 1, r);
|
||||
SC_FUNC_RETURN(card->ctx, 1, r);
|
||||
}
|
||||
|
||||
int sc_get_data(sc_card_t *card, unsigned int tag, u8 *buf, size_t len)
|
||||
|
@ -737,10 +737,10 @@ int sc_get_data(sc_card_t *card, unsigned int tag, u8 *buf, size_t len)
|
|||
int r;
|
||||
|
||||
sc_debug(card->ctx, "called, tag=%04x\n", tag);
|
||||
if (card->ops->get_data == NULL)
|
||||
if (card->ops->get_data == NULL)
|
||||
SC_FUNC_RETURN(card->ctx, 2, SC_ERROR_NOT_SUPPORTED);
|
||||
r = card->ops->get_data(card, tag, buf, len);
|
||||
SC_FUNC_RETURN(card->ctx, 1, r);
|
||||
SC_FUNC_RETURN(card->ctx, 1, r);
|
||||
}
|
||||
|
||||
int sc_put_data(sc_card_t *card, unsigned int tag, const u8 *buf, size_t len)
|
||||
|
@ -748,10 +748,10 @@ int sc_put_data(sc_card_t *card, unsigned int tag, const u8 *buf, size_t len)
|
|||
int r;
|
||||
|
||||
sc_debug(card->ctx, "called, tag=%04x\n", tag);
|
||||
if (card->ops->put_data == NULL)
|
||||
if (card->ops->put_data == NULL)
|
||||
SC_FUNC_RETURN(card->ctx, 2, SC_ERROR_NOT_SUPPORTED);
|
||||
r = card->ops->put_data(card, tag, buf, len);
|
||||
SC_FUNC_RETURN(card->ctx, 1, r);
|
||||
SC_FUNC_RETURN(card->ctx, 1, r);
|
||||
}
|
||||
|
||||
int sc_get_challenge(struct sc_card *card, u8 *rnd, size_t len)
|
||||
|
@ -760,10 +760,10 @@ int sc_get_challenge(struct sc_card *card, u8 *rnd, size_t len)
|
|||
|
||||
assert(card != NULL);
|
||||
SC_FUNC_CALLED(card->ctx, 2);
|
||||
if (card->ops->get_challenge == NULL)
|
||||
if (card->ops->get_challenge == NULL)
|
||||
SC_FUNC_RETURN(card->ctx, 2, SC_ERROR_NOT_SUPPORTED);
|
||||
r = card->ops->get_challenge(card, rnd, len);
|
||||
SC_FUNC_RETURN(card->ctx, 2, r);
|
||||
SC_FUNC_RETURN(card->ctx, 2, r);
|
||||
}
|
||||
|
||||
int sc_read_record(struct sc_card *card, unsigned int rec_nr, u8 *buf,
|
||||
|
@ -773,10 +773,10 @@ int sc_read_record(struct sc_card *card, unsigned int rec_nr, u8 *buf,
|
|||
|
||||
assert(card != NULL);
|
||||
SC_FUNC_CALLED(card->ctx, 2);
|
||||
if (card->ops->read_record == NULL)
|
||||
if (card->ops->read_record == NULL)
|
||||
SC_FUNC_RETURN(card->ctx, 2, SC_ERROR_NOT_SUPPORTED);
|
||||
r = card->ops->read_record(card, rec_nr, buf, count, flags);
|
||||
SC_FUNC_RETURN(card->ctx, 2, r);
|
||||
SC_FUNC_RETURN(card->ctx, 2, r);
|
||||
}
|
||||
|
||||
int sc_write_record(struct sc_card *card, unsigned int rec_nr, const u8 * buf,
|
||||
|
@ -786,10 +786,10 @@ int sc_write_record(struct sc_card *card, unsigned int rec_nr, const u8 * buf,
|
|||
|
||||
assert(card != NULL);
|
||||
SC_FUNC_CALLED(card->ctx, 2);
|
||||
if (card->ops->write_record == NULL)
|
||||
if (card->ops->write_record == NULL)
|
||||
SC_FUNC_RETURN(card->ctx, 2, SC_ERROR_NOT_SUPPORTED);
|
||||
r = card->ops->write_record(card, rec_nr, buf, count, flags);
|
||||
SC_FUNC_RETURN(card->ctx, 2, r);
|
||||
SC_FUNC_RETURN(card->ctx, 2, r);
|
||||
}
|
||||
|
||||
int sc_append_record(struct sc_card *card, const u8 * buf, size_t count,
|
||||
|
@ -799,10 +799,10 @@ int sc_append_record(struct sc_card *card, const u8 * buf, size_t count,
|
|||
|
||||
assert(card != NULL);
|
||||
SC_FUNC_CALLED(card->ctx, 2);
|
||||
if (card->ops->append_record == NULL)
|
||||
if (card->ops->append_record == NULL)
|
||||
SC_FUNC_RETURN(card->ctx, 2, SC_ERROR_NOT_SUPPORTED);
|
||||
r = card->ops->append_record(card, buf, count, flags);
|
||||
SC_FUNC_RETURN(card->ctx, 2, r);
|
||||
SC_FUNC_RETURN(card->ctx, 2, r);
|
||||
}
|
||||
|
||||
int sc_update_record(struct sc_card *card, unsigned int rec_nr, const u8 * buf,
|
||||
|
@ -812,10 +812,10 @@ int sc_update_record(struct sc_card *card, unsigned int rec_nr, const u8 * buf,
|
|||
|
||||
assert(card != NULL);
|
||||
SC_FUNC_CALLED(card->ctx, 2);
|
||||
if (card->ops->update_record == NULL)
|
||||
if (card->ops->update_record == NULL)
|
||||
SC_FUNC_RETURN(card->ctx, 2, SC_ERROR_NOT_SUPPORTED);
|
||||
r = card->ops->update_record(card, rec_nr, buf, count, flags);
|
||||
SC_FUNC_RETURN(card->ctx, 2, r);
|
||||
SC_FUNC_RETURN(card->ctx, 2, r);
|
||||
}
|
||||
|
||||
int sc_delete_record(struct sc_card *card, unsigned int rec_nr)
|
||||
|
@ -844,7 +844,7 @@ sc_card_ctl(struct sc_card *card, unsigned long cmd, void *args)
|
|||
|
||||
assert(card != NULL);
|
||||
SC_FUNC_CALLED(card->ctx, 2);
|
||||
if (card->ops->card_ctl != NULL)
|
||||
if (card->ops->card_ctl != NULL)
|
||||
r = card->ops->card_ctl(card, cmd, args);
|
||||
|
||||
/* suppress "not supported" error messages */
|
||||
|
@ -852,7 +852,7 @@ sc_card_ctl(struct sc_card *card, unsigned long cmd, void *args)
|
|||
sc_debug(card->ctx, "card_ctl(%lu) not supported\n", cmd);
|
||||
return r;
|
||||
}
|
||||
SC_FUNC_RETURN(card->ctx, 2, r);
|
||||
SC_FUNC_RETURN(card->ctx, 2, r);
|
||||
}
|
||||
|
||||
int _sc_card_add_algorithm(struct sc_card *card, const struct sc_algorithm_info *info)
|
||||
|
|
|
@ -64,7 +64,6 @@ static int ccid_build_verify_pin_block(u8 * buf, size_t * size, struct sc_pin_cm
|
|||
|
||||
if (!data->pin1.min_length || !data->pin1.max_length)
|
||||
return SC_ERROR_INVALID_ARGUMENTS;
|
||||
|
||||
buf[count++] = data->pin1.max_length; /* wPINMaxExtraDigit: max */
|
||||
buf[count++] = data->pin1.min_length; /* wPINMaxExtraDigit: min */
|
||||
|
||||
|
@ -95,7 +94,7 @@ static int ccid_build_verify_pin_block(u8 * buf, size_t * size, struct sc_pin_cm
|
|||
*
|
||||
* Otherwise we assume a proper APDU and CCID compatible operations
|
||||
* and the APDU is copied verbatim.
|
||||
*/
|
||||
*/
|
||||
if (data->pin1.length_offset > 4) {
|
||||
memcpy(&buf[count], apdu->data, apdu->datalen);
|
||||
count += apdu->datalen;
|
||||
|
@ -150,7 +149,7 @@ ccid_pin_cmd(struct sc_reader *reader, sc_slot_info_t * slot,
|
|||
|
||||
/* The slot must be manually locked, as the control does not pass through card.c
|
||||
* wrappers that lock the card (card_transmit is not OK in this case, as it assumes
|
||||
* a proper APDU as a parameter, not a arbitary binary blob to be sent to the reader)
|
||||
* a proper APDU as a parameter, not an arbitary binary blob to be sent to the reader)
|
||||
*/
|
||||
r = reader->ops->lock(reader, slot);
|
||||
SC_TEST_RET(reader->ctx, r, "CCID PIN: Could not lock!");
|
||||
|
|
|
@ -63,10 +63,8 @@ sc_pkcs15emu_esteid_init (sc_pkcs15_card_t * p15card)
|
|||
set_string (&p15card->label, "EstEID isikutunnistus");
|
||||
set_string (&p15card->manufacturer_id, "AS Sertifitseerimiskeskus");
|
||||
|
||||
select_esteid_df (card);
|
||||
|
||||
/* read the serial (document number) */
|
||||
sc_format_path ("5044", &tmppath);
|
||||
sc_format_path ("3f00eeee5044", &tmppath);
|
||||
tmppath.type = SC_PATH_TYPE_PATH;
|
||||
r = sc_select_file (card, &tmppath, NULL);
|
||||
SC_TEST_RET (card->ctx, r, "select esteid PD failed");
|
||||
|
|
|
@ -765,7 +765,7 @@ __sc_pkcs15_search_objects(sc_pkcs15_card_t *p15card,
|
|||
int sc_pkcs15_get_objects(struct sc_pkcs15_card *p15card, int type,
|
||||
struct sc_pkcs15_object **ret, int ret_size)
|
||||
{
|
||||
return sc_pkcs15_get_objects_cond(p15card, type, NULL, NULL, ret, ret_size);
|
||||
return sc_pkcs15_get_objects_cond(p15card, type, NULL, NULL, ret, ret_size);
|
||||
}
|
||||
|
||||
static int compare_obj_id(struct sc_pkcs15_object *obj, const sc_pkcs15_id_t *id)
|
||||
|
@ -1183,7 +1183,7 @@ int sc_pkcs15_parse_df(struct sc_pkcs15_card *p15card,
|
|||
{
|
||||
struct sc_context *ctx = p15card->card->ctx;
|
||||
u8 *buf;
|
||||
const u8 *p;
|
||||
const u8 *p;
|
||||
size_t bufsize;
|
||||
int r;
|
||||
struct sc_pkcs15_object *obj = NULL;
|
||||
|
|
|
@ -49,7 +49,7 @@ struct pkcs15_slot_data {
|
|||
attr->ulValueLen = size; \
|
||||
return CKR_BUFFER_TOO_SMALL; \
|
||||
} \
|
||||
attr->ulValueLen = size;
|
||||
attr->ulValueLen = size;
|
||||
|
||||
#define MAX_OBJECTS 64
|
||||
struct pkcs15_fw_data {
|
||||
|
@ -692,7 +692,7 @@ static CK_RV pkcs15_create_tokens(struct sc_pkcs11_card *p11card)
|
|||
struct pkcs15_any_object *obj = fw_data->objects[j];
|
||||
|
||||
if (!(obj->base.flags & SC_PKCS11_OBJECT_SEEN)) {
|
||||
sc_debug(context, "Object %d was not seen previously\n", j);
|
||||
sc_debug(context, "Object %d was not seen previously\n", j);
|
||||
if (!slot) {
|
||||
rv = pkcs15_create_slot(p11card, NULL, &slot);
|
||||
if (rv != CKR_OK)
|
||||
|
@ -719,7 +719,7 @@ static CK_RV pkcs15_create_tokens(struct sc_pkcs11_card *p11card)
|
|||
static CK_RV pkcs15_release_token(struct sc_pkcs11_card *p11card, void *fw_token)
|
||||
{
|
||||
unlock_card((struct pkcs15_fw_data *) p11card->fw_data);
|
||||
return CKR_OK;
|
||||
return CKR_OK;
|
||||
}
|
||||
|
||||
static CK_RV pkcs15_login(struct sc_pkcs11_card *p11card,
|
||||
|
@ -926,7 +926,7 @@ static CK_RV pkcs15_create_private_key(struct sc_pkcs11_card *p11card,
|
|||
case CKA_KEY_TYPE:
|
||||
case CKA_MODULUS_BITS:
|
||||
case CKA_PRIVATE:
|
||||
break;
|
||||
break;
|
||||
case CKA_LABEL:
|
||||
args.label = (char *) attr->pValue;
|
||||
break;
|
||||
|
@ -991,9 +991,9 @@ static CK_RV pkcs15_create_public_key(struct sc_pkcs11_card *p11card,
|
|||
struct pkcs15_any_object *key_any_obj;
|
||||
struct sc_pkcs15_object *key_obj;
|
||||
struct sc_pkcs15_pin_info *pin;
|
||||
CK_KEY_TYPE key_type;
|
||||
CK_KEY_TYPE key_type;
|
||||
struct sc_pkcs15_pubkey_rsa *rsa;
|
||||
int rc, rv;
|
||||
int rc, rv;
|
||||
|
||||
memset(&args, 0, sizeof(args));
|
||||
|
||||
|
@ -1022,7 +1022,7 @@ static CK_RV pkcs15_create_public_key(struct sc_pkcs11_card *p11card,
|
|||
case CKA_KEY_TYPE:
|
||||
case CKA_MODULUS_BITS:
|
||||
case CKA_PRIVATE:
|
||||
break;
|
||||
break;
|
||||
case CKA_LABEL:
|
||||
args.label = (char *) attr->pValue;
|
||||
break;
|
||||
|
@ -1100,7 +1100,7 @@ static CK_RV pkcs15_create_certificate(struct sc_pkcs11_card *p11card,
|
|||
switch (attr->type) {
|
||||
/* Skip attrs we already know or don't care for */
|
||||
case CKA_CLASS:
|
||||
break;
|
||||
break;
|
||||
case CKA_PRIVATE:
|
||||
rv = attr_extract(attr, &bValue, NULL);
|
||||
if (bValue) {
|
||||
|
@ -1153,7 +1153,7 @@ static CK_RV pkcs15_create_object(struct sc_pkcs11_card *p11card,
|
|||
{
|
||||
struct sc_profile *profile = NULL;
|
||||
CK_OBJECT_CLASS _class;
|
||||
int rv, rc;
|
||||
int rv, rc;
|
||||
|
||||
rv = attr_find(pTemplate, ulCount, CKA_CLASS, &_class, NULL);
|
||||
if (rv != CKR_OK)
|
||||
|
@ -1563,17 +1563,15 @@ static CK_RV pkcs15_cert_get_attribute(struct sc_pkcs11_session *session,
|
|||
memcpy(attr->pValue, cert->cert_data->data, cert->cert_data->data_len);
|
||||
break;
|
||||
case CKA_SERIAL_NUMBER:
|
||||
check_attribute_buffer(attr, cert->cert_data->serial_len);
|
||||
memcpy(attr->pValue, cert->cert_data->serial, cert->cert_data->serial_len);
|
||||
break;
|
||||
check_attribute_buffer(attr, cert->cert_data->serial_len);
|
||||
memcpy(attr->pValue, cert->cert_data->serial, cert->cert_data->serial_len);
|
||||
break;
|
||||
case CKA_SUBJECT:
|
||||
return asn1_sequence_wrapper(cert->cert_data->subject,
|
||||
cert->cert_data->subject_len,
|
||||
attr);
|
||||
return asn1_sequence_wrapper(cert->cert_data->subject,
|
||||
cert->cert_data->subject_len, attr);
|
||||
case CKA_ISSUER:
|
||||
return asn1_sequence_wrapper(cert->cert_data->issuer,
|
||||
cert->cert_data->issuer_len,
|
||||
attr);
|
||||
return asn1_sequence_wrapper(cert->cert_data->issuer,
|
||||
cert->cert_data->issuer_len, attr);
|
||||
default:
|
||||
return CKR_ATTRIBUTE_TYPE_INVALID;
|
||||
}
|
||||
|
@ -1892,8 +1890,7 @@ pkcs15_prkey_decrypt(struct sc_pkcs11_session *ses, void *obj,
|
|||
}
|
||||
|
||||
rv = sc_pkcs15_decipher(fw_data->p15_card, prkey->prv_p15obj,
|
||||
flags,
|
||||
pEncryptedData, ulEncryptedDataLen,
|
||||
flags, pEncryptedData, ulEncryptedDataLen,
|
||||
decrypted, sizeof(decrypted));
|
||||
|
||||
/* Do we have to try a re-login and then try to decrypt again? */
|
||||
|
@ -1901,8 +1898,7 @@ pkcs15_prkey_decrypt(struct sc_pkcs11_session *ses, void *obj,
|
|||
rv = revalidate_pin(data, ses);
|
||||
if (rv == 0)
|
||||
rv = sc_pkcs15_decipher(fw_data->p15_card, prkey->prv_p15obj,
|
||||
flags,
|
||||
pEncryptedData, ulEncryptedDataLen,
|
||||
flags, pEncryptedData, ulEncryptedDataLen,
|
||||
decrypted, sizeof(decrypted));
|
||||
}
|
||||
sc_unlock(ses->slot->card->card);
|
||||
|
@ -1989,7 +1985,7 @@ static CK_RV pkcs15_pubkey_get_attribute(struct sc_pkcs11_session *session,
|
|||
case CKA_CLASS:
|
||||
check_attribute_buffer(attr, sizeof(CK_OBJECT_CLASS));
|
||||
*(CK_OBJECT_CLASS*)attr->pValue = CKO_PUBLIC_KEY;
|
||||
break;
|
||||
break;
|
||||
case CKA_TOKEN:
|
||||
case CKA_LOCAL:
|
||||
case CKA_SENSITIVE:
|
||||
|
@ -1997,13 +1993,13 @@ static CK_RV pkcs15_pubkey_get_attribute(struct sc_pkcs11_session *session,
|
|||
case CKA_NEVER_EXTRACTABLE:
|
||||
check_attribute_buffer(attr, sizeof(CK_BBOOL));
|
||||
*(CK_BBOOL*)attr->pValue = TRUE;
|
||||
break;
|
||||
break;
|
||||
case CKA_PRIVATE:
|
||||
case CKA_MODIFIABLE:
|
||||
case CKA_EXTRACTABLE:
|
||||
check_attribute_buffer(attr, sizeof(CK_BBOOL));
|
||||
*(CK_BBOOL*)attr->pValue = FALSE;
|
||||
break;
|
||||
break;
|
||||
case CKA_LABEL:
|
||||
if (pubkey->pub_p15obj) {
|
||||
len = strlen(pubkey->pub_p15obj->label);
|
||||
|
@ -2019,8 +2015,8 @@ static CK_RV pkcs15_pubkey_get_attribute(struct sc_pkcs11_session *session,
|
|||
break;
|
||||
case CKA_KEY_TYPE:
|
||||
check_attribute_buffer(attr, sizeof(CK_KEY_TYPE));
|
||||
*(CK_KEY_TYPE*)attr->pValue = CKK_RSA;
|
||||
break;
|
||||
*(CK_KEY_TYPE*)attr->pValue = CKK_RSA;
|
||||
break;
|
||||
case CKA_ID:
|
||||
if (pubkey->pub_info) {
|
||||
check_attribute_buffer(attr, pubkey->pub_info->id.len);
|
||||
|
@ -2031,10 +2027,10 @@ static CK_RV pkcs15_pubkey_get_attribute(struct sc_pkcs11_session *session,
|
|||
} else {
|
||||
return CKR_ATTRIBUTE_TYPE_INVALID;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case CKA_KEY_GEN_MECHANISM:
|
||||
check_attribute_buffer(attr, sizeof(CK_MECHANISM_TYPE));
|
||||
*(CK_MECHANISM_TYPE*)attr->pValue = CK_UNAVAILABLE_INFORMATION;
|
||||
*(CK_MECHANISM_TYPE*)attr->pValue = CK_UNAVAILABLE_INFORMATION;
|
||||
break;
|
||||
case CKA_ENCRYPT:
|
||||
case CKA_DECRYPT:
|
||||
|
@ -2180,7 +2176,7 @@ static CK_RV pkcs15_dobj_get_attribute(struct sc_pkcs11_session *session,
|
|||
case CKA_ID:
|
||||
check_attribute_buffer(attr, dobj->info->id.len);
|
||||
memcpy(attr->pValue, dobj->info->id.value, dobj->info->id.len);
|
||||
break;
|
||||
break;
|
||||
#endif
|
||||
case CKA_OBJECT_ID:
|
||||
{
|
||||
|
@ -2189,7 +2185,7 @@ static CK_RV pkcs15_dobj_get_attribute(struct sc_pkcs11_session *session,
|
|||
check_attribute_buffer(attr, len);
|
||||
memcpy(attr->pValue, dobj->info->app_oid.value, len);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case CKA_VALUE:
|
||||
{
|
||||
CK_RV rv;
|
||||
|
@ -2227,7 +2223,6 @@ struct sc_pkcs11_object_ops pkcs15_dobj_ops = {
|
|||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* get_attribute helpers
|
||||
*/
|
||||
|
|
|
@ -145,7 +145,7 @@ CK_RV pool_find_and_delete(struct sc_pkcs11_pool *pool, CK_ULONG handle, void **
|
|||
if (item->prev) item->prev->next = item->next;
|
||||
if (item->next) item->next->prev = item->prev;
|
||||
if (pool->head == item) pool->head = item->next;
|
||||
if (pool->tail == item) pool->tail = item->prev;
|
||||
if (pool->tail == item) pool->tail = item->prev;
|
||||
|
||||
*item_ptr = item->item;
|
||||
free(item);
|
||||
|
|
|
@ -48,11 +48,11 @@ CK_RV C_Initialize(CK_VOID_PTR pReserved)
|
|||
load_pkcs11_parameters(&sc_pkcs11_conf, context);
|
||||
|
||||
first_free_slot = 0;
|
||||
pool_initialize(&session_pool, POOL_TYPE_SESSION);
|
||||
pool_initialize(&session_pool, POOL_TYPE_SESSION);
|
||||
for (i=0; i<SC_PKCS11_MAX_VIRTUAL_SLOTS; i++)
|
||||
slot_initialize(i, &virtual_slots[i]);
|
||||
slot_initialize(i, &virtual_slots[i]);
|
||||
for (i=0; i<SC_PKCS11_MAX_READERS; i++)
|
||||
card_initialize(i);
|
||||
card_initialize(i);
|
||||
|
||||
/* Detect any card, but do not flag "insert" events */
|
||||
__card_detect_all(0);
|
||||
|
|
|
@ -40,7 +40,7 @@ CK_RV C_CreateObject(CK_SESSION_HANDLE hSession, /* the session's handle */
|
|||
rv = sc_pkcs11_lock();
|
||||
if (rv != CKR_OK)
|
||||
return rv;
|
||||
dump_template("C_CreateObject()", pTemplate, ulCount);
|
||||
dump_template("C_CreateObject()", pTemplate, ulCount);
|
||||
|
||||
rv = pool_find(&session_pool, hSession, (void**) &session);
|
||||
if (rv != CKR_OK)
|
||||
|
@ -316,7 +316,7 @@ CK_RV C_FindObjects(CK_SESSION_HANDLE hSession, /* the session's han
|
|||
&operation->handles[operation->current_handle],
|
||||
to_return * sizeof(CK_OBJECT_HANDLE));
|
||||
|
||||
operation->current_handle += to_return;
|
||||
operation->current_handle += to_return;
|
||||
|
||||
out: sc_pkcs11_unlock();
|
||||
return rv;
|
||||
|
@ -361,10 +361,10 @@ CK_RV C_DigestInit(CK_SESSION_HANDLE hSession, /* the session's handle */
|
|||
rv = pool_find(&session_pool, hSession, (void**) &session);
|
||||
if (rv == CKR_OK)
|
||||
rv = sc_pkcs11_md_init(session, pMechanism);
|
||||
sc_debug(context, "C_DigestInit returns %d\n", rv);
|
||||
sc_debug(context, "C_DigestInit returns %d\n", rv);
|
||||
|
||||
sc_pkcs11_unlock();
|
||||
return rv;
|
||||
return rv;
|
||||
}
|
||||
|
||||
CK_RV C_Digest(CK_SESSION_HANDLE hSession, /* the session's handle */
|
||||
|
@ -391,7 +391,7 @@ CK_RV C_Digest(CK_SESSION_HANDLE hSession, /* the session's handle */
|
|||
out: sc_debug(context, "C_Digest returns %d\n", rv);
|
||||
sc_pkcs11_unlock();
|
||||
|
||||
return rv;
|
||||
return rv;
|
||||
}
|
||||
|
||||
CK_RV C_DigestUpdate(CK_SESSION_HANDLE hSession, /* the session's handle */
|
||||
|
@ -409,15 +409,15 @@ CK_RV C_DigestUpdate(CK_SESSION_HANDLE hSession, /* the session's handle */
|
|||
if (rv == CKR_OK)
|
||||
rv = sc_pkcs11_md_update(session, pPart, ulPartLen);
|
||||
|
||||
sc_debug(context, "C_DigestUpdate returns %d\n", rv);
|
||||
sc_debug(context, "C_DigestUpdate returns %d\n", rv);
|
||||
sc_pkcs11_unlock();
|
||||
return rv;
|
||||
return rv;
|
||||
}
|
||||
|
||||
CK_RV C_DigestKey(CK_SESSION_HANDLE hSession, /* the session's handle */
|
||||
CK_OBJECT_HANDLE hKey) /* handle of secret key to digest */
|
||||
{
|
||||
return CKR_FUNCTION_NOT_SUPPORTED;
|
||||
return CKR_FUNCTION_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
CK_RV C_DigestFinal(CK_SESSION_HANDLE hSession, /* the session's handle */
|
||||
|
@ -435,9 +435,9 @@ CK_RV C_DigestFinal(CK_SESSION_HANDLE hSession, /* the session's handle */
|
|||
if (rv == CKR_OK)
|
||||
rv = sc_pkcs11_md_final(session, pDigest, pulDigestLen);
|
||||
|
||||
sc_debug(context, "C_DigestFinal returns %d\n", rv);
|
||||
sc_debug(context, "C_DigestFinal returns %d\n", rv);
|
||||
sc_pkcs11_unlock();
|
||||
return rv;
|
||||
return rv;
|
||||
}
|
||||
|
||||
CK_RV C_SignInit(CK_SESSION_HANDLE hSession, /* the session's handle */
|
||||
|
@ -465,18 +465,18 @@ CK_RV C_SignInit(CK_SESSION_HANDLE hSession, /* the session's handle */
|
|||
goto out;
|
||||
|
||||
if (object->ops->sign == NULL_PTR) {
|
||||
rv = CKR_KEY_TYPE_INCONSISTENT;
|
||||
rv = CKR_KEY_TYPE_INCONSISTENT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
rv = object->ops->get_attribute(session, object, &sign_attribute);
|
||||
if (rv != CKR_OK || !can_sign) {
|
||||
rv = CKR_KEY_TYPE_INCONSISTENT;
|
||||
if (rv != CKR_OK || !can_sign) {
|
||||
rv = CKR_KEY_TYPE_INCONSISTENT;
|
||||
goto out;
|
||||
}
|
||||
rv = object->ops->get_attribute(session, object, &key_type_attr);
|
||||
if (rv != CKR_OK) {
|
||||
rv = CKR_KEY_TYPE_INCONSISTENT;
|
||||
if (rv != CKR_OK) {
|
||||
rv = CKR_KEY_TYPE_INCONSISTENT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -485,7 +485,7 @@ CK_RV C_SignInit(CK_SESSION_HANDLE hSession, /* the session's handle */
|
|||
out: sc_debug(context, "Sign initialization returns %d\n", rv);
|
||||
sc_pkcs11_unlock();
|
||||
|
||||
return rv;
|
||||
return rv;
|
||||
}
|
||||
|
||||
CK_RV C_Sign(CK_SESSION_HANDLE hSession, /* the session's handle */
|
||||
|
@ -526,7 +526,7 @@ CK_RV C_Sign(CK_SESSION_HANDLE hSession, /* the session's handle */
|
|||
|
||||
out: sc_debug(context, "Signing result was %d\n", rv);
|
||||
sc_pkcs11_unlock();
|
||||
return rv;
|
||||
return rv;
|
||||
}
|
||||
|
||||
CK_RV C_SignUpdate(CK_SESSION_HANDLE hSession, /* the session's handle */
|
||||
|
@ -583,14 +583,14 @@ CK_RV C_SignFinal(CK_SESSION_HANDLE hSession, /* the session's handle */
|
|||
out: sc_debug(context, "C_SignFinal returns %d\n", rv);
|
||||
sc_pkcs11_unlock();
|
||||
|
||||
return rv;
|
||||
return rv;
|
||||
}
|
||||
|
||||
CK_RV C_SignRecoverInit(CK_SESSION_HANDLE hSession, /* the session's handle */
|
||||
CK_MECHANISM_PTR pMechanism, /* the signature mechanism */
|
||||
CK_OBJECT_HANDLE hKey) /* handle of the signature key */
|
||||
{
|
||||
CK_BBOOL can_sign;
|
||||
CK_BBOOL can_sign;
|
||||
CK_KEY_TYPE key_type;
|
||||
CK_ATTRIBUTE sign_attribute = { CKA_SIGN, &can_sign, sizeof(can_sign) };
|
||||
CK_ATTRIBUTE key_type_attr = { CKA_KEY_TYPE, &key_type, sizeof(key_type) };
|
||||
|
@ -611,30 +611,30 @@ CK_RV C_SignRecoverInit(CK_SESSION_HANDLE hSession, /* the session's handle */
|
|||
goto out;
|
||||
|
||||
if (object->ops->sign == NULL_PTR) {
|
||||
rv = CKR_KEY_TYPE_INCONSISTENT;
|
||||
rv = CKR_KEY_TYPE_INCONSISTENT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
rv = object->ops->get_attribute(session, object, &sign_attribute);
|
||||
if (rv != CKR_OK || !can_sign) {
|
||||
rv = CKR_KEY_TYPE_INCONSISTENT;
|
||||
if (rv != CKR_OK || !can_sign) {
|
||||
rv = CKR_KEY_TYPE_INCONSISTENT;
|
||||
goto out;
|
||||
}
|
||||
rv = object->ops->get_attribute(session, object, &key_type_attr);
|
||||
if (rv != CKR_OK) {
|
||||
rv = CKR_KEY_TYPE_INCONSISTENT;
|
||||
if (rv != CKR_OK) {
|
||||
rv = CKR_KEY_TYPE_INCONSISTENT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* XXX: need to tell the signature algorithm that we want
|
||||
* to recover the signature */
|
||||
sc_debug(context, "SignRecover operation initialized\n");
|
||||
sc_debug(context, "SignRecover operation initialized\n");
|
||||
|
||||
rv = sc_pkcs11_sign_init(session, pMechanism, object, key_type);
|
||||
|
||||
out: sc_debug(context, "Sign initialization returns %d\n", rv);
|
||||
sc_pkcs11_unlock();
|
||||
return rv;
|
||||
return rv;
|
||||
}
|
||||
|
||||
CK_RV C_SignRecover(CK_SESSION_HANDLE hSession, /* the session's handle */
|
||||
|
@ -643,14 +643,14 @@ CK_RV C_SignRecover(CK_SESSION_HANDLE hSession, /* the session's handle *
|
|||
CK_BYTE_PTR pSignature, /* receives the signature */
|
||||
CK_ULONG_PTR pulSignatureLen) /* receives byte count of signature */
|
||||
{
|
||||
return CKR_FUNCTION_NOT_SUPPORTED;
|
||||
return CKR_FUNCTION_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
CK_RV C_EncryptInit(CK_SESSION_HANDLE hSession, /* the session's handle */
|
||||
CK_MECHANISM_PTR pMechanism, /* the encryption mechanism */
|
||||
CK_OBJECT_HANDLE hKey) /* handle of encryption key */
|
||||
{
|
||||
return CKR_FUNCTION_NOT_SUPPORTED;
|
||||
return CKR_FUNCTION_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
CK_RV C_Encrypt(CK_SESSION_HANDLE hSession, /* the session's handle */
|
||||
|
@ -659,7 +659,7 @@ CK_RV C_Encrypt(CK_SESSION_HANDLE hSession, /* the session's handle *
|
|||
CK_BYTE_PTR pEncryptedData, /* receives encrypted data */
|
||||
CK_ULONG_PTR pulEncryptedDataLen) /* receives encrypted byte count */
|
||||
{
|
||||
return CKR_FUNCTION_NOT_SUPPORTED;
|
||||
return CKR_FUNCTION_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
CK_RV C_EncryptUpdate(CK_SESSION_HANDLE hSession, /* the session's handle */
|
||||
|
@ -668,14 +668,14 @@ CK_RV C_EncryptUpdate(CK_SESSION_HANDLE hSession, /* the session's han
|
|||
CK_BYTE_PTR pEncryptedPart, /* receives encrypted data */
|
||||
CK_ULONG_PTR pulEncryptedPartLen)/* receives encrypted byte count */
|
||||
{
|
||||
return CKR_FUNCTION_NOT_SUPPORTED;
|
||||
return CKR_FUNCTION_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
CK_RV C_EncryptFinal(CK_SESSION_HANDLE hSession, /* the session's handle */
|
||||
CK_BYTE_PTR pLastEncryptedPart, /* receives encrypted last part */
|
||||
CK_ULONG_PTR pulLastEncryptedPartLen) /* receives byte count */
|
||||
{
|
||||
return CKR_FUNCTION_NOT_SUPPORTED;
|
||||
return CKR_FUNCTION_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
CK_RV C_DecryptInit(CK_SESSION_HANDLE hSession, /* the session's handle */
|
||||
|
@ -703,18 +703,18 @@ CK_RV C_DecryptInit(CK_SESSION_HANDLE hSession, /* the session's handle */
|
|||
goto out;
|
||||
|
||||
if (object->ops->decrypt == NULL_PTR) {
|
||||
rv = CKR_KEY_TYPE_INCONSISTENT;
|
||||
rv = CKR_KEY_TYPE_INCONSISTENT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
rv = object->ops->get_attribute(session, object, &decrypt_attribute);
|
||||
if (rv != CKR_OK || !can_decrypt) {
|
||||
rv = CKR_KEY_TYPE_INCONSISTENT;
|
||||
if (rv != CKR_OK || !can_decrypt) {
|
||||
rv = CKR_KEY_TYPE_INCONSISTENT;
|
||||
goto out;
|
||||
}
|
||||
rv = object->ops->get_attribute(session, object, &key_type_attr);
|
||||
if (rv != CKR_OK) {
|
||||
rv = CKR_KEY_TYPE_INCONSISTENT;
|
||||
if (rv != CKR_OK) {
|
||||
rv = CKR_KEY_TYPE_INCONSISTENT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -828,10 +828,10 @@ CK_RV C_GenerateKeyPair(CK_SESSION_HANDLE hSession, /* the
|
|||
rv = sc_pkcs11_lock();
|
||||
if (rv != CKR_OK)
|
||||
return rv;
|
||||
dump_template("C_CreateObject(), PrivKey attrs", pPrivateKeyTemplate, ulPrivateKeyAttributeCount);
|
||||
dump_template("C_CreateObject(), PubKey attrs", pPublicKeyTemplate, ulPublicKeyAttributeCount);
|
||||
dump_template("C_CreateObject(), PrivKey attrs", pPrivateKeyTemplate, ulPrivateKeyAttributeCount);
|
||||
dump_template("C_CreateObject(), PubKey attrs", pPublicKeyTemplate, ulPublicKeyAttributeCount);
|
||||
|
||||
rv = pool_find(&session_pool, hSession, (void**) &session);
|
||||
rv = pool_find(&session_pool, hSession, (void**) &session);
|
||||
if (rv != CKR_OK)
|
||||
goto out;
|
||||
|
||||
|
@ -886,7 +886,7 @@ CK_RV C_UnwrapKey(CK_SESSION_HANDLE hSession, /* the session's handl
|
|||
goto out;
|
||||
|
||||
if (object->ops->sign == NULL_PTR) {
|
||||
rv = CKR_KEY_TYPE_INCONSISTENT;
|
||||
rv = CKR_KEY_TYPE_INCONSISTENT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -978,7 +978,7 @@ CK_RV C_VerifyInit(CK_SESSION_HANDLE hSession, /* the session's handle */
|
|||
return CKR_FUNCTION_NOT_SUPPORTED;
|
||||
#else
|
||||
#if 0
|
||||
CK_BBOOL can_verify;
|
||||
CK_BBOOL can_verify;
|
||||
CK_ATTRIBUTE verify_attribute = { CKA_VERIFY, &can_verify, sizeof(can_verify) };
|
||||
#endif
|
||||
CK_KEY_TYPE key_type;
|
||||
|
@ -1001,14 +1001,14 @@ CK_RV C_VerifyInit(CK_SESSION_HANDLE hSession, /* the session's handle */
|
|||
|
||||
#if 0
|
||||
rv = object->ops->get_attribute(session, object, &verify_attribute);
|
||||
if (rv != CKR_OK || !can_verify) {
|
||||
rv = CKR_KEY_TYPE_INCONSISTENT;
|
||||
if (rv != CKR_OK || !can_verify) {
|
||||
rv = CKR_KEY_TYPE_INCONSISTENT;
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
rv = object->ops->get_attribute(session, object, &key_type_attr);
|
||||
if (rv != CKR_OK) {
|
||||
rv = CKR_KEY_TYPE_INCONSISTENT;
|
||||
if (rv != CKR_OK) {
|
||||
rv = CKR_KEY_TYPE_INCONSISTENT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ CK_RV C_OpenSession(CK_SLOT_ID slotID, /* the slot's ID */
|
|||
CK_SESSION_HANDLE_PTR phSession) /* receives new session handle */
|
||||
{
|
||||
struct sc_pkcs11_slot *slot;
|
||||
struct sc_pkcs11_session *session;
|
||||
struct sc_pkcs11_session *session;
|
||||
int rv;
|
||||
|
||||
rv = sc_pkcs11_lock();
|
||||
|
@ -49,7 +49,7 @@ CK_RV C_OpenSession(CK_SLOT_ID slotID, /* the slot's ID */
|
|||
goto out;
|
||||
}
|
||||
|
||||
rv = slot_get_token(slotID, &slot);
|
||||
rv = slot_get_token(slotID, &slot);
|
||||
if (rv != CKR_OK)
|
||||
goto out;
|
||||
|
||||
|
@ -85,7 +85,7 @@ out: sc_pkcs11_unlock();
|
|||
static CK_RV sc_pkcs11_close_session(CK_SESSION_HANDLE hSession)
|
||||
{
|
||||
struct sc_pkcs11_slot *slot;
|
||||
struct sc_pkcs11_session *session;
|
||||
struct sc_pkcs11_session *session;
|
||||
int rv;
|
||||
|
||||
rv = pool_find_and_delete(&session_pool, hSession, (void**) &session);
|
||||
|
@ -178,8 +178,8 @@ CK_RV C_GetSessionInfo(CK_SESSION_HANDLE hSession, /* the session's handle */
|
|||
|
||||
sc_debug(context, "C_GetSessionInfo(slot %d).\n", session->slot->id);
|
||||
pInfo->slotID = session->slot->id;
|
||||
pInfo->flags = session->flags;
|
||||
pInfo->ulDeviceError = 0;
|
||||
pInfo->flags = session->flags;
|
||||
pInfo->ulDeviceError = 0;
|
||||
|
||||
slot = session->slot;
|
||||
if (slot->login_user == CKU_SO) {
|
||||
|
@ -211,7 +211,7 @@ CK_RV C_SetOperationState(CK_SESSION_HANDLE hSession, /* the session'
|
|||
CK_OBJECT_HANDLE hEncryptionKey, /* handle of en/decryption key */
|
||||
CK_OBJECT_HANDLE hAuthenticationKey) /* handle of sign/verify key */
|
||||
{
|
||||
return CKR_FUNCTION_NOT_SUPPORTED;
|
||||
return CKR_FUNCTION_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
CK_RV C_Login(CK_SESSION_HANDLE hSession, /* the session's handle */
|
||||
|
@ -228,7 +228,7 @@ CK_RV C_Login(CK_SESSION_HANDLE hSession, /* the session's handle */
|
|||
return rv;
|
||||
|
||||
if (userType != CKU_USER && userType != CKU_SO) {
|
||||
rv = CKR_USER_TYPE_INVALID;
|
||||
rv = CKR_USER_TYPE_INVALID;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -246,7 +246,7 @@ CK_RV C_Login(CK_SESSION_HANDLE hSession, /* the session's handle */
|
|||
}
|
||||
|
||||
if (slot->login_user >= 0) {
|
||||
rv = CKR_USER_ALREADY_LOGGED_IN;
|
||||
rv = CKR_USER_ALREADY_LOGGED_IN;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,9 +61,9 @@ struct sc_pkcs11_card;
|
|||
/* Object Pool */
|
||||
struct sc_pkcs11_pool_item {
|
||||
int handle;
|
||||
void *item;
|
||||
void *item;
|
||||
struct sc_pkcs11_pool_item *next;
|
||||
struct sc_pkcs11_pool_item *prev;
|
||||
struct sc_pkcs11_pool_item *prev;
|
||||
};
|
||||
|
||||
enum {
|
||||
|
@ -73,10 +73,10 @@ enum {
|
|||
|
||||
struct sc_pkcs11_pool {
|
||||
int type;
|
||||
int next_free_handle;
|
||||
int next_free_handle;
|
||||
int num_items;
|
||||
struct sc_pkcs11_pool_item *head;
|
||||
struct sc_pkcs11_pool_item *tail;
|
||||
struct sc_pkcs11_pool_item *tail;
|
||||
};
|
||||
|
||||
struct sc_pkcs11_config {
|
||||
|
@ -92,16 +92,16 @@ struct sc_pkcs11_config {
|
|||
*/
|
||||
|
||||
struct sc_pkcs11_object_ops {
|
||||
/* Generic operations */
|
||||
void (*release)(void *);
|
||||
/* Generic operations */
|
||||
void (*release)(void *);
|
||||
|
||||
/* Management methods */
|
||||
/* Management methods */
|
||||
CK_RV (*set_attribute)(struct sc_pkcs11_session *, void *, CK_ATTRIBUTE_PTR);
|
||||
CK_RV (*get_attribute)(struct sc_pkcs11_session *, void *, CK_ATTRIBUTE_PTR);
|
||||
int (*cmp_attribute)(struct sc_pkcs11_session *, void *, CK_ATTRIBUTE_PTR);
|
||||
|
||||
CK_RV (*destroy_object)(struct sc_pkcs11_session *, void *);
|
||||
CK_RV (*get_size)(struct sc_pkcs11_session *, void *);
|
||||
CK_RV (*get_size)(struct sc_pkcs11_session *, void *);
|
||||
|
||||
/* Cryptographic methods */
|
||||
CK_RV (*sign)(struct sc_pkcs11_session *, void *,
|
||||
|
@ -118,12 +118,12 @@ struct sc_pkcs11_object_ops {
|
|||
CK_BYTE_PTR pEncryptedData, CK_ULONG ulEncryptedDataLen,
|
||||
CK_BYTE_PTR pData, CK_ULONG_PTR pulDataLen);
|
||||
|
||||
/* Others to be added when implemented */
|
||||
/* Others to be added when implemented */
|
||||
};
|
||||
|
||||
struct sc_pkcs11_object {
|
||||
int flags;
|
||||
struct sc_pkcs11_object_ops *ops;
|
||||
struct sc_pkcs11_object_ops *ops;
|
||||
};
|
||||
|
||||
#define SC_PKCS11_OBJECT_SEEN 0x0001
|
||||
|
@ -136,20 +136,20 @@ struct sc_pkcs11_object {
|
|||
*/
|
||||
|
||||
struct sc_pkcs11_framework_ops {
|
||||
/* Detect and bind card to framework */
|
||||
/* Detect and bind card to framework */
|
||||
CK_RV (*bind)(struct sc_pkcs11_card *);
|
||||
/* Unbind and release allocated resources */
|
||||
/* Unbind and release allocated resources */
|
||||
CK_RV (*unbind)(struct sc_pkcs11_card *);
|
||||
|
||||
/* Create tokens to virtual slots and
|
||||
* objects in tokens; called after bind */
|
||||
CK_RV (*create_tokens)(struct sc_pkcs11_card *);
|
||||
CK_RV (*release_token)(struct sc_pkcs11_card *, void *);
|
||||
CK_RV (*release_token)(struct sc_pkcs11_card *, void *);
|
||||
|
||||
/* Login and logout */
|
||||
CK_RV (*login)(struct sc_pkcs11_card *, void *,
|
||||
CK_USER_TYPE, CK_CHAR_PTR, CK_ULONG);
|
||||
CK_RV (*logout)(struct sc_pkcs11_card *, void *);
|
||||
CK_RV (*logout)(struct sc_pkcs11_card *, void *);
|
||||
CK_RV (*change_pin)(struct sc_pkcs11_card *, void *,
|
||||
CK_CHAR_PTR, CK_ULONG,
|
||||
CK_CHAR_PTR, CK_ULONG);
|
||||
|
@ -157,7 +157,7 @@ struct sc_pkcs11_framework_ops {
|
|||
/*
|
||||
* In future: functions to create new objects
|
||||
* (ie. certificates, private keys)
|
||||
*/
|
||||
*/
|
||||
CK_RV (*init_token)(struct sc_pkcs11_card *, void *,
|
||||
CK_UTF8CHAR_PTR, CK_ULONG,
|
||||
CK_UTF8CHAR_PTR);
|
||||
|
@ -182,9 +182,9 @@ struct sc_pkcs11_framework_ops {
|
|||
*/
|
||||
|
||||
struct sc_pkcs11_card {
|
||||
int reader;
|
||||
int reader;
|
||||
struct sc_card *card;
|
||||
struct sc_pkcs11_framework_ops *framework;
|
||||
struct sc_pkcs11_framework_ops *framework;
|
||||
void *fw_data;
|
||||
sc_timestamp_t slot_state_expires;
|
||||
|
||||
|
@ -200,17 +200,17 @@ struct sc_pkcs11_card {
|
|||
|
||||
struct sc_pkcs11_slot {
|
||||
int id;
|
||||
int login_user;
|
||||
/* Slot specific information (information about reader) */
|
||||
int login_user;
|
||||
/* Slot specific information (information about reader) */
|
||||
CK_SLOT_INFO slot_info;
|
||||
/* Token specific information (information about card) */
|
||||
CK_TOKEN_INFO token_info;
|
||||
CK_TOKEN_INFO token_info;
|
||||
|
||||
/* Reader to which card is allocated (same as card->reader
|
||||
* if there's a card present) */
|
||||
int reader;
|
||||
|
||||
/* The card associated with this slot */
|
||||
/* The card associated with this slot */
|
||||
struct sc_pkcs11_card *card;
|
||||
/* Card events SC_EVENT_CARD_{INSERTED,REMOVED} */
|
||||
int events;
|
||||
|
@ -293,8 +293,8 @@ struct sc_pkcs11_operation {
|
|||
#define SC_PKCS11_FIND_MAX_HANDLES 32
|
||||
struct sc_pkcs11_find_operation {
|
||||
struct sc_pkcs11_operation operation;
|
||||
int num_handles, current_handle;
|
||||
CK_OBJECT_HANDLE handles[SC_PKCS11_FIND_MAX_HANDLES];
|
||||
int num_handles, current_handle;
|
||||
CK_OBJECT_HANDLE handles[SC_PKCS11_FIND_MAX_HANDLES];
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -304,10 +304,10 @@ struct sc_pkcs11_find_operation {
|
|||
struct sc_pkcs11_session {
|
||||
/* Session to this slot */
|
||||
struct sc_pkcs11_slot *slot;
|
||||
CK_FLAGS flags;
|
||||
CK_FLAGS flags;
|
||||
/* Notifications */
|
||||
CK_NOTIFY notify_callback;
|
||||
CK_VOID_PTR notify_data;
|
||||
CK_VOID_PTR notify_data;
|
||||
/* Active operations - one per type */
|
||||
struct sc_pkcs11_operation *operation[SC_PKCS11_OPERATION_MAX];
|
||||
};
|
||||
|
|
|
@ -22,11 +22,11 @@
|
|||
#include "sc-pkcs11.h"
|
||||
|
||||
static struct sc_pkcs11_framework_ops *frameworks[] = {
|
||||
&framework_pkcs15,
|
||||
&framework_pkcs15,
|
||||
#ifdef USE_PKCS15_INIT
|
||||
/* This should be the last framework, because it
|
||||
* will assume the card is blank and try to initialize it */
|
||||
&framework_pkcs15init,
|
||||
&framework_pkcs15init,
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
@ -241,7 +241,7 @@ CK_RV slot_allocate(struct sc_pkcs11_slot **slot, struct sc_pkcs11_card *card)
|
|||
CK_RV slot_get_slot(int id, struct sc_pkcs11_slot **slot)
|
||||
{
|
||||
if (context == NULL)
|
||||
return CKR_CRYPTOKI_NOT_INITIALIZED;
|
||||
return CKR_CRYPTOKI_NOT_INITIALIZED;
|
||||
|
||||
if (id < 0 || id >= SC_PKCS11_MAX_VIRTUAL_SLOTS)
|
||||
return CKR_SLOT_ID_INVALID;
|
||||
|
|
|
@ -79,7 +79,7 @@ int opensc_init(void)
|
|||
if (r)
|
||||
goto err;
|
||||
return 1;
|
||||
err:
|
||||
err:
|
||||
/* need to do engine stuff? */
|
||||
fprintf(stderr, "error: %d", r);
|
||||
opensc_finish();
|
||||
|
@ -178,7 +178,7 @@ int sc_prkey_op_init(const RSA * rsa, struct sc_pkcs15_object **key_obj_out,
|
|||
}
|
||||
*key_obj_out = key_obj;
|
||||
return 0;
|
||||
err:
|
||||
err:
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -352,7 +352,7 @@ sc_private_decrypt(int flen, const unsigned char * from, unsigned char * to,
|
|||
goto err;
|
||||
}
|
||||
return r;
|
||||
err:
|
||||
err:
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -386,7 +386,7 @@ sc_sign(int type, const unsigned char * m, unsigned int m_len,
|
|||
}
|
||||
*siglen = r;
|
||||
return 1;
|
||||
err:
|
||||
err:
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ ambiguous_match(struct command *table, const char *cmd)
|
|||
int matches = 0;
|
||||
|
||||
for (; table->name; table++) {
|
||||
if (strncasecmp(cmd, table->name, strlen(cmd)) == 0) {
|
||||
if (strncasecmp(cmd, table->name, strlen(cmd)) == 0) {
|
||||
last_match = table;
|
||||
matches++;
|
||||
}
|
||||
|
@ -154,12 +154,12 @@ static void print_file(const struct sc_file *file)
|
|||
if (file->type == SC_FILE_TYPE_DF)
|
||||
printf("[");
|
||||
else
|
||||
printf(" ");
|
||||
printf(" ");
|
||||
printf("%02X%02X", file->id >> 8, file->id & 0xFF);
|
||||
if (file->type == SC_FILE_TYPE_DF)
|
||||
printf("]");
|
||||
else
|
||||
printf(" ");
|
||||
printf(" ");
|
||||
switch (file->type) {
|
||||
case SC_FILE_TYPE_WORKING_EF:
|
||||
st = "wEF";
|
||||
|
@ -175,12 +175,12 @@ static void print_file(const struct sc_file *file)
|
|||
break;
|
||||
}
|
||||
printf("\t%4s", st);
|
||||
printf(" %5d", file->size);
|
||||
printf(" %5d", file->size);
|
||||
if (file->namelen) {
|
||||
printf("\tName: ");
|
||||
print_binary(stdout, file->name, file->namelen);
|
||||
}
|
||||
printf("\n");
|
||||
printf("\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -189,15 +189,15 @@ static int do_ls(int argc, char **argv)
|
|||
u8 buf[256], *cur = buf;
|
||||
int r, count;
|
||||
|
||||
if (argc)
|
||||
goto usage;
|
||||
if (argc)
|
||||
goto usage;
|
||||
r = sc_list_files(card, buf, sizeof(buf));
|
||||
if (r < 0) {
|
||||
check_ret(r, SC_AC_OP_LIST_FILES, "unable to receive file listing", current_file);
|
||||
return -1;
|
||||
}
|
||||
count = r;
|
||||
printf("FileID\tType Size\n");
|
||||
printf("FileID\tType Size\n");
|
||||
while (count >= 2) {
|
||||
struct sc_path path;
|
||||
struct sc_file *file = NULL;
|
||||
|
@ -210,17 +210,17 @@ static int do_ls(int argc, char **argv)
|
|||
return -1;
|
||||
}
|
||||
file->id = (cur[0] << 8) | cur[1];
|
||||
cur += 2;
|
||||
cur += 2;
|
||||
count -= 2;
|
||||
print_file(file);
|
||||
sc_file_free(file);
|
||||
print_file(file);
|
||||
sc_file_free(file);
|
||||
r = sc_select_file(card, ¤t_path, NULL);
|
||||
if (r) {
|
||||
printf("unable to select parent DF: %s\n", sc_strerror(r));
|
||||
die(1);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return 0;
|
||||
usage:
|
||||
puts("Usage: ls");
|
||||
return -1;
|
||||
|
@ -232,14 +232,14 @@ static int do_cd(int argc, char **argv)
|
|||
struct sc_file *file;
|
||||
int r;
|
||||
|
||||
if (argc != 1)
|
||||
goto usage;
|
||||
if (argc != 1)
|
||||
goto usage;
|
||||
if (strcmp(argv[0], "..") == 0) {
|
||||
if (current_path.len < 4) {
|
||||
printf("unable to go up, already in MF.\n");
|
||||
return -1;
|
||||
}
|
||||
path = current_path;
|
||||
path = current_path;
|
||||
path.len -= 2;
|
||||
r = sc_select_file(card, &path, &file);
|
||||
if (r) {
|
||||
|
@ -252,7 +252,7 @@ static int do_cd(int argc, char **argv)
|
|||
return 0;
|
||||
}
|
||||
if (arg_to_path(argv[0], &path, 0) != 0)
|
||||
goto usage;
|
||||
goto usage;
|
||||
|
||||
r = sc_select_file(card, &path, &file);
|
||||
if (r) {
|
||||
|
@ -330,18 +330,18 @@ static int do_cat(int argc, char **argv)
|
|||
{
|
||||
int r, err = 0;
|
||||
struct sc_path path;
|
||||
struct sc_file *file;
|
||||
struct sc_file *file;
|
||||
int not_current = 1;
|
||||
|
||||
if (argc > 1)
|
||||
goto usage;
|
||||
if (argc > 1)
|
||||
goto usage;
|
||||
if (!argc) {
|
||||
path = current_path;
|
||||
file = current_file;
|
||||
not_current = 0;
|
||||
} else {
|
||||
if (arg_to_path(argv[0], &path, 0) != 0)
|
||||
goto usage;
|
||||
goto usage;
|
||||
|
||||
r = sc_select_file(card, &path, &file);
|
||||
if (r) {
|
||||
|
@ -366,10 +366,10 @@ static int do_cat(int argc, char **argv)
|
|||
die(1);
|
||||
}
|
||||
}
|
||||
return -err;
|
||||
usage:
|
||||
puts("Usage: cat [file_id]");
|
||||
return -1;
|
||||
return -err;
|
||||
usage:
|
||||
puts("Usage: cat [file_id]");
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int do_info(int argc, char **argv)
|
||||
|
@ -386,15 +386,14 @@ static int do_info(int argc, char **argv)
|
|||
not_current = 0;
|
||||
} else if (argc == 1) {
|
||||
if (arg_to_path(argv[0], &path, 0) != 0)
|
||||
goto usage;
|
||||
goto usage;
|
||||
r = sc_select_file(card, &path, &file);
|
||||
if (r) {
|
||||
printf("unable to select file: %s\n", sc_strerror(r));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
goto usage;
|
||||
} else
|
||||
goto usage;
|
||||
|
||||
switch (file->type) {
|
||||
case SC_FILE_TYPE_WORKING_EF:
|
||||
|
@ -412,7 +411,7 @@ static int do_info(int argc, char **argv)
|
|||
printf("%-15s", "File path:");
|
||||
for (i = 0; i < path.len; i++) {
|
||||
for (i = 0; i < path.len; i++) {
|
||||
if ((i & 1) == 0 && i)
|
||||
if ((i & 1) == 0 && i)
|
||||
printf("/");
|
||||
printf("%02X", path.value[i]);
|
||||
}
|
||||
|
@ -436,11 +435,11 @@ static int do_info(int argc, char **argv)
|
|||
printf("%-25s%s\n", buf, acl_to_str(sc_file_get_acl_entry(file, i)));
|
||||
}
|
||||
} else {
|
||||
const char *structs[] = {
|
||||
"Unknown", "Transparent", "Linear fixed",
|
||||
const char *structs[] = {
|
||||
"Unknown", "Transparent", "Linear fixed",
|
||||
"Linear fixed, SIMPLE-TLV", "Linear variable",
|
||||
"Linear variable TLV", "Cyclic, SIMPLE-TLV",
|
||||
};
|
||||
};
|
||||
const char *ops[] = {
|
||||
"READ", "UPDATE", "WRITE", "ERASE", "REHABILITATE",
|
||||
"INVALIDATE", "LIST_FILES", "CRYPTO",
|
||||
|
@ -476,9 +475,9 @@ static int do_info(int argc, char **argv)
|
|||
}
|
||||
return 0;
|
||||
|
||||
usage:
|
||||
puts("Usage: info [file_id]");
|
||||
return -1;
|
||||
usage:
|
||||
puts("Usage: info [file_id]");
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int create_file(struct sc_file *file)
|
||||
|
@ -507,8 +506,8 @@ static int do_create(int argc, char **argv)
|
|||
unsigned int size;
|
||||
int r, op;
|
||||
|
||||
if (argc != 2)
|
||||
goto usage;
|
||||
if (argc != 2)
|
||||
goto usage;
|
||||
if (arg_to_path(argv[0], &path, 1) != 0)
|
||||
goto usage;
|
||||
/* %z isn't supported everywhere */
|
||||
|
@ -538,8 +537,8 @@ static int do_mkdir(int argc, char **argv)
|
|||
unsigned int size;
|
||||
int r, op;
|
||||
|
||||
if (argc != 2)
|
||||
goto usage;
|
||||
if (argc != 2)
|
||||
goto usage;
|
||||
if (arg_to_path(argv[0], &path, 1) != 0)
|
||||
goto usage;
|
||||
if (sscanf(argv[1], "%d", &size) != 1)
|
||||
|
@ -565,8 +564,8 @@ static int do_delete(int argc, char **argv)
|
|||
struct sc_path path;
|
||||
int r;
|
||||
|
||||
if (argc != 1)
|
||||
goto usage;
|
||||
if (argc != 1)
|
||||
goto usage;
|
||||
if (arg_to_path(argv[0], &path, 1) != 0)
|
||||
goto usage;
|
||||
if (path.len != 2)
|
||||
|
@ -597,12 +596,12 @@ static int do_verify(int argc, char **argv)
|
|||
};
|
||||
int r, tries_left = -1;
|
||||
u8 buf[30];
|
||||
const char *s;
|
||||
const char *s;
|
||||
size_t buflen = sizeof(buf), i;
|
||||
struct sc_pin_cmd_data data;
|
||||
|
||||
if (argc < 1 || argc > 2)
|
||||
goto usage;
|
||||
goto usage;
|
||||
|
||||
memset(&data, 0, sizeof(data));
|
||||
data.cmd = SC_PIN_CMD_VERIFY;
|
||||
|
@ -613,7 +612,7 @@ static int do_verify(int argc, char **argv)
|
|||
data.pin_type = typeNames[i].type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (data.pin_type == SC_AC_NONE) {
|
||||
printf("Invalid type.\n");
|
||||
goto usage;
|
||||
|
@ -623,21 +622,21 @@ static int do_verify(int argc, char **argv)
|
|||
goto usage;
|
||||
}
|
||||
|
||||
if (argc < 2) {
|
||||
if (argc < 2) {
|
||||
if (!(card->reader->slot[0].capabilities & SC_SLOT_CAP_PIN_PAD)) {
|
||||
printf("Card reader or driver doesn't support PIN PAD\n");
|
||||
return -1;
|
||||
}
|
||||
printf("Please enter PIN on the reader's pin pad.\n");
|
||||
data.pin1.prompt = "Please enter PIN";
|
||||
data.flags |= SC_PIN_CMD_USE_PINPAD;
|
||||
} else if (argv[1][0] == '"') {
|
||||
data.flags |= SC_PIN_CMD_USE_PINPAD;
|
||||
} else if (argv[1][0] == '"') {
|
||||
for (s=argv[1]+1, i=0; i < sizeof(buf) && *s && *s != '"';i++)
|
||||
buf[i] = *s++;
|
||||
data.pin1.data = buf;
|
||||
data.pin1.len = i;
|
||||
} else {
|
||||
r = sc_hex_to_bin(argv[1], buf, &buflen);
|
||||
r = sc_hex_to_bin(argv[1], buf, &buflen);
|
||||
if (0 != r) {
|
||||
printf("Invalid key value.\n");
|
||||
goto usage;
|
||||
|
@ -711,7 +710,7 @@ static int do_change(int argc, char **argv)
|
|||
|
||||
if (argv[0][0] == '"') {
|
||||
for (s = argv[0] + 1, i = 0;
|
||||
i < sizeof(newpin) && *s && *s != '"'; i++)
|
||||
i < sizeof(newpin) && *s && *s != '"'; i++)
|
||||
newpin[i] = *s++;
|
||||
newpinlen = i;
|
||||
} else if (sc_hex_to_bin(argv[0], newpin, &newpinlen) != 0) {
|
||||
|
@ -782,7 +781,7 @@ static int do_unblock(int argc, char **argv)
|
|||
|
||||
if (argv[0][0] == '"') {
|
||||
for (s = argv[0] + 1, i = 0;
|
||||
i < sizeof(newpin) && *s && *s != '"'; i++)
|
||||
i < sizeof(newpin) && *s && *s != '"'; i++)
|
||||
newpin[i] = *s++;
|
||||
newpinlen = i;
|
||||
} else if (sc_hex_to_bin(argv[0], newpin, &newpinlen) != 0) {
|
||||
|
|
|
@ -219,8 +219,8 @@ main(int argc, char * const argv[])
|
|||
CK_RV rv;
|
||||
|
||||
while (1) {
|
||||
c = getopt_long(argc, argv, "ILMOa:d:e:hi:klm:o:p:scvty:w:z:r",
|
||||
options, &long_optind);
|
||||
c = getopt_long(argc, argv, "ILMOa:d:e:hi:klm:o:p:scvty:w:z:r",
|
||||
options, &long_optind);
|
||||
if (c == -1)
|
||||
break;
|
||||
switch (c) {
|
||||
|
@ -1043,10 +1043,10 @@ find_object(CK_SESSION_HANDLE sess, CK_OBJECT_CLASS cls,
|
|||
attrs[0].ulValueLen = sizeof(cls);
|
||||
nattrs++;
|
||||
if (id) {
|
||||
attrs[nattrs].type = CKA_ID;
|
||||
attrs[nattrs].pValue = (void *) id;
|
||||
attrs[nattrs].ulValueLen = id_len;
|
||||
nattrs++;
|
||||
attrs[nattrs].type = CKA_ID;
|
||||
attrs[nattrs].pValue = (void *) id;
|
||||
attrs[nattrs].ulValueLen = id_len;
|
||||
nattrs++;
|
||||
}
|
||||
|
||||
rv = p11->C_FindObjectsInit(sess, attrs, nattrs);
|
||||
|
@ -1370,12 +1370,11 @@ show_dobj(CK_SESSION_HANDLE sess, CK_OBJECT_HANDLE obj)
|
|||
}
|
||||
|
||||
printf(" flags: ");
|
||||
if (getMODIFIABLE(sess, obj))
|
||||
if (getMODIFIABLE(sess, obj))
|
||||
printf(" modifiable");
|
||||
if (getPRIVATE(sess, obj))
|
||||
if (getPRIVATE(sess, obj))
|
||||
printf(" private");
|
||||
printf ("\n");
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2065,7 +2064,7 @@ sign_verify(CK_SLOT_ID slot, CK_SESSION_HANDLE session, CK_OBJECT_HANDLE priv_ke
|
|||
CK_ULONG signat_len;
|
||||
int j, errors = 0;
|
||||
|
||||
memcpy(buf, "\x00\x01\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00", 11);
|
||||
memcpy(buf, "\x00\x01\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00", 11);
|
||||
|
||||
for (j = 0, mech_type = mech_types; *mech_type != 0xffffff; mech_type++, j++) {
|
||||
CK_MECHANISM mech = {*mech_type, NULL, 0};
|
||||
|
@ -2863,7 +2862,7 @@ int hex_to_bin(const char *in, unsigned char *out, size_t *outlen)
|
|||
return 1;
|
||||
}
|
||||
|
||||
left = *outlen;
|
||||
left = *outlen;
|
||||
|
||||
while (*in != '\0') {
|
||||
int byte = 0, nybbles = 2;
|
||||
|
|
|
@ -113,7 +113,7 @@ struct sc_pkcs15_card *p15card = NULL;
|
|||
static void print_cert_info(const struct sc_pkcs15_object *obj)
|
||||
{
|
||||
unsigned int i;
|
||||
struct sc_pkcs15_cert_info *cert = (struct sc_pkcs15_cert_info *) obj->data;
|
||||
struct sc_pkcs15_cert_info *cert = (struct sc_pkcs15_cert_info *) obj->data;
|
||||
|
||||
printf("X.509 Certificate [%s]\n", obj->label);
|
||||
printf("\tFlags : %d\n", obj->flags);
|
||||
|
@ -129,7 +129,7 @@ static void print_cert_info(const struct sc_pkcs15_object *obj)
|
|||
static int list_certificates(void)
|
||||
{
|
||||
int r, i;
|
||||
struct sc_pkcs15_object *objs[32];
|
||||
struct sc_pkcs15_object *objs[32];
|
||||
|
||||
r = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_CERT_X509, objs, 32);
|
||||
if (r < 0) {
|
||||
|
@ -362,7 +362,7 @@ static int list_data_objects(void)
|
|||
static void print_prkey_info(const struct sc_pkcs15_object *obj)
|
||||
{
|
||||
unsigned int i;
|
||||
struct sc_pkcs15_prkey_info *prkey = (struct sc_pkcs15_prkey_info *) obj->data;
|
||||
struct sc_pkcs15_prkey_info *prkey = (struct sc_pkcs15_prkey_info *) obj->data;
|
||||
const char *usages[] = {
|
||||
"encrypt", "decrypt", "sign", "signRecover",
|
||||
"wrap", "unwrap", "verify", "verifyRecover",
|
||||
|
@ -378,17 +378,17 @@ static void print_prkey_info(const struct sc_pkcs15_object *obj)
|
|||
printf("Private RSA Key [%s]\n", obj->label);
|
||||
printf("\tCom. Flags : %X\n", obj->flags);
|
||||
printf("\tUsage : [0x%X]", prkey->usage);
|
||||
for (i = 0; i < usage_count; i++)
|
||||
if (prkey->usage & (1 << i)) {
|
||||
printf(", %s", usages[i]);
|
||||
}
|
||||
for (i = 0; i < usage_count; i++)
|
||||
if (prkey->usage & (1 << i)) {
|
||||
printf(", %s", usages[i]);
|
||||
}
|
||||
printf("\n");
|
||||
printf("\tAccess Flags: [0x%X]", prkey->access_flags);
|
||||
for (i = 0; i < af_count; i++)
|
||||
if (prkey->access_flags & (1 << i)) {
|
||||
printf(", %s", access_flags[i]);
|
||||
}
|
||||
printf("\n");
|
||||
for (i = 0; i < af_count; i++)
|
||||
if (prkey->access_flags & (1 << i)) {
|
||||
printf(", %s", access_flags[i]);
|
||||
}
|
||||
printf("\n");
|
||||
printf("\tModLength : %d\n", prkey->modulus_length);
|
||||
printf("\tKey ref : %d\n", prkey->key_reference);
|
||||
printf("\tNative : %s\n", prkey->native ? "yes" : "no");
|
||||
|
@ -423,7 +423,7 @@ static int list_private_keys(void)
|
|||
static void print_pubkey_info(const struct sc_pkcs15_object *obj)
|
||||
{
|
||||
unsigned int i;
|
||||
const struct sc_pkcs15_pubkey_info *pubkey = (const struct sc_pkcs15_pubkey_info *) obj->data;
|
||||
const struct sc_pkcs15_pubkey_info *pubkey = (const struct sc_pkcs15_pubkey_info *) obj->data;
|
||||
const char *usages[] = {
|
||||
"encrypt", "decrypt", "sign", "signRecover",
|
||||
"wrap", "unwrap", "verify", "verifyRecover",
|
||||
|
@ -439,17 +439,17 @@ static void print_pubkey_info(const struct sc_pkcs15_object *obj)
|
|||
printf("Public RSA Key [%s]\n", obj->label);
|
||||
printf("\tCom. Flags : %X\n", obj->flags);
|
||||
printf("\tUsage : [0x%X]", pubkey->usage);
|
||||
for (i = 0; i < usage_count; i++)
|
||||
if (pubkey->usage & (1 << i)) {
|
||||
printf(", %s", usages[i]);
|
||||
}
|
||||
for (i = 0; i < usage_count; i++)
|
||||
if (pubkey->usage & (1 << i)) {
|
||||
printf(", %s", usages[i]);
|
||||
}
|
||||
printf("\n");
|
||||
printf("\tAccess Flags: [0x%X]", pubkey->access_flags);
|
||||
for (i = 0; i < af_count; i++)
|
||||
if (pubkey->access_flags & (1 << i)) {
|
||||
printf(", %s", access_flags[i]);
|
||||
}
|
||||
printf("\n");
|
||||
for (i = 0; i < af_count; i++)
|
||||
if (pubkey->access_flags & (1 << i)) {
|
||||
printf(", %s", access_flags[i]);
|
||||
}
|
||||
printf("\n");
|
||||
printf("\tModLength : %d\n", pubkey->modulus_length);
|
||||
printf("\tKey ref : %d\n", pubkey->key_reference);
|
||||
printf("\tNative : %s\n", pubkey->native ? "yes" : "no");
|
||||
|
@ -464,7 +464,7 @@ static void print_pubkey_info(const struct sc_pkcs15_object *obj)
|
|||
static int list_public_keys(void)
|
||||
{
|
||||
int r, i;
|
||||
struct sc_pkcs15_object *objs[32];
|
||||
struct sc_pkcs15_object *objs[32];
|
||||
|
||||
r = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_PUBKEY_RSA, objs, 32);
|
||||
if (r < 0) {
|
||||
|
@ -544,11 +544,11 @@ static int read_public_key(void)
|
|||
static sc_pkcs15_object_t *
|
||||
get_pin_info(void)
|
||||
{
|
||||
sc_pkcs15_object_t *objs[32], *obj;
|
||||
sc_pkcs15_object_t *objs[32], *obj;
|
||||
int r;
|
||||
|
||||
if (opt_auth_id == NULL) {
|
||||
r = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_AUTH_PIN, objs, 32);
|
||||
r = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_AUTH_PIN, objs, 32);
|
||||
if (r < 0) {
|
||||
fprintf(stderr, "PIN code enumeration failed: %s\n", sc_strerror(r));
|
||||
return NULL;
|
||||
|
@ -557,7 +557,7 @@ get_pin_info(void)
|
|||
fprintf(stderr, "No PIN codes found.\n");
|
||||
return NULL;
|
||||
}
|
||||
obj = objs[0];
|
||||
obj = objs[0];
|
||||
} else {
|
||||
struct sc_pkcs15_id auth_id;
|
||||
|
||||
|
@ -627,7 +627,7 @@ static void print_pin_info(const struct sc_pkcs15_object *obj)
|
|||
};
|
||||
const char *pin_types[] = {"bcd", "ascii-numeric", "UTF-8",
|
||||
"halfnibble bcd", "iso 9664-1"};
|
||||
const struct sc_pkcs15_pin_info *pin = (const struct sc_pkcs15_pin_info *) obj->data;
|
||||
const struct sc_pkcs15_pin_info *pin = (const struct sc_pkcs15_pin_info *) obj->data;
|
||||
const size_t pf_count = sizeof(pin_flags)/sizeof(pin_flags[0]);
|
||||
char path[SC_MAX_PATH_SIZE * 2 + 1];
|
||||
size_t i;
|
||||
|
@ -822,7 +822,7 @@ static int learn_card(void)
|
|||
{
|
||||
char dir[PATH_MAX];
|
||||
int r, i, cert_count;
|
||||
struct sc_pkcs15_object *certs[32];
|
||||
struct sc_pkcs15_object *certs[32];
|
||||
struct sc_pkcs15_df *df;
|
||||
|
||||
r = sc_get_cache_dir(ctx, dir, sizeof(dir));
|
||||
|
@ -832,18 +832,18 @@ static int learn_card(void)
|
|||
}
|
||||
|
||||
printf("Using cache directory '%s'.\n", dir);
|
||||
r = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_CERT_X509, certs, 32);
|
||||
r = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_CERT_X509, certs, 32);
|
||||
if (r < 0) {
|
||||
fprintf(stderr, "Certificate enumeration failed: %s\n", sc_strerror(r));
|
||||
return 1;
|
||||
}
|
||||
cert_count = r;
|
||||
r = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_PRKEY_RSA, NULL, 0);
|
||||
cert_count = r;
|
||||
r = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_PRKEY_RSA, NULL, 0);
|
||||
if (r < 0) {
|
||||
fprintf(stderr, "Private key enumeration failed: %s\n", sc_strerror(r));
|
||||
return 1;
|
||||
}
|
||||
r = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_AUTH_PIN, NULL, 0);
|
||||
r = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_AUTH_PIN, NULL, 0);
|
||||
if (r < 0) {
|
||||
fprintf(stderr, "PIN code enumeration failed: %s\n", sc_strerror(r));
|
||||
return 1;
|
||||
|
|
Loading…
Reference in New Issue