Fix Windows emulation build.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos
2024-01-09 11:43:47 +01:00
parent 29837e5691
commit caddf87c23
4 changed files with 15 additions and 7 deletions

View File

@@ -145,9 +145,9 @@ uint16_t apdu_process(uint8_t itf, const uint8_t *buffer, uint16_t buffer_size)
}
#endif
#else
driver_exec_finished_cont_emul(itf, apdu.ne + 2, (uint16_t)(rdata_gr - apdu.ne - usb_get_tx(itf)));
driver_exec_finished_cont_emul(itf, (uint16_t)(apdu.ne + 2), (uint16_t)(rdata_gr - apdu.ne - usb_get_tx(itf)));
#endif
apdu.rlen -= apdu.ne;
apdu.rlen -= (uint16_t)apdu.ne;
}
}
else {
@@ -228,9 +228,9 @@ uint16_t apdu_next() {
else {
rdata_gr[1] = (uint8_t)(apdu.rlen - apdu.ne);
}
apdu.rlen -= apdu.ne;
apdu.rlen -= (uint16_t)apdu.ne;
}
return apdu.ne + 2;
return (uint16_t)(apdu.ne + 2);
}
return 0;
}

View File

@@ -113,7 +113,7 @@ int sm_unwrap() {
uint16_t tag = 0x0;
uint8_t *tag_data = NULL, *p = NULL;
uint16_t tag_len = 0;
while (walk_tlv(apdu.data, apdu.nc, &p, &tag, &tag_len, &tag_data)) {
while (walk_tlv(apdu.data, (uint16_t)apdu.nc, &p, &tag, &tag_len, &tag_data)) {
if (tag == 0x87 || tag == 0x85) {
body = tag_data;
body_size = tag_len;
@@ -209,7 +209,7 @@ uint16_t sm_get_le() {
uint16_t tag = 0x0;
uint8_t *tag_data = NULL, *p = NULL;
uint16_t tag_len = 0;
while (walk_tlv(apdu.data, apdu.nc, &p, &tag, &tag_len, &tag_data)) {
while (walk_tlv(apdu.data, (uint16_t)apdu.nc, &p, &tag, &tag_len, &tag_data)) {
if (tag == 0x97) {
uint16_t le = 0;
for (uint16_t t = 1; t <= tag_len; t++) {
@@ -266,7 +266,7 @@ int sm_verify() {
uint16_t tag = 0x0;
uint8_t *tag_data = NULL, *p = NULL;
uint16_t tag_len = 0;
while (walk_tlv(apdu.data, apdu.nc, &p, &tag, &tag_len, &tag_data)) {
while (walk_tlv(apdu.data, (uint16_t)apdu.nc, &p, &tag, &tag_len, &tag_data)) {
if (tag & 0x1) {
input[input_len++] = (uint8_t)tag;
uint8_t tlen = format_tlv_len(tag_len, input + input_len);

View File

@@ -334,7 +334,14 @@ uint16_t emul_read(uint8_t itf) {
uint16_t len = 0;
fd_set input;
FD_ZERO(&input);
#ifdef _WIN32
__pragma(warning(push))
__pragma(warning(disable:4548))
#endif
FD_SET(sock, &input);
#ifdef _WIN32
__pragma(warning(pop))
#endif
struct timeval timeout;
timeout.tv_sec = 0;
timeout.tv_usec = 0 * 1000;