the apdu error codes are unsigned => change sc_check_sw and the card ops check_sw
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2467 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
44384eccbf
commit
69ffd496b2
|
@ -797,7 +797,8 @@ static int atrust_acos_decipher(struct sc_card *card,
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static int atrust_acos_check_sw(struct sc_card *card, int sw1, int sw2)
|
||||
static int atrust_acos_check_sw(struct sc_card *card, unsigned int sw1,
|
||||
unsigned int sw2)
|
||||
{
|
||||
|
||||
if (card->ctx->debug >= 3)
|
||||
|
@ -805,7 +806,7 @@ static int atrust_acos_check_sw(struct sc_card *card, int sw1, int sw2)
|
|||
|
||||
if (sw1 == 0x90)
|
||||
return SC_NO_ERROR;
|
||||
if (sw1 == 0x63 && (sw2 & ~0x0f) == 0xc0 )
|
||||
if (sw1 == 0x63 && (sw2 & ~0x0fU) == 0xc0 )
|
||||
{
|
||||
sc_error(card->ctx, "Verification failed (remaining tries: %d)\n",
|
||||
(sw2 & 0x0f));
|
||||
|
|
|
@ -154,7 +154,7 @@ static const struct sc_card_error etoken_errors[] = {
|
|||
{ 0x9850, SC_NO_ERROR, "over/underflow useing in/decrease"}
|
||||
};
|
||||
|
||||
static int etoken_check_sw(sc_card_t *card, int sw1, int sw2)
|
||||
static int etoken_check_sw(sc_card_t *card, unsigned int sw1, unsigned int sw2)
|
||||
{
|
||||
const int err_count = sizeof(etoken_errors)/sizeof(etoken_errors[0]);
|
||||
int i;
|
||||
|
|
|
@ -529,8 +529,9 @@ static int starcos_select_file(sc_card_t *card,
|
|||
#define STARCOS_AC_NEVER 0x5f
|
||||
#define STARCOS_PINID2STATE(a) ((((a) & 0x0f) == 0x01) ? ((a) & 0x0f) : (0x0f - ((0x0f & (a)) >> 1)))
|
||||
|
||||
static u8 process_acl_entry(sc_file_t *in, unsigned int method, u8 def)
|
||||
static u8 process_acl_entry(sc_file_t *in, unsigned int method, unsigned int in_def)
|
||||
{
|
||||
u8 def = (u8)in_def;
|
||||
const sc_acl_entry_t *entry = sc_file_get_acl_entry(in, method);
|
||||
if (!entry)
|
||||
return def;
|
||||
|
@ -1249,7 +1250,7 @@ static int starcos_compute_signature(sc_card_t *card,
|
|||
SC_FUNC_RETURN(card->ctx, 4, sc_check_sw(card, apdu.sw1, apdu.sw2));
|
||||
}
|
||||
|
||||
static int starcos_check_sw(sc_card_t *card, int sw1, int sw2)
|
||||
static int starcos_check_sw(sc_card_t *card, unsigned int sw1, unsigned int sw2)
|
||||
{
|
||||
const int err_count = sizeof(starcos_errors)/sizeof(starcos_errors[0]);
|
||||
int i;
|
||||
|
@ -1259,7 +1260,7 @@ static int starcos_check_sw(sc_card_t *card, int sw1, int sw2)
|
|||
|
||||
if (sw1 == 0x90)
|
||||
return SC_NO_ERROR;
|
||||
if (sw1 == 0x63 && (sw2 & ~0x0f) == 0xc0 )
|
||||
if (sw1 == 0x63 && (sw2 & ~0x0fU) == 0xc0 )
|
||||
{
|
||||
sc_error(card->ctx, "Verification failed (remaining tries: %d)\n",
|
||||
(sw2 & 0x0f));
|
||||
|
|
|
@ -27,9 +27,12 @@
|
|||
#endif
|
||||
#include <string.h>
|
||||
|
||||
int sc_check_sw(sc_card_t *card, int sw1, int sw2)
|
||||
int sc_check_sw(sc_card_t *card, unsigned int sw1, unsigned int sw2)
|
||||
{
|
||||
assert(card->ops->check_sw != NULL);
|
||||
if (card == NULL)
|
||||
return SC_ERROR_INVALID_ARGUMENTS;
|
||||
if (card->ops->check_sw == NULL)
|
||||
return SC_ERROR_NOT_SUPPORTED;
|
||||
return card->ops->check_sw(card, sw1, sw2);
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ struct sc_atr_table {
|
|||
};
|
||||
|
||||
/* Internal use only */
|
||||
int sc_check_sw(struct sc_card *card, int sw1, int sw2);
|
||||
int sc_check_sw(struct sc_card *card, unsigned int sw1, unsigned int sw2);
|
||||
size_t _sc_count_bit_string_size(const void * buf, size_t bufsize);
|
||||
|
||||
int _sc_add_reader(struct sc_context *ctx, struct sc_reader *reader);
|
||||
|
|
|
@ -76,7 +76,7 @@ static const struct sc_card_error iso7816_errors[] = {
|
|||
{ 0x6A8A, SC_ERROR_FILE_ALREADY_EXISTS, "Application exists"},
|
||||
};
|
||||
|
||||
static int iso7816_check_sw(sc_card_t *card, int sw1, int sw2)
|
||||
static int iso7816_check_sw(sc_card_t *card, unsigned int sw1, unsigned int sw2)
|
||||
{
|
||||
const int err_count = sizeof(iso7816_errors)/sizeof(iso7816_errors[0]);
|
||||
int i;
|
||||
|
@ -88,7 +88,7 @@ static int iso7816_check_sw(sc_card_t *card, int sw1, int sw2)
|
|||
}
|
||||
if (sw1 == 0x90)
|
||||
return SC_NO_ERROR;
|
||||
if (sw1 == 0x63 && (sw2 & ~0x0f) == 0xc0 ) {
|
||||
if (sw1 == 0x63U && (sw2 & ~0x0fU) == 0xc0U ) {
|
||||
sc_error(card->ctx, "Verification failed (remaining tries: %d)\n",
|
||||
(sw2 & 0x0f));
|
||||
return SC_ERROR_PIN_CODE_INCORRECT;
|
||||
|
|
|
@ -599,7 +599,7 @@ struct sc_card_operations {
|
|||
* the number of bytes stored. */
|
||||
int (*list_files)(struct sc_card *card, u8 *buf, size_t buflen);
|
||||
|
||||
int (*check_sw)(struct sc_card *card, int sw1, int sw2);
|
||||
int (*check_sw)(struct sc_card *card,unsigned int sw1,unsigned int sw2);
|
||||
int (*card_ctl)(struct sc_card *card, unsigned long request,
|
||||
void *data);
|
||||
int (*process_fci)(struct sc_card *card, struct sc_file *file,
|
||||
|
@ -884,7 +884,7 @@ const sc_app_info_t * sc_find_app_by_aid(sc_card_t *card,
|
|||
int sc_update_dir(sc_card_t *card, sc_app_info_t *app);
|
||||
|
||||
struct sc_card_error {
|
||||
int SWs;
|
||||
unsigned int SWs;
|
||||
int errorno;
|
||||
const char *errorstr;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue