get rid of the YKPIV_APDU_* macros
transport the starting 4 bytes as an array instead
This commit is contained in:
+2
-2
@@ -148,7 +148,7 @@ ykpiv_rc ykpiv_connect(ykpiv_state *state, const char *wanted) {
|
||||
return YKPIV_OK;
|
||||
}
|
||||
|
||||
ykpiv_rc ykpiv_transfer_data(ykpiv_state *state, uint32_t template,
|
||||
ykpiv_rc ykpiv_transfer_data(ykpiv_state *state, unsigned char *templ,
|
||||
unsigned char *in_data, long in_len,
|
||||
unsigned char *out_data, unsigned long *out_len, int *sw) {
|
||||
unsigned char *in_ptr = in_data;
|
||||
@@ -163,7 +163,7 @@ ykpiv_rc ykpiv_transfer_data(ykpiv_state *state, uint32_t template,
|
||||
APDU apdu;
|
||||
|
||||
memset(apdu.raw, 0, sizeof(apdu.raw));
|
||||
YKPIV_APDU_UNPACK(apdu.raw, template);
|
||||
memcpy(apdu.raw, templ, 4);
|
||||
if(in_ptr + 0xff < in_data + in_len) {
|
||||
apdu.st.cla = 0x10;
|
||||
} else {
|
||||
|
||||
+1
-5
@@ -52,16 +52,12 @@ extern "C"
|
||||
ykpiv_rc ykpiv_init(ykpiv_state **state, int verbose);
|
||||
ykpiv_rc ykpiv_done(ykpiv_state *state);
|
||||
ykpiv_rc ykpiv_connect(ykpiv_state *state, const char *wanted);
|
||||
ykpiv_rc ykpiv_transfer_data(ykpiv_state *state, uint32_t template,
|
||||
ykpiv_rc ykpiv_transfer_data(ykpiv_state *state, unsigned char *templ,
|
||||
unsigned char *in_data, long in_len,
|
||||
unsigned char *out_data, unsigned long *out_len, int *sw);
|
||||
ykpiv_rc ykpiv_send_data(ykpiv_state *state, unsigned char *apdu,
|
||||
unsigned char *data, unsigned long *recv_len, int *sw);
|
||||
|
||||
#define YKPIV_APDU_TEMPLATE(i,j,k,l) ((i & 0xff) << 24 | (j & 0xff) << 16 | (k & 0xff) << 8 | (l & 0xff))
|
||||
#define YKPIV_APDU_UNPACK(c, t) (c[0] = ((t >> 24) & 0xff), \
|
||||
c[1] = ((t >> 16) & 0xff), c[2] = ((t >> 8) & 0xff), c[3] = (t & 0xff))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user