X-Git-Url: http://www.average.org/gitweb/?p=pam_pcsc_cr.git;a=blobdiff_plain;f=ykneo.c;h=79c86e5302ec3176ac5172f9752171a33b85ca33;hp=3399f711a0c8323fbf71c597c05af6763fd3d492;hb=0894042d90da9c8ad0d03e875c727442e778a7d6;hpb=7c4066e68330f89016e939a6ad34036f9e00c11d diff --git a/ykneo.c b/ykneo.c index 3399f71..79c86e5 100644 --- a/ykneo.c +++ b/ykneo.c @@ -1,3 +1,4 @@ +#include #include #include @@ -7,7 +8,27 @@ static const BYTE selcmd[] = {0x00, 0xA4, 0x04, 0x00, 0x07, 0xA0, 0x00, 0x00, 0x05, 0x27, 0x20, 0x01, 0x00}; -static const BYTE cr_cmd[] = {0x00, 0x01, 0x38, 0x00}; +static const BYTE cr_cmd[] = {0x00, 0x01, 0xff, 0x00}; + +static BYTE cr_for_slot[3] = {0xff, 0x30, 0x38}; + +static int slot; + +static int ykn_parse_option(char *key, char *val) +{ + if (!strcmp(key, "slot")) { + if (!strcmp(val, "1")) { + slot = 1; + } else if (!strcmp(val, "2")) { + slot = 2; + } else { + return -1; + } + } else { + return -1; + } + return 0; +} static DWORD ykn_check_atr_hb(LPTSTR str, DWORD size) { @@ -39,6 +60,7 @@ static DWORD ykn_trancieve(SCARDHANDLE hCard,LPTSTR envp[], BYTE *rbuf = alloca(rsize); BYTE *sbuf = alloca(sendsize + 6); memcpy(sbuf, cr_cmd, sizeof(cr_cmd)); + sbuf[2] = cr_for_slot[slot]; sbuf[sizeof(cr_cmd)] = sendsize; memcpy(sbuf + sizeof(cr_cmd) + 1, send, sendsize); sbuf[sendsize + 5] = rsize; @@ -58,6 +80,8 @@ static DWORD ykn_epilogue(SCARDHANDLE hCard,LPTSTR envp[]) } struct token_interface ykneo_interface = { + .name = "ykneo", + .parse_option = ykn_parse_option, .check_atr_hb = ykn_check_atr_hb, .prologue = ykn_prologue, .trancieve = ykn_trancieve,