@@ -1843,9 +1843,10 @@ unsigned char *tmpbuf, *tmpbuf_s; unsigned char bytes_to_send, p1; cackey_ret send_ret; uint16_t respcode; - size_t tmpbuflen, padlen; + ssize_t retval; + size_t tmpbuflen, padlen, tmpoutbuflen; int free_tmpbuf = 0; int le; CACKEY_DEBUG_PRINTF("Called."); @@ -1950,9 +1951,11 @@ p1 = 0x00; le = 0x00; } - send_ret = cackey_send_apdu(slot, GSCIS_CLASS_GLOBAL_PLATFORM, GSCIS_INSTR_SIGNDECRYPT, p1, 0x00, bytes_to_send, tmpbuf, le, &respcode, outbuf, &outbuflen); + tmpoutbuflen = outbuflen; + + send_ret = cackey_send_apdu(slot, GSCIS_CLASS_GLOBAL_PLATFORM, GSCIS_INSTR_SIGNDECRYPT, p1, 0x00, bytes_to_send, tmpbuf, le, &respcode, outbuf, &tmpoutbuflen); if (send_ret != CACKEY_PCSC_S_OK) { CACKEY_DEBUG_PRINTF("ADPU Sending Failed -- returning in error."); if (respcode == 0x6982) { @@ -1972,8 +1975,12 @@ } tmpbuf += bytes_to_send; tmpbuflen -= bytes_to_send; + + outbuf += tmpoutbuflen; + outbuflen -= tmpoutbuflen; + retval += tmpoutbuflen; } if (free_tmpbuf) { if (tmpbuf_s) { @@ -1995,9 +2002,9 @@ #endif CACKEY_DEBUG_PRINTF("Returning in success."); - return(outbuflen); + return(retval); } /* * SYNPOSIS