let the ykpiv_connect() function select as well

This commit is contained in:
Klas Lindfors
2014-06-17 09:20:32 +02:00
parent 9eb5c7fda1
commit 6dcb6798e6
4 changed files with 24 additions and 31 deletions
+1
View File
@@ -45,6 +45,7 @@ static const err_t errors[] = {
ERR (YKPIV_MEMORY_ERROR, "Error allocating memory"),
ERR (YKPIV_PCSC_ERROR, "Error in PCSC call"),
ERR (YKPIV_SIZE_ERROR, "Wrong buffer size"),
ERR (YKPIV_APPLET_ERROR, "No PIV applet found"),
};
/**
+22
View File
@@ -145,6 +145,28 @@ ykpiv_rc ykpiv_connect(ykpiv_state *state, const char *wanted) {
return YKPIV_PCSC_ERROR;
}
{
APDU apdu;
unsigned char data[0xff];
unsigned long recv_len = sizeof(data);
int sw;
ykpiv_rc res;
memset(apdu.raw, 0, sizeof(apdu));
apdu.st.ins = 0xa4;
apdu.st.p1 = 0x04;
apdu.st.lc = sizeof(aid);
memcpy(apdu.st.data, aid, sizeof(aid));
if((res = ykpiv_send_data(state, apdu.raw, data, &recv_len, &sw) != YKPIV_OK)) {
return res;
} else if(sw == 0x9000) {
return YKPIV_OK;
}
return YKPIV_APPLET_ERROR;
}
return YKPIV_OK;
}
+1
View File
@@ -44,6 +44,7 @@ extern "C"
YKPIV_MEMORY_ERROR = -1,
YKPIV_PCSC_ERROR = -2,
YKPIV_SIZE_ERROR = -3,
YKPIV_APPLET_ERROR = -4,
} ykpiv_rc;
const char *ykpiv_strerror(ykpiv_rc err);