- Introduce _sc_match_atr_hex / struct sc_atr_table_hex.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2130 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
10e9bd4e05
commit
cbe2904889
|
@ -22,6 +22,9 @@
|
||||||
#include "asn1.h"
|
#include "asn1.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
int sc_check_sw(struct sc_card *card, int sw1, int sw2)
|
int sc_check_sw(struct sc_card *card, int sw1, int sw2)
|
||||||
|
@ -917,6 +920,32 @@ int _sc_match_atr(struct sc_card *card, struct sc_atr_table *table, int *id_out)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int _sc_match_atr_hex(struct sc_card *card, struct sc_atr_table_hex *table, int *id_out)
|
||||||
|
{
|
||||||
|
const u8 *atr = card->atr;
|
||||||
|
size_t atr_len = card->atr_len;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
if (table == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
for (i = 0; table[i].atr != NULL; i++) {
|
||||||
|
u8 tatr[SC_MAX_ATR_SIZE];
|
||||||
|
size_t tlen = sizeof(tatr);
|
||||||
|
|
||||||
|
if (sc_hex_to_bin(table[i].atr, tatr, &tlen))
|
||||||
|
continue;
|
||||||
|
if (tlen != atr_len)
|
||||||
|
continue;
|
||||||
|
if (memcmp(tatr, atr, tlen) != 0)
|
||||||
|
continue;
|
||||||
|
if (id_out != NULL)
|
||||||
|
*id_out = table[i].id;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
int _sc_add_atr(struct sc_card_driver *driver,
|
int _sc_add_atr(struct sc_card_driver *driver,
|
||||||
const u8 *atr, size_t atrlen, int id)
|
const u8 *atr, size_t atrlen, int id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,6 +44,13 @@ struct sc_atr_table {
|
||||||
int id;
|
int id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct sc_atr_table_hex {
|
||||||
|
const char *atr;
|
||||||
|
const char *name;
|
||||||
|
int id;
|
||||||
|
unsigned flags;
|
||||||
|
};
|
||||||
|
|
||||||
/* Internal use only */
|
/* Internal use only */
|
||||||
int sc_check_sw(struct sc_card *card, int sw1, int sw2);
|
int sc_check_sw(struct sc_card *card, int sw1, int sw2);
|
||||||
size_t _sc_count_bit_string_size(const void * buf, size_t bufsize);
|
size_t _sc_count_bit_string_size(const void * buf, size_t bufsize);
|
||||||
|
@ -58,6 +65,7 @@ int _sc_add_atr(struct sc_card_driver *, const u8 *, size_t, int);
|
||||||
/* Returns an index number if a match was found, -1 otherwise. table has to
|
/* Returns an index number if a match was found, -1 otherwise. table has to
|
||||||
* be null terminated. */
|
* be null terminated. */
|
||||||
int _sc_match_atr(struct sc_card *card, struct sc_atr_table *table, int *id_out);
|
int _sc_match_atr(struct sc_card *card, struct sc_atr_table *table, int *id_out);
|
||||||
|
int _sc_match_atr_hex(struct sc_card *card, struct sc_atr_table_hex *table, int *id_out);
|
||||||
|
|
||||||
int _sc_card_add_algorithm(struct sc_card *card, const struct sc_algorithm_info *info);
|
int _sc_card_add_algorithm(struct sc_card *card, const struct sc_algorithm_info *info);
|
||||||
int _sc_card_add_rsa_alg(struct sc_card *card, unsigned int key_length,
|
int _sc_card_add_rsa_alg(struct sc_card *card, unsigned int key_length,
|
||||||
|
|
Loading…
Reference in New Issue